1
- # Fetch pakages.
2
- using NonlinearSolve, DiffEqDevTools, Plots
3
- using Test
1
+ # Fetch packages.
2
+ using DiffEqDevTools, NonlinearSolve, Plots, Test
4
3
5
- # Prepares NonlinearProblem.
6
- f (u, p) = 3 u .^ 3 .+ 2 u .^ 2 .+ u + .- p
7
- u0 = [1.0 , 6.0 ]
8
- p = [1.0 , 3.0 ]
9
- static_prob = NonlinearProblem (f, u0, p)
10
- real_sol = solve (static_prob, NewtonRaphson (), reltol = 1e-15 , abstol = 1e-15 )
4
+ let
5
+ # Prepares NonlinearProblem.
6
+ f (u, p) = 3 u .^ 3 .+ 2 u .^ 2 .+ u + .- p
7
+ u0 = [1.0 , 6.0 ]
8
+ p = [1.0 , 3.0 ]
9
+ static_prob = NonlinearProblem (f, u0, p)
10
+ real_sol = solve (static_prob, NewtonRaphson (), reltol = 1e-15 , abstol = 1e-15 )
11
11
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" ]
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" ]
18
18
19
- # Makes WP-diagram
20
- 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 )
21
21
22
- # Checks that all errors are small (they definitely should be).
23
- @test all (vcat (getfield .(wp. wps, :errors )... ) .< 10e-9 )
24
- @test length (plot (wp). series_list) == 2
22
+ # Checks that all errors are small (they definitely should be).
23
+ @test all (vcat (getfield .(wp. wps, :errors )... ) .< 10e-9 )
24
+ @test length (plot (wp). series_list) == 2
25
25
26
- # Check without appxsol.
27
- wp = WorkPrecisionSet (static_prob, abstols, reltols, setups; names= solnames, numruns= 100 , error_estimate= :l2 )
28
- @test all (vcat (getfield .(wp. wps, :errors )... ) .< 10e-9 )
29
- @test length (plot (wp). series_list) == 2
26
+ # Check without appxsol.
27
+ wp = WorkPrecisionSet (static_prob, abstols, reltols, setups; names= solnames, numruns= 100 , error_estimate= :l2 )
28
+ @test all (vcat (getfield .(wp. wps, :errors )... ) .< 10e-9 )
29
+ @test length (plot (wp). series_list) == 2
30
+ end
0 commit comments