In numerical analysis and scientific computing, the trapezoidal rule is a numerical method to solve ordinary differential equations derived from the trapezoidal rule for computing integrals. The trapezoidal rule is an implicit second-order method, which can be considered as both a Runge–Kutta method and a linear multistep method.
Method Suppose that we want to solve the differential equation
y ′ = f ( t , y ) . {\displaystyle y'=f(t,y).}
The trapezoidal rule is given by the formula
y n + 1 = y n + 1 2 h ( f ( t n , y n ) + f ( t n + 1 , y n + 1 ) ) , {\displaystyle y_{n+1}=y_{n}+{\tfrac {1}{2}}h{\Big (}f(t_{n},y_{n})+f(t_{n+1},y_{n+1}){\Big )},}
where h = t n + 1 − t n {\displaystyle h=t_{n+1}-t_{n}} is the step size. This is an implicit method: the value y n + 1 {\displaystyle y_{n+1}} appears on both sides of the equation, and to actually calculate it, we have to solve an equation which will usually be nonlinear. One possible method for solving this equation is Newton's method. We can use the Euler method to get a fairly good estimate for the solution, which can be used as the initial guess of Newton's method. Cutting short, using only the guess from Eulers method is equivalent to performing Heun's method.
Motivation Integrating the differential equation from t n {\displaystyle t_{n}} to t n + 1 {\displaystyle t_{n+1}} , we find that
y ( t n + 1 ) − y ( t n ) = ∫ t n t n + 1 f ( t , y ( t ) ) d t . {\displaystyle y(t_{n+1})-y(t_{n})=\int _{t_{n}}^{t_{n+1}}f(t,y(t))\,\mathrm {d} t.}
The trapezoidal rule states that the integral on the right-hand side can be approximated as
∫ t n t n + 1 f ( t , y ( t ) ) d t ≈ 1 2 h ( f ( t n , y ( t n ) ) + f ( t n + 1 , y ( t n + 1 ) ) ) . {\displaystyle \int _{t_{n}}^{t_{n+1}}f(t,y(t))\,\mathrm {d} t\approx {\tfrac {1}{2}}h{\Big (}f(t_{n},y(t_{n}))+f(t_{n+1},y(t_{n+1})){\Big )}.}
Now combine both formulas and use that y n ≈ y ( t n ) {\displaystyle y_{n}\approx y(t_{n})} and y n + 1 ≈ y ( t n + 1 ) {\displaystyle y_{n+1}\approx y(t_{n+1})} to get the trapezoidal rule for solving ordinary differential equations.
Error analysis It follows from the error analysis of the trapezoidal rule for quadrature that the local truncation error τ n {\displaystyle \tau _{n}} of the trapezoidal rule for solving differential equations can be bounded as:
… excerpt ends here. Continue reading the full article.

