# Math Insight

### Multivariable Taylor polynomial example

Calculate the second-degree Taylor polynomial of \begin{align*} f(x,y) = e^{-(x^2+y^2)} \end{align*} at the point $(0,0)$ and at the point $(1,2)$

Solution: The second-degree Taylor polynomial at the point $(a,b)$ is \begin{align*} p_2(x,y) &= f(a,b) + D f(a,b) \left[ \begin{array}{c} x-a \\ y-b \end{array} \right] \\ &\quad + \frac{1}{2} \left[ \begin{array}{cc} x-a &y-b \end{array} \right] Hf(a,b) \left[ \begin{array}{c} x-a \\ y-b \end{array} \right] \end{align*}

First compute all the derivatives: \begin{align*} \pdiff{f}{x}(x,y) &= -2x e^{-(x^2+y^2)}\\ \pdiff{f}{y}(x,y) &= -2y e^{-(x^2+y^2)}\\ \pdiffn{f}{x}{2}(x,y) &= (-2+4x^2) e^{-(x^2+y^2)}\\ \pdiffn{f}{y}{2}(x,y) &= (-2+4y^2) e^{-(x^2+y^2)}\\ \frac{\partial^2 f}{\partial x \partial y}(x,y) = \frac{\partial^2 f}{\partial y \partial x}(x,y) &= 4xye^{-(x^2+y^2)} \end{align*}

At the point $(a,b)=(0,0)$ \begin{align*} f(0,0)&=e^0 =1\\ \pdiff{f}{x}(0,0)=\pdiff{f}{y}(0,0)&=0\\ \pdiffn{f}{x}{2}(0,0) &= -2\\ \pdiffn{f}{y}{2}(0,0) &= -2\\ \frac{\partial^2 f}{\partial x \partial y}(0,0)&= 0 \end{align*}

The second-degree Taylor polynomial at the point (0,0) is \begin{align*} p_2(x,y) &= f(0,0) + D f(0,0) \left[ \begin{array}{c} x-0 \\ y-0 \end{array} \right] \\ &\qquad + \frac{1}{2} \left[ \begin{array}{cc} x-0 &y-0 \end{array} \right] Hf(0,0) \left[ \begin{array}{c} x-0 \\ y-0 \end{array} \right] \\ &= 1 + \left[ \begin{array}{cc} 0 &0 \end{array} \right] \left[ \begin{array}{c} x\\ y \end{array} \right] + \frac{1}{2} \left[ \begin{array}{cc} x &y \end{array} \right] \left[ \begin{array}{rr} -2 & 0\\ 0 & -2 \end{array} \right] \left[ \begin{array}{c} x\\ y \end{array} \right] \\& = 1- x^2 -y^2 \end{align*}

At the point $(a,b)=(1,2)$, things get uglier. But it is good practice. \begin{align*} f(1,2)&=e^{-5} \\ \pdiff{f}{x}(1,2) &= -2 e^{-5}\\ \pdiff{f}{y}(1,2) &= -4 e^{-5},\\ \pdiffn{f}{x}{2}(1,2) &= 2 e^{-5}\\ \pdiffn{f}{y}{2}(1,2) &= 14 e^{-5}\\ \frac{\partial^2 f}{\partial x \partial y}(1,2) = \frac{\partial^2 f}{\partial y \partial x}(1,2) &= 8e^{-5} \end{align*}

The second-degree Taylor polynomial at the point (1,2) is \begin{align*} p_2(x,y) &= f(1,2) + D f(1,2) \left[ \begin{array}{c} x-1 \\ y-2 \end{array} \right] \\ &\quad + \frac{1}{2} \left[ \begin{array}{cc} x-1 &y-2 \end{array} \right] Hf(1,2) \left[ \begin{array}{c} x-1 \\ y-2 \end{array} \right] \\ & = e^{-5} + \left[ \begin{array}{cc} -2e^{-5} & -4 e^{-5} \end{array} \right] \left[ \begin{array}{c} x-1\\ y-2 \end{array} \right] \\ &\quad + \frac{1}{2} \left[ \begin{array}{cc} x-1 &y-2 \end{array} \right] \left[ \begin{array}{rr} 2 e^{-5} & 8 e^{-5}\\ 8 e^{-5} & 14 e^{-5} \end{array} \right] \left[ \begin{array}{c} x-1\\ y-2 \end{array} \right] \\& = e^{-5} -e^{-5}(2(x-1)+4(y-2)) + e^{-5} (x-1)^2 \\ &\quad + e^{-5} 8 (x-1)(y-2) + e^{-5} 7 (y-2)^2\\ & = e^{-5} ( 1 - 2(x-1)-4(y-2) + (x-1)^2 + 8 (x-1)(y-2) + 7 (y-2)^2) \end{align*}