Solving ODEs Numerically

The Euler Method

The Euler method for solving ODEs numerically consists of using the Taylor series to express the derivatives to first order and then generating a stepping rule. Let's consider an example.

Example: Newton's Cooling Law

A simple differential equation that we can use to demonstrate the Euler method is Newton's cooling law. Newton said that if an object of a temperature T was immersed in a bath* of temperature T0 that the rate at which its temperature changes is proportional to the difference of the temperatures between the object and the bath. Writing this in mathematics yields the equation:

.

You can, of course, solve this equation for the function T(t) analytically. But let's demonstrate how the Euler method works on this simple equation.

If we use the Taylor series to expand T(t + Δt) about t, we get:

.

Keeping only the first order term and putting the result into the original equation gives

.

In the last line above, we have solved for T(t + Δt) in terms of the value of T at an earlier time and the parameters of the system. This means we can "step." That is, if we know the values of the parameters (λ and T0) and the value of T at the starting time, we can use the above equation to find T at a time Δt later; we can then use that value to find T at a time Δt later, etc., etc., on into the future.

Euler's Method for Newton's Second Law

For Newton's second law, we start with a second order equation.

.

This says that "ma" is equal to the net force which, typically, can be a function of the position and velocity. (Though we have expressed this in one-dimension for one mass for simplicity, the process is easily generalized to many dimensions and many particles.) To apply the Euler method, we have to have first order equations, so we introduce the velocity, v, as a second variable. This separates Newton's second order second law into two first order equations.

.

We now have two first order equations in two unknowns (x and v) and we can apply the Euler approach to generate a stepping rule.

.

If we know the position and velocity at a time t, we can use them to calculate the force at that time and use that to calculate the position and velocity at a later time, t + Δt, stepping our knowledge to predict the future motion of the object.

* A "bath" means that the substance in which the object is immersed is very large compared to the object we are considering so that we can consider whatever heat energy is exchanged between the object and the bath is insignificant as far as the bath is concerned. We can assume that the bath stays at a constant temperature.

RETURNS

University of MarylandPhysics DepartmentPhysics 374 Home


This page prepared by

Edward F. Redish
Department of Physics
University of Maryland
College Park, MD 20742
Phone: (301) 405-6120
Email: redish@umd.edu

Last revision 24. September, 2005.