2
2
using NonlinearSolve, DiffEqDevTools, Plots
3
3
4
4
# Prepares NonlinearProblem.
5
- f (u, p) = u .* u .- p
6
- u0 = [1.0 , 1.0 ]
7
- p = 2.0
8
- static_prob = NonlinearProblem (f, u0, p)
9
- real_sol = solve (static_prob, NewtonRaphson (), reltol = 1e-15 , abstol = 1e-15 )
5
+ let
6
+ f (u, p) = u .* u .- p
7
+ u0 = [1.0 , 1.0 ]
8
+ p = 2.0
9
+ static_prob = NonlinearProblem (f, u0, p)
10
+ real_sol = solve (static_prob, NewtonRaphson (), reltol = 1e-15 , abstol = 1e-15 )
10
11
11
- # Sets WP input.
12
- abstols = 1.0 ./ 10.0 .^ (8 : 12 )
13
- reltols = 1.0 ./ 10.0 .^ (8 : 12 )
14
- setups = [Dict (:alg => NewtonRaphson ())
15
- Dict (:alg => TrustRegion ())]
16
- solnames = [" NewtonRaphson" ;" TrustRegion" ]
12
+ # Sets WP input.
13
+ abstols = 1.0 ./ 10.0 .^ (8 : 12 )
14
+ reltols = 1.0 ./ 10.0 .^ (8 : 12 )
15
+ setups = [Dict (:alg => NewtonRaphson ())
16
+ Dict (:alg => TrustRegion ())]
17
+ solnames = [" NewtonRaphson" ;" TrustRegion" ]
17
18
18
- # Makes WP-diagram
19
- wp = WorkPrecisionSet (static_prob, abstols, reltols, setups; names= solnames, numruns= 100 , appxsol= real_sol, error_estimate= :l2 )
19
+ # Makes WP-diagram
20
+ wp = WorkPrecisionSet (static_prob, abstols, reltols, setups; names= solnames, numruns= 100 , appxsol= real_sol, error_estimate= :l2 )
20
21
21
- # Checks that all errors are small (they definitely should be).
22
- all (vcat (getfield .(wp. wps, :errors )... ) .< 10e-9 )
22
+ # Checks that all errors are small (they definitely should be).
23
+ all (vcat (getfield .(wp. wps, :errors )... ) .< 10e-9 )
24
+ end
0 commit comments