# Importance of offset

What does the offset 20 signify in the below code?

using ModelingToolkit

@variables x y z
@parameters a b c

----Define a nonlinear system
eqs = [0 ~ - y - (z+20),
0 ~ x + a * y,
0 ~ b + (z+20) * (x - c)]
ns = NonlinearSystem(eqs, [x,y,z], [a,b,c])
nlsys_func = generate_function(ns) # second is the inplace version

rossler = ModelingToolkit.eval(nlsys_func)
du = zeros(3); u = ones(3)
params = (0.2,0.2,5.7)

j_func2 = generate_jacobian(ns) # second is in-place
j2! = ModelingToolkit.eval(j_func2)

using NLsolve
nlsolve((out, x) → rossler(out, x, params), (out, x) → j2!(out, x, params), ones(3))

out:

Results of Nonlinear Solver Algorithm

• Algorithm: Trust-region with dogleg and autoscaling
• Starting Point: [1.0, 1.0, 1.0]
• Zero: [0.007026204834100122, -0.035131024170500603, -19.9648689758295]
• Inf-norm of residuals: 0.000000
• Iterations: 8
• Convergence: true
• |x - x’| < 0.0e+00: false
• |f(x)| < 1.0e-08: true
• Function Calls (f): 9
• Jacobian Calls (df/dx): 9

What do you mean? The `+20`? It means it’s `+20` in the sample code?

1 Like

Yes,
is that given for the verification of the roots?

It’s just to make the test a bit non-trivial

1 Like