Lesson 12 (09/21/26) — Numerical Approximation (2.4, 2.5)

Original PDF

Page 1

Lesson 12 (09/21/26) — Numerical Approximation (2.4, 2.5)

Warmup: What is the definition of derivative of \( y(x) \)?

Diagram illustrating the geometric definition of a derivative on a curve y(x). A blue curve represents the function y(x) with two points labeled: (a, y(a)) and (a+h, y(a+h)). A purple line indicates the tangent line at the point (a, y(a)), and a black secant line connects (a, y(a)) and (a+h, y(a+h)).
Visual Description: Diagram illustrating the geometric definition of a derivative on a curve y(x). A blue curve represents the function y(x) with two points labeled: (a, y(a)) and (a+h, y(a+h)). A purple line indicates the tangent line at the point (a, y(a)), and a black secant line connects (a, y(a)) and (a+h, y(a+h)).

\[ y'(a) = \text{slope of tangent line} \]

\[ = \lim_{h \to 0} \frac{y(a+h) - y(a)}{h} \]

Idea: If \( h \) is small enough we can approximate

\[ y'(a) \approx \frac{y(a+h) - y(a)}{h} \]

If you know \( y(a), y'(a) \)

Approximate

\[ y(a+h) \approx y(a) + h y'(a) \]


Page 2

Solving \( \frac{dy}{dx} = f(x,y) \), \( y(x_0) = y_0 \) Numerically.

A 2D Cartesian coordinate graph showing y versus x. The horizontal x-axis shows discrete step points labeled x_0, x_1, x_2, x_3, x_4, ... . A continuous solution curve is plotted in blue across the coordinate space. At the initial condition point labeled (x_0, y_0), a tangent line segment is shown indicating the initial slope dy/dx = f(x_0, y_0), illustrating the numerical approximation steps progressing from x_0 through subsequent grid points.
Visual Description: A 2D Cartesian coordinate graph showing y versus x. The horizontal x-axis shows discrete step points labeled x_0, x_1, x_2, x_3, x_4, ... . A continuous solution curve is plotted in blue across the coordinate space. At the initial condition point labeled (x_0, y_0), a tangent line segment is shown indicating the initial slope dy/dx = f(x_0, y_0), illustrating the numerical approximation steps progressing from x_0 through subsequent grid points.

choose \( h \) small “enough”

\[ x_1 = x_0 + h \]

\[ x_2 = x_1 + h = x_0 + 2h \]

\[ x_3 = x_2 + h = x_0 + 3h \]

\[ \vdots \]

use \( x_1, (x_0, y_0) \), \( f(x_0, y_0) = \frac{dy}{dx} \) to find \( y_1 \)

+

Repeat untill your desried \( x_n \)


Page 3

Euler method: \( \frac{dy}{dx} = f(x, y) \), \( y(x_0) = y_0 \)

Recall: \[ \frac{dy}{dx} = \lim_{h \to 0} \frac{y(x+h) - y(x)}{h} \]

\( h \) is "small"

\[ \left. \frac{dy}{dx} \right|_{(x_0, y_0)} = \frac{y(x_0+h) - y(x_0)}{h} \]

\[ y(x_0+h) = y(x_1) = y_1, \quad y(x_0) = y_0 \]

using ODE \[ \left. \frac{dy}{dx} \right|_{(x_0, y_0)} = f(x_0, y_0) \]

\[ f(x_0, y_0) = \frac{y_1 - y_0}{h} \]

\[ y_1 = y_0 + h f(x_0, y_0) \qquad \text{Euler Formula} \]

Repeat the process:

\[ f(x_1, y_1) = \left. \frac{dy}{dx} \right|_{(x_1, y_1)} \approx \frac{y(x_1+h) - y(x_1)}{h} \]

\[ f(x_1, y_1) = \frac{y_2 - y_1}{h} \leadsto y_2 = y_1 + h f(x_1, y_1) \]


Page 4

\[ \frac{dy}{dx} = f(x, y), \quad y(x_0) = y_0 \]

A hand-drawn graph on a grid illustrating a numerical method (such as Euler's method) for approximating a solution to a differential equation. A Cartesian coordinate system shows an x-axis with labeled points x_0, x_1, x_2, and x_3, and a y-axis with corresponding labeled points y_0, y_1, y_2, and y_3, connected via blue dashed projection lines. A red curve traverses from left to right, representing the 'Approx solution.' Along the curve, red dots mark successive approximation steps connected by tangent slope lines: at (x_0, y_0), a dark green segment is labeled 'slope = f(x_0, y_0)'; at (x_1, y_1), a purple segment is labeled 'slope f(x_1, y_1)'; and at (x_2, y_2), another green segment extends to (x_3, y_3) labeled 'slope f(x_2, y_2)'. The curve continues further to the right through additional points in an undulating shape.
Visual Description: A hand-drawn graph on a grid illustrating a numerical method (such as Euler's method) for approximating a solution to a differential equation. A Cartesian coordinate system shows an x-axis with labeled points x_0, x_1, x_2, and x_3, and a y-axis with corresponding labeled points y_0, y_1, y_2, and y_3, connected via blue dashed projection lines. A red curve traverses from left to right, representing the 'Approx solution.' Along the curve, red dots mark successive approximation steps connected by tangent slope lines: at (x_0, y_0), a dark green segment is labeled 'slope = f(x_0, y_0)'; at (x_1, y_1), a purple segment is labeled 'slope f(x_1, y_1)'; and at (x_2, y_2), another green segment extends to (x_3, y_3) labeled 'slope f(x_2, y_2)'. The curve continues further to the right through additional points in an undulating shape.

Choose \(h = \text{step size}\) to be small enough

\[ x_n = x_0 + nh \]

\[ y_1 = y_0 + h \, f(x_0, y_0) \]

\[ y_2 = y_1 + h \, f(x_1, y_1) \]

\[ y_3 = y_2 + h \, f(x_2, y_2) \]

Recursively find \(y_n\)

\[ y_n = y_{n-1} + h \, f(x_{n-1}, y_{n-1}) \]


Page 5

\[ \frac{dy}{dx} = -y, \quad y(0) = 1 \]

Actual Solution:

\[ \frac{1}{y} \, dy = -1 \, dx \] \[ \ln y = -x + k \] \[ y(x) = e^{-x+k} \] \[ 1 = y(0) = e^{0+k} = e^k = 1 \] \[ y(x) = e^{-x} \]

Euler's Method:

\[ (x_0, y_0) = (0, 1) \]

Euler: \( h = 0.5, \quad f(x, y) = -y \)

\[ \begin{aligned} y_1 &= y_0 + h f(x_0, y_0) \\ &= 1 + (0.5)[-1] \\ &= 0.5 \end{aligned} \]

\[ \begin{aligned} y_2 &= y_1 + h f(x_1, y_1) \\ &= y_1 - h y_1 \\ &= (0.5) - 0.5(0.5) \\ &= 0.25 \end{aligned} \]

Smaller the value of \( h \) the better the Approximation


Page 6

Improved Euler

Two side-by-side coordinate plots illustrating numerical approximations of ordinary differential equations on a grid background. 

Left Plot (Euler's Method):
- Axes: Horizontal axis with points x_0 and x_1; vertical axis with points y_0 and y_1.
- Curves and Lines: A smooth blue curve labeled 'Actual' represents the exact solution. At (x_0, y_0), a green dashed tangent line follows the initial slope f(x_0, y_0) forward to x_1, reaching an estimated value y_1.
- Error: A red bracket indicates the vertical difference between the estimated value y_1 on the tangent line and the actual curve at x_1, labeled 'error'.

Right Plot (Predictor-Corrector / Modified Euler's Method):
- Axes: Horizontal axis with points x_0 and x_1; vertical axis marked with y_0, the corrected estimate y_1, and a predicted value y_1^*.
- Curves and Lines: The same blue 'Actual' solution curve is shown. A green dashed line projects from (x_0, y_0) with initial slope f(x_0, y_0) to predict (x_1, y_1^*). A purple segment represents the evaluated slope at the predicted point, labeled f(x_1, y_1^*). A solid black line connects (x_0, y_0) to (x_1, y_1) using the averaged slope.
- Error: A smaller red bracket highlights the reduced vertical 'error' between the corrected estimate y_1 and the actual curve at x_1.
Visual Description: Two side-by-side coordinate plots illustrating numerical approximations of ordinary differential equations on a grid background. Left Plot (Euler's Method): - Axes: Horizontal axis with points x_0 and x_1; vertical axis with points y_0 and y_1. - Curves and Lines: A smooth blue curve labeled 'Actual' represents the exact solution. At (x_0, y_0), a green dashed tangent line follows the initial slope f(x_0, y_0) forward to x_1, reaching an estimated value y_1. - Error: A red bracket indicates the vertical difference between the estimated value y_1 on the tangent line and the actual curve at x_1, labeled 'error'. Right Plot (Predictor-Corrector / Modified Euler's Method): - Axes: Horizontal axis with points x_0 and x_1; vertical axis marked with y_0, the corrected estimate y_1, and a predicted value y_1^*. - Curves and Lines: The same blue 'Actual' solution curve is shown. A green dashed line projects from (x_0, y_0) with initial slope f(x_0, y_0) to predict (x_1, y_1^*). A purple segment represents the evaluated slope at the predicted point, labeled f(x_1, y_1^*). A solid black line connects (x_0, y_0) to (x_1, y_1) using the averaged slope. - Error: A smaller red bracket highlights the reduced vertical 'error' between the corrected estimate y_1 and the actual curve at x_1.

Improved Euler

take Average slope \( f(x_0, y_0), f(x_1, y_1^*) \)


Page 7

Improved Euler:

\[ \frac{dy}{dx} = f(x, y), \quad y(x_0) = y_0 \]

Euler: used \(1\text{ slope} = f(x_0, y_0)\) to Approximate \(y_1\)

Improved Euler:

\[ k_1 = f(x_0, y_0) \text{ as } 1^{\text{st}}\text{ slope estimate} \]

\[ y_1^* = y_0 + h k_1 \quad (\text{intermediate}) \]

\[ k_2 = f(x_1, y_1^*) \text{ as } 2^{\text{nd}}\text{ slope estimate} \]

use Average slope \(= \frac{1}{2}(k_1 + k_2)\) to Approximate \(y_1\)

\[ y_1 = y_0 + h \frac{1}{2}(k_1 + k_2) \]

Repeat Recursively