Type a command or search the notes. Tab cycles completions. Up and down recall history when blank. Escape dismisses, then leaves the prompt.
MATH
[1251]

Examples from Numerical solutions

All examples from Numerical solutions.

Back to Numerical solutions

A family of translated curves

For

y′=x2,y'=x^2,

every point with the same xx-coordinate has the same slope. Integrating gives

y=x33+C.y=\frac{x^3}{3}+C.

The curves through y(0)=1y(0)=1 and y(0)=3y(0)=3 are vertical translates of one another. The direction field displays this common slope pattern even though the initial condition chooses only one curve.

[routine]

  1. [1]:Direction field

A visibly large step

For

y′=x2,y(0)=1,h=1,y'=x^2,\qquad y(0)=1,\qquad h=1,

the first point is (x0,y0)=(0,1)(x_0,y_0)=(0,1). Since f(0,1)=0f(0,1)=0, the next point is (1,1)(1,1). The following slopes are f(1,1)=1f(1,1)=1 and f(2,2)=4f(2,2)=4, giving

(0,1)⟶(1,1)⟶(2,2)⟶(3,6).(0,1)\longrightarrow(1,1)\longrightarrow(2,2)\longrightarrow(3,6).

The exact solution is y=1+x3/3y=1+x^3/3, whose value at x=3x=3 is 1010. The step size is too large to track the curvature accurately.

[routine]

  1. [1]:Euler's method

A smaller step

For

y′=x+y,y(0)=1,h=0.1,y'=x+y,\qquad y(0)=1,\qquad h=0.1,

Euler's update gives

y1=1+0.1(0+1)=1.1,y2=1.1+0.1(0.1+1.1)=1.22,y3=1.22+0.1(0.2+1.22)=1.362.\begin{aligned} y_1&=1+0.1(0+1)=1.1,\\ y_2&=1.1+0.1(0.1+1.1)=1.22,\\ y_3&=1.22+0.1(0.2+1.22)=1.362. \end{aligned}

The exact solution is

y=2ex−1−x,y=2e^x-1-x,

whose value at x=0.3x=0.3 is approximately 1.39971.3997. The Euler value 1.3621.362 is below it by about 0.03770.0377.

[routine]

  1. [1]:Euler's method

Comparing Euler and Heun

Consider

y′=11+x2−2y2,y(0)=0,y'=\frac{1}{1+x^2}-2y^2,\qquad y(0)=0,

whose exact solution is

y(x)=x1+x2.y(x)=\frac{x}{1+x^2}.

With h=0.2h=0.2, f(0,0)=1f(0,0)=1. Euler predicts u1=0.2u_1=0.2; the predicted endpoint slope is f(0.2,0.2)=1/1.04−2(0.2)2≈0.88154f(0.2,0.2)=1/1.04-2(0.2)^2\approx0.88154. Heun therefore gives y1≈0.2(1+0.88154)/2=0.18815y_1\approx0.2(1+0.88154)/2=0.18815, closer to the exact value y(0.2)=0.2/1.04≈0.19231y(0.2)=0.2/1.04\approx0.19231 than Euler's 0.20.2. Repeating the updates on [0,1][0,1] gives these maximum grid-point errors:

hEulerHeun0.20.05450.01050.10.02590.0023\begin{array}{c|cc} h & \text{Euler} & \text{Heun}\\ \hline 0.2 & 0.0545 & 0.0105\\ 0.1 & 0.0259 & 0.0023 \end{array}

Reducing hh lowers the error for both methods and Heun keeps the smaller error.

[exam]

  1. [1]:Heun's method

On this page