Skip to content

Commit 7bd6df1

Browse files
committed
compare against NLSolve
1 parent d4194e6 commit 7bd6df1

3 files changed

Lines changed: 137 additions & 2 deletions

File tree

docs/src/notebooks/Project.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
[deps]
2+
Ariadne = "0be81120-40bf-4f8b-adf0-26103efb66f1"
23
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
34
Krylov = "ba0b0d4f-ebba-5204-a429-3ac8c609bfb7"
4-
Ariadne = "0be81120-40bf-4f8b-adf0-26103efb66f1"
5+
NonlinearSolve = "8913a72c-1f9b-4ce2-8d82-65094dcecaec"
56
OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"
67
Pluto = "c3e4b0f8-55cb-11ea-2926-15256bba5781"
78
PlutoLinks = "0ff47ea0-7a50-410d-8455-4348d5de0420"

docs/src/notebooks/comparison.jl

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
### A Pluto.jl notebook ###
2+
# v0.20.24
3+
4+
using Markdown
5+
using InteractiveUtils
6+
7+
# ╔═╡ eb792fe6-3cbe-11f1-2eca-0bd287486337
8+
begin
9+
import Pkg
10+
# careful: this is _not_ a reproducible environment
11+
# activate the local environment
12+
Pkg.activate(".")
13+
Pkg.instantiate()
14+
using PlutoUI, PlutoLinks
15+
using CairoMakie
16+
end
17+
18+
# ╔═╡ 869833fd-ee32-4469-ad9f-ef6489f68811
19+
@revise using Ariadne
20+
21+
# ╔═╡ 0aa45e3b-433b-4385-aa8c-e71e8acf725a
22+
import NonlinearSolve as NLS
23+
24+
# ╔═╡ fa13b4ca-a809-43c4-979d-e0864874d8f6
25+
md"""
26+
## Generalized Rosenbrock
27+
28+
This example is taken from Fig. 1 of:
29+
> A. Pal et al., "NonlinearSolve.jl: High-performance and robust solvers for systems
30+
> of nonlinear equations in Julia," arXiv [math.NA], 24-Mar-2024.
31+
> https://arxiv.org/abs/2403.16341
32+
33+
### Problem definition
34+
35+
The generalized Rosenbrock function in $N$ dimensions:
36+
```math
37+
F(x)_1 = 1 - x_1, \quad F(x)_i = 10(x_i - x_{i-1}^2), \quad i = 2, \ldots, N
38+
```
39+
"""
40+
41+
# ╔═╡ edf5d7a1-4f17-484a-aebf-729ea149b580
42+
function generalized_rosenbrock(x, _)
43+
return vcat(
44+
1 - x[1],
45+
10 .* (x[2:end] .- x[1:(end - 1)] .* x[1:(end - 1)])
46+
)
47+
end
48+
49+
# ╔═╡ 078b6618-f037-44b1-9c17-4a1785170bfc
50+
N = 5
51+
52+
# ╔═╡ 80cde332-fbd1-49a0-bd61-944720f885fe
53+
x_start = vcat(-1.2, ones(N - 1))
54+
55+
# ╔═╡ 4bb5bf4b-a37b-4d02-97a6-00bece7dc9f8
56+
md"""
57+
## using Ariadne
58+
"""
59+
60+
# ╔═╡ 772047e4-debd-4871-a659-f91d15c3ea45
61+
let
62+
_, stats = newton_krylov(
63+
generalized_rosenbrock,
64+
copy(x_start);
65+
algo = :gmres,
66+
linesearch! = NoLineSearch(),
67+
max_niter = 100_000
68+
)
69+
stats
70+
end
71+
72+
# ╔═╡ 42a30e51-8cf7-49fa-8348-159803d4a1c3
73+
let
74+
_, stats = newton_krylov(
75+
generalized_rosenbrock,
76+
copy(x_start);
77+
algo = :gmres,
78+
linesearch! = BacktrackingLineSearch(),
79+
max_niter = 100_000
80+
)
81+
stats
82+
end
83+
84+
# ╔═╡ 4ec97f25-7af2-4138-9203-f933d8e593d9
85+
md"""
86+
## using NonlinearSolve
87+
"""
88+
89+
# ╔═╡ eafb63ff-857d-4cc3-84eb-19ad4dd5755a
90+
prob = NLS.NonlinearProblem(generalized_rosenbrock, x_start)
91+
92+
# ╔═╡ 69a3e7b5-bf52-408b-bd33-80e0618b539b
93+
alg = NLS.NewtonRaphson(
94+
linesearch = missing,
95+
forcing = NLS.EisenstatWalkerForcing2(),
96+
linsolve = NLS.KrylovJL()
97+
)
98+
99+
# ╔═╡ aa53ea6f-9d39-43ea-b130-f0c98f187958
100+
alg2 = NLS.NewtonRaphson(
101+
linesearch = NLS.BackTracking(),
102+
forcing = NLS.EisenstatWalkerForcing2(),
103+
linsolve = NLS.KrylovJL()
104+
)
105+
106+
# ╔═╡ 08473c35-a4f6-4115-8db5-03b13f4a2cce
107+
let
108+
sol = NLS.solve(prob, alg, reltol = 1.0e-6, abstol = 1.0e-12, verbose = false)
109+
sol.stats
110+
end
111+
112+
# ╔═╡ 9cea0413-f915-4784-a2c0-9b041c71b649
113+
let
114+
sol = NLS.solve(prob, alg2, reltol = 1.0e-6, abstol = 1.0e-12, verbose = false)
115+
sol.stats
116+
end
117+
118+
# ╔═╡ Cell order:
119+
# ╠═eb792fe6-3cbe-11f1-2eca-0bd287486337
120+
# ╠═869833fd-ee32-4469-ad9f-ef6489f68811
121+
# ╠═0aa45e3b-433b-4385-aa8c-e71e8acf725a
122+
# ╟─fa13b4ca-a809-43c4-979d-e0864874d8f6
123+
# ╠═edf5d7a1-4f17-484a-aebf-729ea149b580
124+
# ╠═078b6618-f037-44b1-9c17-4a1785170bfc
125+
# ╠═80cde332-fbd1-49a0-bd61-944720f885fe
126+
# ╟─4bb5bf4b-a37b-4d02-97a6-00bece7dc9f8
127+
# ╠═772047e4-debd-4871-a659-f91d15c3ea45
128+
# ╠═42a30e51-8cf7-49fa-8348-159803d4a1c3
129+
# ╟─4ec97f25-7af2-4138-9203-f933d8e593d9
130+
# ╠═eafb63ff-857d-4cc3-84eb-19ad4dd5755a
131+
# ╠═69a3e7b5-bf52-408b-bd33-80e0618b539b
132+
# ╠═aa53ea6f-9d39-43ea-b130-f0c98f187958
133+
# ╠═08473c35-a4f6-4115-8db5-03b13f4a2cce
134+
# ╠═9cea0413-f915-4784-a2c0-9b041c71b649

docs/src/notebooks/heat_1D_DG.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
### A Pluto.jl notebook ###
2-
# v0.20.8
2+
# v0.20.24
33

44
using Markdown
55
using InteractiveUtils

0 commit comments

Comments
 (0)