Second order taylor series expansion of $\cos(x+2y)e^{2x}$ around $(2, -1)$

analysisapproximationmultivariable-calculusreal-analysistaylor expansion

I'm asked to find the second order taylor series expansion of $\cos(x+2y)e^{2x}$ around $(2, -1)$. It's from an old exam of a professor who doesn't give solutions to them, so I don't know if my results are correct. So I woud like that you tell me if my results are correct, and if not, where I made a mistake. Thank you.


As first partial derivatives, I get $$f_x=-\sin(x+2y)e^{2x}+2\cos(x+2y)e^{2x}$$ $$f_y=-2\sin(x+2y)e^{2x}$$ As second partial derivatives, I get
$$\begin{align}
f_{xx}&=-\cos(x+2y)e^{2x}-2\sin(x+2y)e^{2x}-2\sin(x+2y)e^{2x}+4\cos(x+2y)e^{2x}\\
&=3\cos(x+2y)e^{2x}-4\sin(x+2y)e^{2x}
\end{align}$$

$$f_{yy}=-4\cos(x+2y)e^{2x}$$ $$f_{xy}=f_{yx}=-2\cos(x+2y)e^{2x}-4\sin(x+2y)e^{2x}$$

So now, if I plug everything into the formula, I get
$$e^{4}+2e^{4}(x-2)+\frac{1}{2!}(3e^{4}(x-2)^2-4e^{4}(x-2)(y+1)-4e^{4}(y+1)^2)=e^{4}(1+2(x-2)+\frac{1}{2!}(3(x-2)^2-4(x-2)(y+1)-4(y+1)^2))$$

Are my results correct ? I just proceeded as usual, using the common two-variables taylor series expansion. Thanks for your help !

Best Answer

Yes, it is correct. An easy way to make sure is just to plot things: blue is the original function, red is your expansion

enter image description here

And this is the code to draw it

from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
from matplotlib import cm
from matplotlib.ticker import LinearLocator, FormatStrFormatter
import numpy as np

fig = plt.figure()
ax = fig.gca(projection = '3d')
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_zlabel('z')

def f(X, Y):
    return np.cos(X + 2 * Y) * np.exp(2 * X)

def taylor(x, y):
    return np.exp(4) * (1 + 2 * (x - 2) + 0.5 * (3 * (x - 2)**2 - 4 * (x - 2) * (y + 1) - 4 * (y + 1)**2))

# Make data.
X = np.arange(1, 3, 0.25)
Y = np.arange(-2, 0, 0.25)
X, Y = np.meshgrid(X, Y)
Z = f(X, Y)
W = taylor(X, Y)

# Plot the surface.
surf = ax.plot_surface(X, Y, Z, cmap = cm.autumn, linewidth = 0, antialiased = False, alpha = 0.5)
sur1 = ax.plot_surface(X, Y, W, cmap = cm.winter, linewidth = 0, antialiased = False, alpha = 0.7)

# Add a color bar which maps values to colors.
ax.xaxis.set_major_locator(LinearLocator(4))
ax.yaxis.set_major_locator(LinearLocator(4))
ax.zaxis.set_major_locator(LinearLocator(4))

plt.show()