Mathematica Lab

83 Views Asked by At
  1. For each of the following functions and associated points, P, compute the equation of the Taylor quadratic approximation to the function at P. Graph the original surface and its Taylor approximation on the same set of axes, and identify each surface. (a) z = sin(xy), P = (1, PI/2) (b) z = exp(–x^2 – y^2), P = (0.3, 0.4)

How would I plot this in Mathematica

1

There are 1 best solutions below

0
On
func[z_, x0_, y0_] := Total[({z, D[z, x], D[z, y], D[z, {x, 2}], D[z, x, y], D[z, {y, 2}]} /. {x -> x0, y -> y0})*{1, (x - x0), (y - y0), (x - x0)^2/2, (x - x0) (y - y0), (y - y0)^2/2}];

Plot3D[{Sin[x y], Evaluate[func[Sin[x y], 1, Pi/2]]}, {x, 0, 2}, {y, Pi/2 - 1, Pi/2 + 1}, PlotLegends -> SwatchLegend[{"Function", "Approximation"}]]

Plot3D[{Exp[-x^2 - y^2], Evaluate[func[Exp[-x^2 - y^2], 0.3, 0.4]]}, {x, 0.3 - 1, 0.3 + 1}, {y, 0.4 - 1, 0.4 + 1}, PlotLegends -> SwatchLegend[{"Function", "Approximation"}]]

The first line defines a function that returns the quadratic Taylor approximation to z around x0,y0. Series isn't a perfect way to do this, since

Normal[Series[z, {x, x0, 2}, {y, y0, 2}]]

will end up having terms proportional to ${\Delta x}^{2}{\Delta y}$, ${\Delta x}{\Delta y}^{2}$, and ${\Delta x}^{2}{\Delta y}^{2}$.

(Normal just removes the big-O notation, turning the series into the corresponding approximation.)

The second and third lines do the actual plotting. Assuming you are using the default colors, the 'true' function will be orange, while the approximation will be blue.