# Talk:Numerical Analysis/Differentiation/Examples

## Two Variables

By Taylor's theorem for real functions of two variables,

${\displaystyle f(x_{0}+x,y_{0}+y)=f(x_{0},y_{0})+x{\frac {df}{dx}}(x_{0},y_{0})+y{\frac {df}{dy}}(x_{0},y_{0})+{\frac {x^{2}}{2}}{\frac {d^{2}f}{dx^{2}}}(x_{0},y_{0})+{\frac {y^{2}}{2}}{\frac {d^{2}f}{dy^{2}}}(x_{0},y_{0})+xy{\frac {d}{dy}}{\frac {df}{dx}}(x_{0},y_{0})+O(x^{3})+O(y^{3})}$

So

${\displaystyle c_{1}f(x_{0}+h,y_{0})+c_{2}f(x_{0}-h,y_{0})+c_{3}f(x_{0},y_{0}+h)+c_{4}f(x_{0},y_{0}-h)=(c_{1}+c_{2}+c_{3}+c_{4})f(x_{0},y_{0})+h\left((c_{1}+c_{2}){\frac {df}{dx}}(x_{0},y_{0})+(c_{3}+c_{4}){\frac {df}{dy}}(x_{0},y_{0})\right)+{\frac {h^{2}}{2}}\left((c_{1}+c_{2}){\frac {d^{2}f}{dx^{2}}}(x_{0},y_{0})+(c_{3}+c_{4}){\frac {d^{2}f}{dy^{2}}}(x_{0},y_{0})\right)+O(h^{3})}$ Nm160111 (talk) 02:29, 26 November 2012 (UTC)

## Mostly Generalized Method

Too complex for examples, but saves work when making them.

By Taylor's theorem,

${\displaystyle y(x_{0}+a)=y(x_{0})+ay'(x_{0})+a^{2}{\frac {y''(x_{0})}{2}}+a^{3}{\frac {y'''(x_{0})}{6}}+a^{4}{\frac {y^{(4)}(x_{0})}{24}}+a^{5}{\frac {y^{(5)}(x_{0})}{120}}+...+O(a^{k+1})}$

So

${\displaystyle \sum _{i=1}^{n}c_{i}y(x_{0}+b_{i}h)=y(x_{0})\sum _{i=1}^{n}c_{i}+hy'(x_{0})\sum _{i=1}^{n}c_{i}b_{i}+h^{2}{\frac {y''(x_{0})}{2}}\sum _{i=1}^{n}c_{i}b_{i}^{2}+h^{3}{\frac {y'''(x_{0})}{6}}\sum _{i=1}^{n}c_{i}b_{i}^{3}+...+h^{k}{\frac {y^{(5)}(x_{0})}{120}}\sum _{i=1}^{n}c_{i}b_{i}^{k}+O(h^{k+1})}$

Which we can rearrange as

${\displaystyle y'(x_{0})\sum _{i=1}^{n}c_{i}b_{i}={\frac {\sum _{i=1}^{n}c_{i}y(x_{0}+b_{i}h)}{h}}-{\frac {y(x_{0})}{h}}\sum _{i=1}^{n}c_{i}-h{\frac {y''(x_{0})}{2}}\sum _{i=1}^{n}c_{i}b_{i}^{2}-h^{2}{\frac {y'''(x_{0})}{6}}\sum _{i=1}^{n}c_{i}b_{i}^{3}-...-h^{k-1}{\frac {y^{(5)}(x_{0})}{120}}\sum _{i=1}^{n}c_{i}b_{i}^{k}+O(h^{k})}$

Given this, we now attempt to choose coefficients ${\displaystyle b_{i}}$ and ${\displaystyle c_{i}}$ such that

${\displaystyle y'(x_{0})={\frac {\sum _{i=1}^{n}c_{i}y(x_{0}+b_{i}h)}{h}}+O(h^{k})}$

This can be done by solving the following system of ${\displaystyle k+1}$ equations in ${\displaystyle 2n}$ unknowns:

${\displaystyle 1=\sum _{i=1}^{n}c_{i}b_{i}}$

${\displaystyle 0=\sum _{i=1}^{n}c_{i}}$

${\displaystyle 0=\sum _{i=1}^{n}c_{i}b_{i}^{2}}$

${\displaystyle ...}$

${\displaystyle 0=\sum _{i=1}^{n}c_{i}b_{i}^{k}}$

By setting all ${\displaystyle b_{i}}$ to be constant, the system of equations may be made linear. Nm160111 (talk) 02:29, 26 November 2012 (UTC)