Taylor Series in Two Variables

Mathematica Built-in Commands

f[x_,y_]=(1/(1-x-y))

Here is how Mathematica built-in commands can be used to create Taylor's formula for two variables:

Series[f[x,y],{x,0,4},{y,0,4}]

To get rid of the ((O[x])^5)and ((O[y])^5) bits we use the command Normal:

Normal[Series[f[x,y],{x,0,4},{y,0,4}]]

And finally, expanding this gives us a polynomial:

Expand[%]

Notice Mathematica does an expansion in x and then in y. We can change the order if we like:

Normal[Series[f[x,y],{y,0,4},{x,0,4}]]
Expand[%]

Using the Formula in the text

The text gives formulas, which are more interesting than the Mathematica built-in commands. We can use Mathematica to implement the formula for the expansion about (0,0) if we use the fact that

(((r+s))^i)=(∑_(k=0)^i)Binomial[i,k] (r^(i-k))(s^k)

f[x_,y_]=(1/(1-x-y))
n=4;
(∑_(i=0)^n)(1/(i!))((∑_(k=0)^i)Binomial[i,k](x^(i-k))(y^k)Derivative[i-k,k][f][0,0])
Expand[%]

Notice that this looks a bit different from what we had before--we are actually stopping the expansion a bit earlier. We are only going out to terms with order 5, whereas the built in Mathematica command was going out to terms of order 8 since it was doing two single variable taylor series expansions.

Something to be aware of!

The Mathematica built-in expansionincludes extra terms--I think it is preferable to use our formulas that we wrote rather than the Series command. Notice that if we take each series out to n=2 in an effort to get a quadratic approximation, we get some extra terms:

f[x_,y_]=(1/(1-x-y))
Normal[Series[f[x,y],{y,0,2},{x,0,2}]]
Expand[%]

All the terms with order greater than 2 really should be dropped from this expansion.

Using the formula with n=2 gives us the quadratic approximation we would expect:

f[x_,y_]=(1/(1-x-y))
n=2;
(∑_(i=0)^n)(1/(i!))((∑_(k=0)^i)Binomial[i,k](x^(i-k))(y^k)Derivative[i-k,k][f][0,0])
Expand[%]

Example

Find the n=7 approximation to the function f(x,y)=(e^x)Cos y near the origin. Sketch the situation.

Barry's Solution

f[x_,y_]=Exp[x] Cos[y]
n=7;
(∑_(i=0)^n)(1/(i!))((∑_(k=0)^i)Binomial[i,k](x^(i-k))(y^k)Derivative[i-k,k][f][0,0])
approx[x_,y_]=Expand[%]

Plot3D[{f[x,y],approx[x,y]},{x,-3,3},{y,-3,3},PlotStyle->{Red,Blue},PlotPoints->40]