Thursday, July 26, 2018

Section 9–6 Numerical solution of the equations

(Euler’s method / Leapfrog method / Accuracy of numerical methods)

In this section, the three interesting points are Euler’s method, Leapfrog method, and the accuracy of numerical methods in calculating positions and velocities of an object.

1. Euler’s method:
… we would find the motion only rather crudely because ϵ = 0.100 sec is rather crude, and we would have to go to a very small interval, say ϵ = 0.01 (Feynman et al., 1963, section 9–6 Numerical solution of the equations).”

Feynman chooses a time interval of 0.100 sec (step size, ϵ) and sets the initial position of an object as x(0) = 1.00. To calculate x(0.1), he adds the position x(0) by the velocity (which is zero) times 0.100 sec. The equations are x(t+ϵ) = x(t) + ϵvx(t) and vx(t+ϵ) = vx(t) + ϵax(t) = vx(t) − ϵx(t). This numerical method may be rewritten as yn+1 = yn + h ´ y’(yn, tn) and it is also known as Euler’s forward method (Zwillinger, 2014). In other words, this is an explicit method because yn+1 is explicitly known in terms of yn and y’(yn, tn). Although it is easy to implement the method, it has a problem of numerical stability depending on the step size chosen. Alternatively, Euler’s backward method is based on yn+1 = yn + h ´ y’(yn+1, tn+1) in which y’(yn+1, tn+1) is not known; this implicit method needs more computations, but it is relatively more stable.

Euler’s method uses the tangent line to the function at the beginning of the interval as an estimate of the slope of the function over the interval. This method can be derived by Taylor’s theorem, but it is sometimes criticized because it is not usually accurate for use in common applications (Burden & Faires, 2011). Essentially, the errors of this numerical method are dependent on the step size or time interval in the example provided. Thus, Feynman suggests using a very small interval, say ϵ = 0.010 sec, if the motion calculated is rather inaccurate. However, even when very small step sizes are used, errors are being accumulated over a large number of steps and the estimated value will likely diverge from the actual value.

2. Leapfrog method:
Similarly, the velocity at this halfway point is the velocity at a time ϵ before (which is in the middle of the previous interval) plus ϵ times the acceleration at the time t (Feynman et al., 1963, section 9–6 Numerical solution of the equations).”

Feynman explains that we should use the acceleration halfway between two “times” (tϵ/2, t+ϵ/2) to deduce the velocity at a later time (t+ϵ/2). Similarly, the position later x(t+ϵ) is equal to the position before x(t) plus ϵ times the velocity at the time in the middle of the interval (t+ϵ/2). Mathematically, we can express the equations as x(t+ϵ) = x(t) + ϵv(t+ϵ/2) and v(t+ϵ/2) = v(tϵ/2) + ϵa(t). Simply phrased, this is a mid-point method that uses the speed between the “now” speed and the “then” speed at the end of an interval. The midpoint method is better because it approximates an integral by using the integrand at the midpoint (instead of “initial” position or “final” position). By using the midpoint between two successive points, there is a slight improvement in the accuracy of the numerical analysis.

The midpoint method is sometimes known as Leapfrog method. Leapfrog method is a second order method that is more accurate than Euler’s method, which is only first order. The order of accuracy of a numerical method indicates how errors decrease in the limit as the step size tends to zero. A method with an order of accuracy n and is known as a n-th order accurate method if there exists a C > 0 such that the error is less than Chn in which h is the step size. Another important feature of Leapfrog method is that it preserves the amplitude of the simple harmonic motion within computation errors (round-off and truncation). This method is useful because it is relatively simple and has better numerical stability than Euler’s method.

3. Accuracy of numerical methods:
The agreement is within the three significant figure accuracy of our calculation (Feynman et al., 1963, section 9–6 Numerical solution of the equations).”

By using a numerical method, it shows that an object starts from rest, first picks up a little upward (negative) velocity and it loses some of its distance. Notably, the agreement of this simulation with the exact mathematical solution of the equation of motion, x = cos t, is within the three significant figure accuracy. This is an impressive illustration of the power of Leapfrog numerical method because it involves simple calculations and gives relatively accurate results. We can simply use a spreadsheet (e.g., Google Sheets or Microsoft Excel) to simulate the motion of the object. A graph of simple harmonic motion of an object can be plotted almost instantly.

Currently, physics teachers may teach Runge–Kutta methods, which are a family of implicit and explicit iterative methods. In 1895, Carl Runge published a numerical method that is more elaborate than Euler’s method and is capable of greater accuracy. Runge’s idea was to develop approximate solutions based on improved formulas by using the midpoint and trapezoidal rules. In 1901, Martin Wilhelm Kutta published a paper that contains the famous Runge-Kutta methodology for solving ordinary differential equations. In general, Runge-Kutta method of order four requires four evaluations per step, whereas Euler’s method requires one evaluation.

Questions for discussion:
1. What are the advantages and disadvantages of Euler’s method?
2. What are the advantages and disadvantages of Leapfrog method?
3. How would you compare the accuracy of Euler’s method and Leapfrog method in simulating simple harmonic motion of an object?

The moral of the lesson: we can use Leapfrog (midpoint) method to illustrate the power of numerical analysis that simple calculations can give accurate results.

References:
1. Burden, R. L. & Faires, J. D. (2011). Numerical Analysis, 9th ed. Boston: Brooks/Cole.
2. Feynman, R. P., Leighton, R. B., & Sands, M. (1963). The Feynman Lectures on Physics, Vol I: Mainly mechanics, radiation, and heat. Reading, MA: Addison-Wesley.
3. Zwillinger, D. (2014). Handbook of Differential Equations. Orlando: Academic Press.

No comments:

Post a Comment