The document introduces the Euler method for numerically approximating solutions to initial value problems (IVPs). It defines IVPs and shows an example. The Euler method uses the derivative approximation y(x+h) ≈ y(x) + hf(x,y) to march forward in small steps h to construct a table of approximate y-values. For the example IVP, the Euler method produces values that begin to resemble the exact solution. While not exact, the errors are small. The method is derived from the definition of the derivative and works because it approximates the tangent line at each step.
Human Factors of XR: Using Human Factors to Design XR Systems
Introduction to Numerical Methods for Differential Equations Using the Euler Method
1. Introduction to Numerical Methods for Differential
Equations
The Euler Method
Matthew Henderson
matthew.james.henderson@gmail.com
21 December, 2011
2. Overview
1 Initial Value Problems
2 Approximate Solutions of Initial Value Problems
3 The Euler Method
Matthew Henderson () Numerical Methods 21 December, 2011 2 / 15
3. An Initial Value Problem
Definition
An initial value problem (IVP) consists of an ordinary differential
equation along with an initial condition.
Matthew Henderson () Numerical Methods 21 December, 2011 3 / 15
4. An Initial Value Problem
Definition
An initial value problem (IVP) consists of an ordinary differential
equation along with an initial condition.
Example
y = 2(x + 3) − y, y(−1) = 3 (1)
Matthew Henderson () Numerical Methods 21 December, 2011 3 / 15
5. An Initial Value Problem
Definition
An initial value problem (IVP) consists of an ordinary differential
equation along with an initial condition.
Example
y = 2(x + 3) − y, y(−1) = 3 (1)
Definition
A solution is a function y(x) which satisfies both the ODE and the
initial condition.
Matthew Henderson () Numerical Methods 21 December, 2011 3 / 15
6. The Solution
The IVP (1) has a unique solution:
y = 2(x + 2) + e−x−1 (2)
Function y satisfies the ODE:
y = 2 − e−x−1
2(x + 3) − y = 2(x + 3) − 2(x + 2) + e−x−1
= 2x + 6 − 2x − 4 − e−x−1
= 2 − e−x−1
Matthew Henderson () Numerical Methods 21 December, 2011 4 / 15
7. The Solution
The IVP (1) has a unique solution:
y = 2(x + 2) + e−x−1 (2)
Function y also satisfies the initial condition:
y(−1) = 2(−1 + 2) + e−(−1)−1
= 2(1) + e1−1
= 2 + e0
= 3
Matthew Henderson () Numerical Methods 21 December, 2011 4 / 15
8. A Plot of the Solution
y
10
y =2(x +2) + e−x−1
8
6
4
2
x
-3 -2 -1 1 2 3
Matthew Henderson () Numerical Methods 21 December, 2011 5 / 15
9. A Plot of the Solution?
y
10
8
6
4
2
x
-3 -2 -1 1 2 3
Matthew Henderson () Numerical Methods 21 December, 2011 6 / 15
10. The Euler Method
Definition
Given an IVP of the form:
y = f(x, y), y(a) = c
Matthew Henderson () Numerical Methods 21 December, 2011 7 / 15
11. The Euler Method
Definition
Given an IVP of the form:
y = f(x, y), y(a) = c
To find the approximate value of y(x + h) for some small value of h:
y(x + h) = y(x) + hf(x, y) (3)
Matthew Henderson () Numerical Methods 21 December, 2011 7 / 15
12. The Euler Method
Example
Going back to our example from before:
y = 2(x + 3) − y, y(−1) = 3
Matthew Henderson () Numerical Methods 21 December, 2011 8 / 15
13. The Euler Method
Example
Going back to our example from before:
y = 2(x + 3) − y, y(−1) = 3
In this case f(x, y) = 2(x + 3) − y.
Matthew Henderson () Numerical Methods 21 December, 2011 8 / 15
14. The Euler Method
Example
Going back to our example from before:
y = 2(x + 3) − y, y(−1) = 3
In this case f(x, y) = 2(x + 3) − y.
Put h = 0.4, x = −1.0 and y = 3.0 into (3):
Matthew Henderson () Numerical Methods 21 December, 2011 8 / 15
15. The Euler Method
Example
Going back to our example from before:
y = 2(x + 3) − y, y(−1) = 3
In this case f(x, y) = 2(x + 3) − y.
Put h = 0.4, x = −1.0 and y = 3.0 into (3):
y(−1.0 + 0.4) = y(−1.0) + 0.4f(−1.0, 3.0)
Matthew Henderson () Numerical Methods 21 December, 2011 8 / 15
16. The Euler Method
Example
Going back to our example from before:
y = 2(x + 3) − y, y(−1) = 3
In this case f(x, y) = 2(x + 3) − y.
Put h = 0.4, x = −1.0 and y = 3.0 into (3):
y(−1.0 + 0.4) = y(−1.0) + 0.4f(−1.0, 3.0)
y(−0.6) = 3.0 + 0.4(2(−1.0 + 3.0) − 3.0)
Matthew Henderson () Numerical Methods 21 December, 2011 8 / 15
17. The Euler Method
Example
Going back to our example from before:
y = 2(x + 3) − y, y(−1) = 3
In this case f(x, y) = 2(x + 3) − y.
Put h = 0.4, x = −1.0 and y = 3.0 into (3):
y(−1.0 + 0.4) = y(−1.0) + 0.4f(−1.0, 3.0)
y(−0.6) = 3.0 + 0.4(2(−1.0 + 3.0) − 3.0)
= 3.0 + 0.4(4 − 3.0)
Matthew Henderson () Numerical Methods 21 December, 2011 8 / 15
18. The Euler Method
Example
Going back to our example from before:
y = 2(x + 3) − y, y(−1) = 3
In this case f(x, y) = 2(x + 3) − y.
Put h = 0.4, x = −1.0 and y = 3.0 into (3):
y(−1.0 + 0.4) = y(−1.0) + 0.4f(−1.0, 3.0)
y(−0.6) = 3.0 + 0.4(2(−1.0 + 3.0) − 3.0)
= 3.0 + 0.4(4 − 3.0)
= 3.4
Matthew Henderson () Numerical Methods 21 December, 2011 8 / 15
19. The Euler Method
We can compute more values in the same way . . .
x = −0.6 and y = 3.4:
y(−0.6 + 0.4) = 3.4 + 0.4(2(−0.6 + 3) − 3.4)
y(−0.2) = 3.4 + 0.4(4.8 − 3.4)
= 3.96
Matthew Henderson () Numerical Methods 21 December, 2011 9 / 15
20. The Euler Method
We can compute more values in the same way . . .
x = −0.6 and y = 3.4:
y(−0.6 + 0.4) = 3.4 + 0.4(2(−0.6 + 3) − 3.4)
y(−0.2) = 3.4 + 0.4(4.8 − 3.4)
= 3.96
x = −0.2 and y = 3.96:
y(−0.2 + 0.4) = 3.96 + 0.4(2(−0.2 + 3) − 3.96)
y(0.2) = bluey + 0.4(5.6 − 3.96)
= 4.616
Matthew Henderson () Numerical Methods 21 December, 2011 9 / 15
21. The Euler Method
We continue to construct a table row-by-row:
x y hf(x, y)
-1.0 3.000000 0.400000
-0.6 0.560000
-0.2 3.960000 0.656000
0.2 4.616000 0.713600
0.6 5.329600 0.748160
1.0 6.077760 0.768896
1.4 6.846656 0.781338
1.8 7.627994 0.788803
2.2 8.416796 0.793281
2.6 9.210078 0.795969
3.0 10.00605 0.797581
Matthew Henderson () Numerical Methods 21 December, 2011 10 / 15
22. The Euler Method
We continue to construct a table row-by-row:
x y hf(x, y)
-1.0 3.000000 0.400000
-0.6 3.400000 0.560000
-0.2 3.960000 0.656000
0.2 4.616000 0.713600
0.6 5.329600 0.748160
1.0 6.077760 0.768896
1.4 6.846656 0.781338
1.8 7.627994 0.788803
2.2 8.416796 0.793281
2.6 9.210078 0.795969
3.0 10.00605 0.797581
Matthew Henderson () Numerical Methods 21 December, 2011 10 / 15
23. The Euler Method: Comparison
Now when we plot those values we get something that begins to look
like our exact solution, albeit only on the interval [−1, 3].
y
10
y =2(x +2) + e−x−1
8
6
4
2
x
-3 -2 -1 1 2 3
Matthew Henderson () Numerical Methods 21 December, 2011 11 / 15
24. The Euler Method: Comparison
The numbers which we computed for y are not exactly correct but the
errors involved are quite small:
x y (approx) y (exact) Error
-1.0 3.000000 3.000000 0.000000
-0.6 3.400000 3.470320 0.070320
-0.2 3.960000 4.049329 0.089329
0.2 4.616000 4.701194 0.085194
0.6 5.329600 5.401896 0.072296
1.0 6.077760 6.135335 0.057575
1.4 6.846656 6.890718 0.044062
1.8 7.627994 7.660810 0.032816
2.2 8.416796 8.440762 0.023966
2.6 9.210078 9.227324 0.017246
3.0 10.00605 10.018316 0.012269
Matthew Henderson () Numerical Methods 21 December, 2011 12 / 15
25. The Euler Method: Where does it come from?
Given an initial value problem of the form:
y = f(x, y), y(a) = c
we want to find the approximate value of y(b) for some b > a. From
the definition of derivative:
y(x + h) − y(x)
y (x) ≈
h
for h > 0 given and small. So,
y(x + h) − y(x)
f(x, y) ≈
h
which gives
y(x + h) ≈ y(x) + hf(x, y)
Matthew Henderson () Numerical Methods 21 December, 2011 13 / 15
26. The Euler Method: Why does it work?
y =2(x +2) + e−x−1 10
8
6
4
2
-3 -2 -1 1 2 3
Matthew Henderson () Numerical Methods 21 December, 2011 14 / 15