Runge-Kutta method: Difference between revisions
→{{header|Excel}}
Pbartholomew (talk | contribs) |
Pbartholomew (talk | contribs) |
||
Line 1,119:
=={{header|Excel}}==
<syntaxhighlight lang="Excel"
//Worksheet formula to manage looping
=LET(
Line 1,132:
)
//Lambda function passed to
Dλ(y,t)
= LAMBDA(y,t, t * SQRT(y))
//Curried Lambda function with derivative function D and y, t as parameters
RungaKutta4λ(Dλ)
= LAMBDA(D,
LAMBDA(yᵣ, tᵣ,
LET(
δy₁, δt * D(yᵣ, tᵣ),
δy₂, δt * D(yᵣ + δy₁ / 2, tᵣ + δt / 2),
δy₃, δt * D(yᵣ + δy₂ / 2, tᵣ + δt / 2),
δy₄, δt * D(yᵣ + δy₃, tᵣ + δt),
yᵣ₊₁, yᵣ + (δy₁ + 2 * δy₂ + 2 * δy₃ + δy₄) / 6,
yᵣ₊₁
)▼
)
▲ )
)
//Lambda function returning the exact solution
f(t)
= LAMBDA(t, (1
</syntaxhighlight>
{{out}}
<pre>
|