@@ -32,7 +32,7 @@ A nonlinear system $$f(u) = 0$$ is specified by defining a function `f(u,p)`,
32
32
where ` p ` are the parameters of the system. For example, the following solves
33
33
the vector equation $$ f(u) = u^2 - p $$ for a vector of equations:
34
34
35
- ``` @example
35
+ ``` @example 1
36
36
using NonlinearSolve
37
37
38
38
f(u, p) = u .* u .- p
@@ -52,24 +52,24 @@ AbstractArray for automatic differentiation.
52
52
To investigate the solution, one can look at the elements of the ` NonlinearSolution ` .
53
53
The most important value is ` sol.u ` : this is the ` u ` that satisfies ` f(u) = 0 ` . For example:
54
54
55
- ``` @example
55
+ ``` @example 1
56
56
u = sol.u
57
57
```
58
58
59
- ``` @example
59
+ ``` @example 1
60
60
f(u, p)
61
61
```
62
62
63
63
This final value, the difference of the solution against zero, can also be found with ` sol.resid ` :
64
64
65
- ``` @example
65
+ ``` @example 1
66
66
sol.resid
67
67
```
68
68
69
69
To know if the solution converged, or why the solution had not converged we can check the return
70
70
code (` retcode ` ):
71
71
72
- ``` @example
72
+ ``` @example 1
73
73
sol.retcode
74
74
```
75
75
@@ -84,7 +84,7 @@ SciMLBase.successful_retcode(sol)
84
84
If we're curious about what it took to solve this equation, then you're in luck because all of the
85
85
details can be found in ` sol.stats ` :
86
86
87
- ``` @example
87
+ ``` @example 1
88
88
sol.stats
89
89
```
90
90
@@ -96,15 +96,15 @@ While `sol = solve(prob)` worked for our case here, in many situations you may n
96
96
deeply with how the solving process is done. First things first, you can specify the solver using the
97
97
positional arguments. For example, let's set the solver to ` TrustRegion() ` :
98
98
99
- ``` @example
99
+ ``` @example 1
100
100
solve(prob, TrustRegion())
101
101
```
102
102
103
103
For a complete list of solver choices, see [ the nonlinear system solvers page] (@ref nonlinearsystemsolvers).
104
104
105
105
Next we can modify the tolerances. Here let's set some really low tolerances to force a tight solution:
106
106
107
- ``` @example
107
+ ``` @example 1
108
108
solve(prob, TrustRegion(), reltol=1e-12, abstol=1e-12)
109
109
```
110
110
@@ -118,7 +118,7 @@ For scalar rootfinding problems, bracketing methods exist in NonlinearSolve. The
118
118
methods is that with bracketing methods, instead of giving a ` u0 ` initial condition, you pass a ` uspan (a,b) `
119
119
bracket in which the zero is expected to live. For example:
120
120
121
- ``` @example
121
+ ``` @example 1
122
122
using NonlinearSolve
123
123
f(u, p) = u * u - 2.0
124
124
uspan = (1.0, 2.0) # brackets
@@ -130,7 +130,7 @@ All of the same option handling from before works just as before, now just with
130
130
(see the [ bracketing solvers] (@ref bracketing) page for more details). For example, let's set the solver
131
131
to ` ITP() ` and set a high absolute tolerance:
132
132
133
- ``` @example
133
+ ``` @example 1
134
134
sol = solve(prob_int, ITP(), abstol = 0.01)
135
135
```
136
136
0 commit comments