MATLAB: Issue with integration schemes in modeling dynamic system with discrete-time integrators

backwarddiscretediscrete timeeulerforwardintegratorsimulinksolvertrapezoidal

I am trying to model a simple mass-spring oscillator in Simulink and using a fixed-step discrete solver. The system is modeled using two in-series discrete-time integrator blocks. I initialize the downstream integrator with a value to represent an initial displacement delta from neutral. I expect the system to oscillate indefinitely with the natural frequency.
I get the result I expect if I set the integrator method to "Integration:Trapezoidal" in the discrete-time integrator blocks. However, if I set this parameter to "Integration: Backward Euler" the oscillation rapidly dampens out. If I set this parameter to "Integration: Forward Euler" the oscillation rapidly diverges.
Why are the results inconsistent between the three integration schemes and what causes algebraic loop warnings when employing the 'Backward Euler' or 'Trapezoidal' schemes?

Best Answer

The results obtained using the three different integration schemes are as expected. The 'Trapezoidal' scheme is more accurate than either the 'Backward Euler' or the 'Forward Euler' schemes. The 'Forward' scheme (sometimes simply referred to as the 'Euler' scheme) goes unstable because it integrates the point forward, while 'Backward' scheme damps out because it takes the point after. More information can be found on Wikipedia:
The 'Trapezoidal' scheme averages the current point and point after, giving a stable result for this steady oscillation. More information on this scheme may also be found on Wikipedia:
Also note that for other types of signals which are not as symmetric, the 'Trapezoidal' scheme would probably not be as accurate as in this case.
To get more accurate results, the step sizes may be made smaller (as a fraction of the natural time period of the system).
The algebraic loop warnings are also expected since the 'Backward Euler' and 'Trapezoidal' schemes require the current input signal to compute the output.