Euler's method

This method does not have the utmost generality, and is not capable of high precision, however it is natural and easy to understand and to program. Its principle lies in approximation of the derivative by the difference quotient. To find approximate values of the initial-value problem

x' = f (t, x) , x(a) = C

over the interval [a, b], the following approximation is used:

x(t + h) = x(t) + h x'(t).

Hence, the formula

x(t + h) = x(t) + h f (t, x(t))

can be used to step from t = a to t = b with n steps of size h = (b - a)/n.

The Java code for Euler's method may be written an follows:

for ( k = 1; k <= n; k++ ) {

x = x + h * f(t, x);

t = a + k*h;

}

This link will take you to an applet demonstrating Euler's method.

 

Hosted by www.Geocities.ws

1