Skip to content

Commit 15c44d5

Browse files
committed
Clean up example a bit
1 parent 890d859 commit 15c44d5

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

docs/src/tutorials/nonlinear.md

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,26 @@ We use (unknown) variables for our nonlinear system.
99
```@example nonlinear
1010
using ModelingToolkit, NonlinearSolve
1111
12+
# Define a nonlinear system
1213
@variables x y z
1314
@parameters σ ρ β
15+
@mtkbuild ns = NonlinearSystem([
16+
0 ~ σ * (y - x)
17+
0 ~ x * (ρ - z) - y
18+
0 ~ x * y - β * z
19+
])
1420
15-
# Define a nonlinear system
16-
eqs = [0 ~ σ * (y - x),
17-
0 ~ x * (ρ - z) - y,
18-
0 ~ x * y - β * z]
19-
@mtkbuild ns = NonlinearSystem(eqs, [x, y, z], [σ, ρ, β])
20-
21-
guess = [x => 1.0,
22-
y => 0.0,
23-
z => 0.0]
24-
25-
ps = [σ => 10.0
26-
ρ => 26.0
27-
β => 8 / 3]
21+
guesses = [x => 1.0, y => 0.0, z => 0.0]
22+
ps = [σ => 10.0, ρ => 26.0, β => 8 / 3]
2823
29-
prob = NonlinearProblem(ns, guess, ps)
24+
prob = NonlinearProblem(ns, guesses, ps)
3025
sol = solve(prob, NewtonRaphson())
3126
```
3227

3328
We can similarly ask to generate the `NonlinearProblem` with the analytical
3429
Jacobian function:
3530

3631
```@example nonlinear
37-
prob = NonlinearProblem(ns, guess, ps, jac = true)
32+
prob = NonlinearProblem(ns, guesses, ps, jac = true)
3833
sol = solve(prob, NewtonRaphson())
3934
```

0 commit comments

Comments
 (0)