# Local truncation error calculation

The other day, I tried to answer someone's question, you can read the question and the answer here:

Numerical Solutions of ordinary differential equations

The problem is, I got stuck towards the end of the calculation. Now my question is: does anyone know how to get order 2?

-

You haven't used $b_2 c_2 = \frac{1}{2}$. Taking from where you left off, $e = b_2 h (f(x_n, y_n) - f(x_n + c_2 h, y_n + c_2 h k_1)) + \frac{h^2}{2}*f^\prime(x_n, y_n) +\ldots$ and using the Taylor expansion of $f$ around $(x_n, y_n)$:

$f(x, y) = f(x_0, y_0) + \frac{\partial}{\partial x}f(x_0, y_0)\frac{(x-x_0)}{1!} + \frac{\partial}{\partial y}f(x_0, y_0)\frac{(y-y_0)}{1!} + ...$

we get $f(x_n + c_2 h, y_n + c_2 h k_1) = f(x_n, y_n) + \frac{\partial}{\partial x}f(x_n, y_n)\frac{(c_2 h)}{1!} + \frac{\partial}{\partial y}f(x_n, y_n)\frac{(c_2 h k_1)}{1!} + O(h^2)$

Now make the substitution to eliminate $c_2$ from the RHS and move a term across:

$f(x_n + c_2 h, y_n + c_2 h k_1) - f(x_n, y_n) = \frac{\partial}{\partial x}f(x_n, y_n)\frac{h}{2 b_2} + \frac{\partial}{\partial y}f(x_n, y_n)\frac{h k_1}{2 b_2} + O(h^2)$

and we have

$e = \frac{h^2}{2} (-\frac{\partial}{\partial x}f(x_n, y_n) - \frac{\partial}{\partial y}f(x_n, y_n)k_1) + \frac{h^2}{2}*f^\prime(x_n, y_n) + O(h^3)$

NB I think that $f^\prime$ is $\frac{\partial}{\partial x}f$, so that could be tidied up a bit.

-
Thank you! You're right about the partial derivative, I corrected it. – Rudy the Reindeer Jan 20 '11 at 20:39