Qu

ode23

Builtin index · Signal processing

ode23(f, tspan, y0, [rtol=1e-6], [atol=1e-9], [max_step=], [t_eval=], [events=], [direction=0], [terminal=false], [max_steps=500000])

Input: f, tspan, y0, rtol, atol, max_step, t_eval, events, direction, terminal, max_steps · Output: no output

What it is

Bogacki-Shampine 3(2), the cheaper low-order pair: better than ode45 at loose tolerances or when f is not smooth. Same arguments, result record and events as ode45; t_eval values come from a cubic Hermite interpolant.

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
ode23(f, tspan, y0, [rtol=1e-6], [atol=1e-9], [max_step=], [t_eval=], [events=], [direction=0], [terminal=false], [max_steps=500000])
f —Bogacki-Shampine 3(2), the cheaper low-order pair: better than ode45 at loose tolerances or when f is not smooth.
tspan —not documented yet
y0 —not documented yet
rtol optional (default 1e-6)not documented yet
atol optional (default 1e-9)not documented yet
max_step optionalnot documented yet
t_eval optionalt_eval values come from a cubic Hermite interpolant.
events optionalSame arguments, result record and events as ode45.
direction optional (default 0)not documented yet
terminal optional (default false)not documented yet
max_steps optional (default 500000)not documented yet
not documented yet—

Examples

From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.

function sho(t, y)
    return [y[1], -y[0]]
end function

te = linspace(0, 5, 51)
r = ode45("sho", [0, 5], [1, 0], t_eval=te, rtol=1e-10, atol=1e-12)
trace_save("reference.npz", {t = r.t, y = r.y[:, 0]})

ref = trace_load("reference.npz")
c = ode23("sho", [0, 5], [1, 0], t_eval=te)          # the run under test

d = trace_diff(ref, {t = c.t, y = c.y[:, 0]}, rtol=1e-6, atol=1e-6)
print(d.ok)                # false

print(d.worst_signal)      # y

print(d.max_abs)           # 2.652263e-6, at sample d.worst_index (32)

output
false
y
2.652263e-6

from signal-processing

How it works

and general minimization. Only a user-defined function (by name, the same convention pmap/spawn use) can be the target of any of these — not a builtin. fzero(f, a, b, [tol=1e-10], [max_iter=100]) — Brent's method: robust root finding (guaranteed convergence given a bracket [a,b] where f changes sign), no derivative needed. The "something better than plain bisection" choice.

From the note above this builtin in the interpreter, where the reasoning was written down as it was built.