Skip to content

Commit f31c591

Browse files
Update FAQ.md
1 parent b225826 commit f31c591

File tree

1 file changed

+36
-1
lines changed

1 file changed

+36
-1
lines changed

docs/src/basics/FAQ.md

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,38 @@
11
# Frequently Asked Questions
22

3-
Ask more questions.
3+
## How is the performance of Julia's NonlinearSolve.jl vs MATLAB's fzero?
4+
5+
This is addressed in a [Twitter thread with the author of the improved fzero](https://twitter.com/ChrisRackauckas/status/1544743542094020615).
6+
On the test example:
7+
8+
```julia
9+
using NonlinearSolve, BenchmarkTools
10+
11+
N = 100_000;
12+
levels = 1.5 .* rand(N);
13+
out = zeros(N);
14+
myfun(x, lv) = x * sin(x) - lv
15+
16+
function f(out, levels, u0)
17+
for i in 1:N
18+
out[i] = solve(NonlinearProblem{false}(NonlinearFunction{false}(myfun),
19+
u0, levels[i]), Falsi()).u
20+
end
21+
end
22+
23+
function f2(out, levels, u0)
24+
for i in 1:N
25+
out[i] = solve(NonlinearProblem{false}(NonlinearFunction{false}(myfun),
26+
u0, levels[i]), NewtonRaphson()).u
27+
end
28+
end
29+
30+
@btime f(out, levels, (0.0, 2.0))
31+
@btime f2(out, levels, 1.0)
32+
```
33+
34+
MATLAB 2022a achieves 1.66s. Try this code yourself: we receive 0.06 seconds, or a 28x speedup.
35+
This example is still not optimized in the Julia code and we expect an improvement in a near
36+
future version.
37+
38+
For more information on performance of SciML, see the [SciMLBenchmarks](https://github.com/SciML/SciMLBenchmarks.jl)

0 commit comments

Comments
 (0)