Tutorials › Calculus I › Applying Euler’s Method to Second-Order Initial-Value Problems

Euler's Method and Numerical Solutions · Tutorial 1432 of 1495

Applying Euler's Method to Second-Order Initial-Value Problems

Rewrite a second-order equation as coupled equations for position and velocity, and use their current values to calculate each Euler step.

Advanced 9 min read

What You'll Learn

  • Identify the position, velocity, and acceleration in a second-order initial-value problem.
  • Convert a second-order equation into an equivalent first-order system.
  • Derive the Euler updates for position and velocity from the system.
  • Compute successive approximations using the same step size and the same old state.
  • Check Euler calculations and recognize a common update-order mistake.

From Acceleration to Two First-Order Equations

A second-order differential equation describes how a quantity’s acceleration depends on time, position, and velocity. To approximate its solution with Euler’s method, we track position and velocity together. This turns the problem into a system of two first-order equations, to which the Euler update can be applied component by component.

Let \(x(t)\) denote position, so that \(x'(t)\) is velocity and \(x''(t)\) is acceleration. Suppose the equation and initial data are given in the form

$$ x''=f(t,x,x'), \qquad x(t_0)=x_0,\qquad x'(t_0)=v_0. $$

The initial position is \(x_0\), and the initial velocity is \(v_0\). We introduce a new variable \(v=x'\). Then \(x'=v\), while the original equation says \(v'=f(t,x,v)\). Thus position and velocity satisfy a coupled first-order system.

Definition: For the second-order initial-value problem \(x''=f(t,x,x')\), \(x(t_0)=x_0\), and \(x'(t_0)=v_0\), its equivalent first-order system is $$ x'=v,\qquad v'=f(t,x,v),\qquad x(t_0)=x_0,\quad v(t_0)=v_0. $$ Here \(x\) is position and \(v\) is velocity. The second equation gives the acceleration.

This conversion does not change the motion being described. It records the same information in two variables: the rate of change of position is velocity, and the rate of change of velocity is acceleration.

The Euler Updates for Position and Velocity

Let \(h>0\) be the step size and define the grid times \(t_n=t_0+nh\), for nonnegative integers \(n\). Write \(x_n\) and \(v_n\) for the Euler approximations to position and velocity at time \(t_n\). At each step, evaluate both rates using the current approximations \(t_n,x_n,v_n\).

$$ x_{n+1}=x_n+h v_n,\qquad v_{n+1}=v_n+h f(t_n,x_n,v_n). $$

The first formula uses the current velocity as the slope of position. The second uses the current acceleration as the slope of velocity. Both updates use the same current state; neither formula uses a value that has just been updated during that step.

These are precisely the componentwise forward Euler updates for the first-order system. If the acceleration is written as a formula involving position and velocity, substitute the current approximations into that formula before calculating the next velocity.

Why the Conversion and Updates Work

The conversion follows directly from the meaning of velocity and acceleration. Define \(v(t)=x'(t)\). Differentiating this definition gives \(v'(t)=x''(t)\). Substituting the second-order equation yields \(v'(t)=f(t,x(t),v(t))\), while the definition itself gives \(x'(t)=v(t)\). The initial values for the system are \(x(t_0)=x_0\) and \(v(t_0)=x'(t_0)=v_0\).

To see why the Euler updates have the stated form, use the derivative approximation \(u(t+h)\approx u(t)+h u'(t)\) for a differentiable quantity \(u\). Apply it first to position, whose derivative is velocity, and then to velocity, whose derivative is acceleration. At time \(t_n\), replace the exact values by their current approximations:

$$ x(t_n+h)\approx x(t_n)+h\,v(t_n), \qquad v(t_n+h)\approx v(t_n)+h\,f(t_n,x(t_n),v(t_n)). $$

Replacing \(x(t_n)\) and \(v(t_n)\) by \(x_n\) and \(v_n\), and using \(t_{n+1}=t_n+h\), gives the two updates. The approximation is made in each component using the system’s rates at the start of the step. This derivation explains both why the method applies and why the current state must be used in both formulas.

Key takeaway: At a step starting from \((t_n,x_n,v_n)\), use \(v_n\) to update position and \(f(t_n,x_n,v_n)\) to update velocity. The step ends at time \(t_{n+1}=t_n+h\).

Worked Examples

Worked Example: Euler Approximation for Falling Motion

A falling object has acceleration \(x''=-10\) metres per second squared. At time \(t_0=0\), its position is \(x_0=20\) metres and its velocity is \(v_0=0\) metres per second. Use \(h=0.2\) seconds to approximate its position and velocity at \(t=0.6\) seconds.

Here \(f(t,x,v)=-10\). The Euler updates are \(x_{n+1}=x_n+0.2v_n\) and \(v_{n+1}=v_n+0.2(-10)=v_n-2\).

Step 1, from \(t_0=0\) to \(t_1=0.2\):

$$ x_1=20+0.2(0)=20\text{ m},\qquad v_1=0+0.2(-10)=-2\text{ m/s}. $$

Step 2, from \(t_1=0.2\) to \(t_2=0.4\): Use the current values \(x_1=20\) and \(v_1=-2\).

$$ x_2=20+0.2(-2)=19.6\text{ m},\qquad v_2=-2+0.2(-10)=-4\text{ m/s}. $$

Step 3, from \(t_2=0.4\) to \(t_3=0.6\):

$$ x_3=19.6+0.2(-4)=18.8\text{ m},\qquad v_3=-4+0.2(-10)=-6\text{ m/s}. $$

Check: Each velocity change is \(0.2(-10)=-2\) metres per second, as required by the constant acceleration. Each position change is \(0.2\) times the velocity at the start of that step: \(0\), \(-0.4\), and \(-0.8\) metres. The approximation at \(t=0.6\) is \(x_3=18.8\) metres and \(v_3=-6\) metres per second.

Worked Example: Time-Dependent Acceleration with Damping

Consider \(x''=t-x'-2x\), with \(x(0)=1\), \(x'(0)=0\). Use \(h=0.25\) to approximate position and velocity at \(t=0.5\). Set \(v=x'\), so the acceleration function is \(f(t,x,v)=t-v-2x\).

Initially, \(t_0=0\), \(x_0=1\), and \(v_0=0\). The initial acceleration is

$$ f(0,1,0)=0-0-2(1)=-2. $$

Therefore the first Euler step gives

$$ x_1=1+0.25(0)=1,\qquad v_1=0+0.25(-2)=-0.5. $$

Now \(t_1=0.25\). Evaluate the acceleration using the current values, not the initial ones:

$$ f(0.25,1,-0.5) =0.25-(-0.5)-2(1) =0.25+0.5-2 =-1.25. $$

The second step is

$$ x_2=1+0.25(-0.5)=0.875,\qquad v_2=-0.5+0.25(-1.25)=-0.8125. $$

Check: The time grid is \(0,0.25,0.5\), so these are the approximations at the requested time. The position increment in the second step is \(0.25v_1=-0.125\), and the velocity increment is \(0.25(-1.25)=-0.3125\), matching the computed values. Thus \(x(0.5)\approx0.875\) and \(x'(0.5)\approx-0.8125\) by this Euler calculation.

Worked Example: A Spring Starting with Nonzero Velocity

For the model \(x''=-4x\), let \(x(0)=0\), \(x'(0)=2\), and use \(h=0.5\). Find the Euler approximations after two steps. Here \(f(t,x,v)=-4x\), so \(x_{n+1}=x_n+0.5v_n\) and \(v_{n+1}=v_n+0.5(-4x_n)\).

At the first step, \(x_0=0\) and \(v_0=2\), so

$$ x_1=0+0.5(2)=1,\qquad v_1=2+0.5(-4(0))=2. $$

At the second step, use \(x_1=1\) and \(v_1=2\). The acceleration used is \(-4x_1=-4\), giving

$$ x_2=1+0.5(2)=2,\qquad v_2=2+0.5(-4) = 0. $$

Check: The computed times are \(t_1=0.5\) and \(t_2=1\). In the first step, position increases by \(0.5(2)=1\), and velocity changes by \(0.5(0)=0\). In the second, position increases by \(0.5(2)=1\), and velocity changes by \(0.5(-4)=-2\). The two-step approximation at \(t=1\) is \(x_2=2\), \(v_2=0\).

A Common Update-Order Mistake

A tempting but incorrect variation is to update velocity first and then use the new velocity to update position. That does not apply forward Euler to both components at the start of the step. For example, take \(x''=-2x\), \(x_0=1\), \(v_0=0\), and \(h=0.1\). The initial acceleration is \(-2(1)=-2\). Forward Euler gives

$$ x_1=1+0.1(0)=1,\qquad v_1=0+0.1(-2)=-0.2. $$

If the new velocity is incorrectly used to update position, the result would instead be \(x_1=1+0.1(-0.2)=0.98\). This is not the forward Euler position update: it uses the velocity at the end of the step instead of the velocity at the start. The correction is to calculate both new values from the old pair \((x_n,v_n)\), as in the two stated formulas.

Practical Checks Before Moving to the Next Step

For each step, keep the time, position, and velocity together. Evaluate the acceleration from the current time, position, and velocity; then calculate both increments. This is especially important when acceleration depends on time or velocity, since carrying forward an outdated value changes the calculation.

  • Check that the time advances by \(h\) at every step.
  • Check that the position increment is \(h v_n\), not \(h v_{n+1}\).
  • Check that the acceleration is evaluated at \((t_n,x_n,v_n)\).
  • Check units: multiplying velocity by time gives a position change, and multiplying acceleration by time gives a velocity change.

These checks verify that the numerical updates have been applied consistently. Euler values are approximations; the update calculation alone does not claim that they are exact values of the solution.

Check Your Understanding

For each question, identify the variables and apply the update rule using values from the start of each step.

  1. Rewrite \(x''=3t-x+2x'\) as a first-order system by defining \(v=x'\).
  2. For \(x''=-5\), \(x_0=4\), \(v_0=1\), and \(h=0.2\), calculate \(x_1\) and \(v_1\).
  3. For \(x''=t-v\), \(t_0=1\), \(x_0=2\), \(v_0=3\), and \(h=0.1\), find the acceleration used in the first step and calculate \(x_1,v_1\).
  4. Why must the position and velocity updates in a forward Euler step both use values from the same starting time?
  5. In the model \(x''=-4x\), suppose \(x_n=2\), \(v_n=-1\), and \(h=0.25\). Calculate \(x_{n+1}\) and \(v_{n+1}\).

Test yourself: Calculus I final exam practice

Ready to check what you know? Work a full-length practice final, then open the complete worked solutions.

Want all 1,114 practice problems?

This tutorial covers one topic. Calc Pass covers the full Calculus AB & BC curriculum (the core of Calculus I and II): full review, every practice question, and step-by-step solutions to each one.

QR code to download the Calc Pass app

Get the Calc Pass App

Scan to download and practice on the go, with instant scoring.

Calc Pass Volume 1: 1,114 Practice Questions book cover

Vol. 1: 1,114 Questions

The complete practice question bank, organized by AB & BC topic.

View on Amazon
Calc Pass Volume 2: Solutions Manual book cover

Vol. 2: Solutions Manual

Fully worked solutions to every question in Volume 1.

View on Amazon