The thread has died down, so I hope it is not a problem if I take it over for my own tangent.
I don't know if you guys were surprised, but I was very surprised to get such a low number for "accuracy" in the my R-L simulation posted just above, especially considering I was using such a big step size (my first reaction was: D*mn!.... that Runge-Kutta is amazing). Now I have studied it a little more and it turns out there is more to the story....
In general (from textbooks), there are 2 types of errors that can occur at a given step:
1 – Roundoff error – independent of step-size. It is assumed to vary randomly from step to step (not correlated with previous steps). Since it varies randomly, by the Central Limit theorem, we can predict that the standard deviation of the cumulative roundoff error after N steps is sqrt(N)*sigma where sigma is standard deviation of roundoff error for one step and N is number of steps (N assumed large for C.L.T.)
2 – "Local Truncation Error". This is not "truncation" as in roundoff, but "truncation" as in truncating the infinite Taylor series associated with the exact differential equation/solution down to a finite Taylor series associated with our approximate algorithm/solution. The magnitude of this particular error increases with step size. In contrast to roundoff error, the variation in LTE between steps might not be random (in this case there is a definite non-random pattern as we will discuss.
Now let's analyze how these two errors might appear in our R-L simulation example:
1 - First roundoff error. Excel uses double precision, where the relative error (of one step) will be on the order of 1E-15 to 1E-14. Since the variable varies between 0 and 2, averaging about 1 that is also our absolute error. For the previous example 25 seconds sampled every 0.002 seconds, it was 12,500 steps and (by Central Limit Theorem) we expect the standard deviation of the accumulated roundoff errors at the end to be 1E-15 to 1E-14 * (sqrt(12,500)) = 1E-13 to 1E-12. So the observed value of 7E-13 that we saw at t=25.000 seconds was very reasonable considering accumulated roundoff error alone.
2 - Next let's discuss Local Truncation Error. It could probably be analyzed mathematically, but I took a different approach... attached I have modified my spreadsheet to add a plot labeled "Error" based on numerical comparison of the simulation output to the true known solution I(t) =1-cos(2*pi*50*t). On the "Error" plot graph you see a sinusoid which varies from 0 to –0.0001. The error plot is periodic at 50hz and it roughly reaches 0 whenever time t is an exact multiple of 1/50hz = 0.020 sec. Also I made the step size an irrational number sqrt(3)/1000 to make sure relationship between step size and exciting frequency is not causing any irregularity (it is not). However if you vary the step size (cell D7, labeled "dt"), you will see that the magnitude of the error plot goes up when you increase dt and goes down when you decrease dt.... which is an expected characteristic of Local Truncation Error.
The above facts lead us to the following conclusions about this particular R-L simulation:
A – The global truncation error (sum of accumulated local truncation errors) is many many order of magnitudes higher than the roundoff error for this simulation.
B – The global truncation error in this particular simulation is periodic at frequency 50hz, which implies the local truncation error is periodic at 60hz. In retrospect, it is not surprising that the error associated with truncating a sin wave at a finite number of terms is itself periodic.
C – The periodicity of the truncation errors prevents them from accumulating to very high values during a very long simulations (global truncation error varies between 0 and some max number, but doesn't tend to increase without bound over time). However we should not expect that to be the case for general excitations other than sinusoidal. I am envisioning I could create a problem using a sawtooth voltage wave where the rising edge is given by (t-tstart)^5 and the falling edge drops sharply, and we add a constant to make the average value of the voltage waveform zero... I think the local truncation errors will be all the same sign and the global truncation error will continually grow with time during a long simulation. (If you see another post appear in this thread, it is probably me trying that idea out).
D – The previous post examined the error at a time t=25.000 sec, exactly divisible by 0.020 when the global truncation error happened to be zero, so results (1E-12 corresponding to accumulated roundoff) were a "little" misleading ;-). If we examined the error of the same simulation at a different "phase angle", we might have seen up to 1E-4 error (periodic, not increasing over time). And as described in C there may be other non-sinusoidal exciting waveforms which whose global truncation error increase continuously over time to much higher values.
=====================================
(2B)+(2B)' ?