October 6, 2005 --- Class 10 --- Error Analysis, Higher Order Algorithms Activities: Error Analysis of the Euler Algorithm We can use awk to compare our numerical integration of the equations of motion with the exact answer. Here is an awk script check.a that returns the error for the case when omega=3 BEGIN{omega=3.0} {t=$1; y=$2; yexact=cos(omega*t); print t, (y-yexact) } The script may be found in ~sg/chap5/check.a. I like to use suffix .a to indicate when a file contains awk commands. Note that when you put awk commands in a file, you don't need all those confusing quotes to keep the shell from interpreting various characters like "{" and "}". An alternative is to omit the BEGIN line and define omega in the awk command. To define omega call awk this way: awk -f check2.a omega=3. filename In the same directory, you will find a shell script plot2.csh for putting two axis graphs on the same page. The -s in the second command keeps axis from trying to clear the page at the beginning of the second plot. The parentheses concatenate the output of the two axis commands so they are joined together in the pipe to the plot filter. Higher order algorithms We talked about several algorithms including leap frog Adams-Bashforth and Runge-Kutta. Euler-Richardson is basically the 2nd order Runge-Kutta algorithm. We also talked about the 4th order Runge-Kutta algorithm. Many of these algorithms are presented in Appendix 5A of Chapter 5. On page 128. There are two typos in the book regarding the 4th order R-K algorithm. In Eq. (5.59a), the right-hand- side should be multiplied by Delta t. In Eq. (5.59b), k_3x on the RHS should be k_3v You may also find more about these algorithms in "Numerical Analysis" by Burden and Faires, or "Numerical Recipes" by Press et al. If you missed class and did not get the handout, please come to my office to get one.