Differential
Equations
Euler
developed a method for finding the approximate solution to initial value
problems. The differential equations to be solved have the form of:
dy/dx = f ( x, y ) x range is
[a, b], initial value y(a) is known.
The
approximation of dy/dx
is
, therefore the next data point, yi+1 can be calculated by present data point, xi and yi. The x range of [a, b] can be divided equally into N steps, the length of the step,
; there are N+1
data points; the x data points
are
. The y data points
are
with y1=y(a).
For
example: to solve the differential
equation, dy/dx = xy, in the x
range of [0, 1], with x increment, dx = 0.1 and
initial value, y(0)=1,
we can first get x data points, then use the Euler method to get y values.
DO
i = 1, N+1 !
x data points
x(i) = a + (i-1)*dx
END
DO
y(1) = 1 !
initial y value
DO
i = 1, N !
y data points
y(i+1) = y(i) + dx*x(i)*y(i) ! f(x,y)=xy
END
DO
Exercise
The
exact solution of the differential equation in the example is
. Find the error of the Euler’s method for N=10,100 and 1000 at x = 1.