Euler method

Uses
- Derivatives of real functions of one variable
- Function combinators

The Euler method, named after Leonhard Euler who first described it in the 18th century, is a simple method for finding a numerical approximation to the solution of a first-order ordinary differential equation.

The most general form of a differential equation to which the Euler method can be applied is
𝒟(f) = g ⚬ fork(f, id),
where the function
f : ℝ → ℝ
is the unknown to be solved for, and
g : (ℝ, ℝ) → ℝ
is an arbitrary function of two real arguments.

The Euler method computes a discrete function f≅ : (ℕ → ℝ) whose value n:ℕ, f≅[n] is an approximation to n:ℕ, f[n × h], where the step size h : ℝ.p is an input parameter to the algorithm. The Euler method starts from a given initial value f≅[0], which corresponds to the freely choosable integration constant, and constructs subsequent values as:
n:ℕ.nz, f≅[n] ⇒ f≅[n - 1] + (h × g[f≅[n - 1], h × (n - 1)])

Example: a linear function

Uses
- example1 Algorithmic construction of one-dimensional arrays
- example1 Plotting

With example1 t:ℝ, ft:ℝ, g[ft, t] ⇒ 1, example1 f≅[0] ⇒ 0, example1 h ⇒ 1/10, and
example1 n : Array1D(ℕ)
example1 n ⇒ IndexArray(10),
we find:
example1 linePlot(n, f≅[n])

Example: an exponential function

Uses
- example2 Algorithmic construction of one-dimensional arrays
- example2 Plotting

With example2 t:ℝ, ft:ℝ, g[ft, t] ⇒ ft, example2 f≅[0] ⇒ 1, example2 h ⇒ 1/10, and
example2 n : Array1D(ℕ)
example2 n ⇒ IndexArray(20),
we find:
example2 linePlot(n, f≅[n])