# Week 6

### Topics:

• Error analysis of the Euler algorithm: Local error proportional to h^2, global error is proportional to h.
Wikipedia: Euler's Algorithm
Euler's original paper on his algorithm
• Runge-Kutta (4) algorithm: Local error is proportional to h^5, global error is proportional to h^4.
Wikipedia: Runge-Kutta
• Dormand-Prince algorithm: Read the entry in PHASER Help and also see
Wikipedia: Dormand-Prince_method
• How to compute e: comparison of several algorithms.
• What to do in practice: In real life applications, it is impossible to be certain if numerically generated solutions of differential equations are reliable, or how large the errors might be. The golden rule of practice is to compute the same solution using several algorithms with various step sizes. If the variations in these computations are large (more than you can accept for a particular application) your problem is most likely a dangerous one. If the variations in these computations are small enough, most likely you get a reliable answer out of the machine.

### Assignment:

1. Largest safe step size: Consider the differential equation x'= -12x.
• Show, using the Linearization Theorem, that x=0 is an asymptotically stable equilibrium point.
• Now, in the XiVsTime View of Phaser, compute several solutions starting near the equilibrium point using Dormand-Prince 5(4) with the default settings. Assume that this is a correct picture (errors are very small). Your picture should indeed show the asymptotic stability of the origin.
• Next, in the XiVsTime View of Phaser using Euler's algorithm with various step sizes compute the same solutions above. Use a large graph point size and connect points. Determine the largest step size that results in a picture where the origin looks like an asymptotically stable point as you obtain with Dormand-Prince 5(4). Hint: h = 0.3 does not give a correct picture.

2. An explosion problem: Here we consider the "explosion" problem x'= x^2, x(0)=1. This simple equation shows up in chemical reactions where two atoms get together to form a molecule.
• Verify that the solution of this initial-value problem is x(t) = 1/(1-t).
• Using Euler's Algorithm with steps h = 0.01 and h = 0.005, compute x(0.99). What is the error in your computations? Hint: What is the exact value of x(0.99) = ?
• Now in Phaser, compute x(1) with Euler using steps h = 0.01 and h = 0.005. What is the error in your calculations?

3. Two steps of Improved Euler(2): Consider the initial value problem x1' = x, x(0)=1. With step size h = 0.5, compute, by hand using paper and pencil, two steps of Improved Euler (2) algorithm to obtain the approximate value of x(1). You can look up the formula for Improved Euler (2) in Phaser Help; make sure you show all the intermediate numbers Ks. Now compare your answer with the one you get from Phaser.

4. Euler for systems of ODEs: Euler's algorithm can be generalized for systems of ODEs. For example, for the pair of differential equations

dx/dt = f (x, y)
dy/dt = g (x, y)

with initial conditions x(0) = x_0 and y(0) = y_0, Euler's algorithm with step size h becomes

x_(n+1) = x_n + h*f(x_n, y_n)
y_(n+1) = y_n + h*g(x_n, y_n).

Now consider the Epidemics problem from last week. Take a = 0.6, r = 0.003, S_0 = 200, I_0 = 20, and step size h = 0.2. Compute two steps of Euler by hand. Compare your numbers with those from Phaser.

5. Reading Euler: Try to read the original paper of Euler listed above. Is his algorithm the same as the one we derived in class? What does he have to say about errors? This problem is for your own edification; you do not have to turn it in.