Skip to content

Commit 07444d8

Browse files
Merge pull request #247 from SciML/rebuild/1b3e1917
Rebuild content
2 parents faf3e0b + 3e203e1 commit 07444d8

16 files changed

+1609
-940
lines changed

html/ode_extras/01-ModelingToolkit.html

+290-309
Large diffs are not rendered by default.

html/ode_extras/02-feagin.html

+101-159
Large diffs are not rendered by default.

html/ode_extras/03-ode_minmax.html

+257-174
Large diffs are not rendered by default.

markdown/ode_extras/01-ModelingToolkit.md

+275-284
Large diffs are not rendered by default.

markdown/ode_extras/02-feagin.md

+202
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
---
2+
author: "Chris Rackauckas"
3+
title: "Feagin's Order 10, 12, and 14 Methods"
4+
---
5+
6+
7+
DifferentialEquations.jl includes Feagin's explicit Runge-Kutta methods of orders 10/8, 12/10, and 14/12. These methods have such high order that it's pretty much required that one uses numbers with more precision than Float64. As a prerequisite reference on how to use arbitrary number systems (including higher precision) in the numerical solvers, please see the Solving Equations in With Chosen Number Types notebook.
8+
9+
## Investigation of the Method's Error
10+
11+
We can use Feagin's order 16 method as follows. Let's use a two-dimensional linear ODE. Like in the Solving Equations in With Chosen Number Types notebook, we change the initial condition to BigFloats to tell the solver to use BigFloat types.
12+
13+
````julia
14+
using DifferentialEquations
15+
````
16+
17+
18+
````
19+
Error: ArgumentError: Package DifferentialEquations not found in current pa
20+
th:
21+
- Run `import Pkg; Pkg.add("DifferentialEquations")` to install the Differe
22+
ntialEquations package.
23+
````
24+
25+
26+
27+
````julia
28+
const linear_bigα = big(1.01)
29+
f(u,p,t) = (linear_bigα*u)
30+
31+
# Add analytical solution so that errors are checked
32+
f_analytic(u0,p,t) = u0*exp(linear_bigα*t)
33+
ff = ODEFunction(f,analytic=f_analytic)
34+
````
35+
36+
37+
````
38+
Error: UndefVarError: ODEFunction not defined
39+
````
40+
41+
42+
43+
````julia
44+
prob = ODEProblem(ff,big(0.5),(0.0,1.0))
45+
````
46+
47+
48+
````
49+
Error: UndefVarError: ODEProblem not defined
50+
````
51+
52+
53+
54+
````julia
55+
sol = solve(prob,Feagin14(),dt=1//16,adaptive=false);
56+
````
57+
58+
59+
````
60+
Error: UndefVarError: Feagin14 not defined
61+
````
62+
63+
64+
65+
````julia
66+
println(sol.errors)
67+
````
68+
69+
70+
````
71+
Error: UndefVarError: sol not defined
72+
````
73+
74+
75+
76+
77+
78+
Compare that to machine $\epsilon$ for Float64:
79+
80+
````julia
81+
eps(Float64)
82+
````
83+
84+
85+
````
86+
2.220446049250313e-16
87+
````
88+
89+
90+
91+
92+
93+
The error for Feagin's method when the stepsize is 1/16 is 8 orders of magnitude below machine $\epsilon$! However, that is dependent on the stepsize. If we instead use adaptive timestepping with the default tolerances, we get
94+
95+
````julia
96+
sol =solve(prob,Feagin14());
97+
````
98+
99+
100+
````
101+
Error: UndefVarError: Feagin14 not defined
102+
````
103+
104+
105+
106+
````julia
107+
println(sol.errors); print("The length was $(length(sol))")
108+
````
109+
110+
111+
````
112+
Error: UndefVarError: sol not defined
113+
````
114+
115+
116+
117+
118+
119+
Notice that when the stepsize is much higher, the error goes up quickly as well. These super high order methods are best when used to gain really accurate approximations (using still modest timesteps). Some examples of where such precision is necessary is astrodynamics where the many-body problem is highly chaotic and thus sensitive to small errors.
120+
121+
## Convergence Test
122+
123+
The Order 14 method is awesome, but we need to make sure it's really that awesome. The following convergence test is used in the package tests in order to make sure the implementation is correct. Note that all methods have such tests in place.
124+
125+
````julia
126+
using DiffEqDevTools
127+
dts = 1.0 ./ 2.0 .^(10:-1:4)
128+
sim = test_convergence(dts,prob,Feagin14())
129+
````
130+
131+
132+
````
133+
Error: UndefVarError: Feagin14 not defined
134+
````
135+
136+
137+
138+
139+
140+
For a view of what's going on, let's plot the simulation results.
141+
142+
````julia
143+
using Plots
144+
gr()
145+
plot(sim)
146+
````
147+
148+
149+
````
150+
Error: UndefVarError: sim not defined
151+
````
152+
153+
154+
155+
156+
157+
This is a clear trend indicating that the convergence is truly Order 14, which
158+
is the estimated slope.
159+
160+
161+
## Appendix
162+
163+
This tutorial is part of the DiffEqTutorials.jl repository, found at: <https://github.com/JuliaDiffEq/DiffEqTutorials.jl>
164+
165+
To locally run this tutorial, do the following commands:
166+
```
167+
using DiffEqTutorials
168+
DiffEqTutorials.weave_file("ode_extras","02-feagin.jmd")
169+
```
170+
171+
Computer Information:
172+
```
173+
Julia Version 1.4.2
174+
Commit 44fa15b150* (2020-05-23 18:35 UTC)
175+
Platform Info:
176+
OS: Linux (x86_64-pc-linux-gnu)
177+
CPU: Intel(R) Core(TM) i7-9700K CPU @ 3.60GHz
178+
WORD_SIZE: 64
179+
LIBM: libopenlibm
180+
LLVM: libLLVM-8.0.1 (ORCJIT, skylake)
181+
Environment:
182+
JULIA_DEPOT_PATH = /builds/JuliaGPU/DiffEqTutorials.jl/.julia
183+
JULIA_CUDA_MEMORY_LIMIT = 536870912
184+
JULIA_PROJECT = @.
185+
JULIA_NUM_THREADS = 4
186+
187+
```
188+
189+
Package Information:
190+
191+
```
192+
Status `/builds/JuliaGPU/DiffEqTutorials.jl/tutorials/ode_extras/Project.toml`
193+
[f3b72e0c-5b89-59e1-b016-84e28bfd966d] DiffEqDevTools 2.22.0
194+
[961ee093-0014-501f-94e3-6117800e7a78] ModelingToolkit 3.11.0
195+
[76087f3c-5699-56af-9a33-bf431cd00edd] NLopt 0.6.0
196+
[2774e3e8-f4cf-5e23-947b-6d7e65073b56] NLsolve 4.4.0
197+
[429524aa-4258-5aef-a3af-852621145aeb] Optim 0.22.0
198+
[1dea7af3-3e70-54e6-95c3-0bf5283fa5ed] OrdinaryDiffEq 5.41.0
199+
[91a5bcdd-55d7-5caf-9e0b-520d859cae80] Plots 1.5.1
200+
[37e2e46d-f89d-539d-b4ee-838fcccc9c8e] LinearAlgebra
201+
[2f01184e-e22b-5df5-ae63-d93ebab69eaf] SparseArrays
202+
```

0 commit comments

Comments
 (0)