2.1 Simulating Processes Composed of Differential Equations
In this section, the numerical derivative will be briefly introduced, followed by a simple method to solve first-order and high-order differential equations.
2.1.1 Numerical Derivative and Solving First-Order Differential Equations
Consider the following derivative definition:
It should be noted that the derivative can be approximated by choosing a small Δt instead of Δt → 0 as shown below.
where Δt is a small value. Equation (2.2) is called a numerical derivative.
The MATLAB program in Table 2.1 is used to calculate the numerical derivative of y(t) = t2 + 3t + 1 at t = 1 and compares it with the analytical value. As expected, the numerical derivative value (5.000 009 999 989) is very close to the analytical derivative value (5.000 000 000 000).
If the Δt value is decreased further, then the accuracy of the numerical derivative will be improved. But, there is a practical limitation in improving the accuracy because the round-off error increases as Δt decreases.
The same principle can be applied to solve differential equations. Consider the following differential equation: