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)])
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])
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])