# 2

# Simulations

## 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*) = *t*^{2} + 3*t* + 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:

**Table 2.1** MATLAB code for the numerical ...