The method described above is often sufficient to approximate first order differential equations, but it may not be obvious how to apply it to the approximation of differential equations of higher order. The trick here is to break down the higher order differential equation into several first order differential equations. This technique is also called state variable analysis.
Consider the differential equation:
We will assume initial conditions are all zero.
Note: this differential equation represents the rectifier circuit from section 7-3 of Circuits Devices and Systems, by Smith (your E11 text). The circuit parameter are R=400W, C=25mF, L=4H, w=377 rad/sec(60 Hz), and Vm=1. Taking the absolute value of the sine wave is equivalent to rectification, and y(t) is equal to the output voltage.
This problem would be extremely hard to solve analytically, but poses no particular problem for Euler's method. The first thing we must do is to recast the problem in terms of first order equations. We will introduce two new variables, x1(t) and x2(t). Let x1(t)=y(t). We can then write two coupled first order equations.
These equations can also be expressed as a first order matrix equation.
We can now use Euler's method to solve both first order equations simultaneously by following the following procedure (which is a simple modification of the procedure for first order equations).
1) Starting at time to, choose a value for h, and find initial conditions for all state variables x1(to), x2(to), ...
2) From the values of xi(to) calculate derivatives for each xi(t) at t=to. Call these k1i.
3) From this value find an approximate value for each xi*(to+h).
4) Let to=to+h, and for each xi, let xi(to)=xi*(to+h).
5) Repeat steps 2 through 4 until the solution is finished.
Numerical Example (2nd order differential equation - Euler)
Here is a link to the Matlab code for this problem, a link to the C Code. Shown below are the results. Clearly the solution is quite a complex function.
To next page
Comments or Questions?