powerseries.mws

Consider expanding a function of two variables in a power series about the point x=a,y=b mtaylor(f(x,y),[x=a,y=b],3);

f(a,b)+D[1](f)(a,b)*(x-a)+D[2](f)(a,b)*(y-b)+1/2*D[...
f(a,b)+D[1](f)(a,b)*(x-a)+D[2](f)(a,b)*(y-b)+1/2*D[...

Example: Expand F(x,y)= sin(x) cos(y) about x=y=0

Calculate the first few partial derivatives

> F:=sin(x)*cos(y);

F := sin(x)*cos(y)

> Fx:=diff(F,x);

Fx := cos(x)*cos(y)

> Fy:=diff(F,y);

Fy := -sin(x)*sin(y)

> Fxx:=diff(F,x,x);

Fxx := -sin(x)*cos(y)

> Fxy:=diff(F,y,x);

Fxy := -cos(x)*sin(y)

> Fyy:=diff(F,y,y);

Fyy := -sin(x)*cos(y)

> Fxxx:=diff(F,x,x,x);

Fxxx := -cos(x)*cos(y)

> Fxxy:=diff(F,y,x,x);

Fxxy := sin(x)*sin(y)

> Fxyy:=diff(F,y,y,x);

Fxyy := -cos(x)*cos(y)

> Fyyy:=diff(F,y,y,y);

Fyyy := sin(x)*sin(y)

All of the above are evaluated at x=0,y=0

> mtaylor(F,[x,y],4);

x-1/2*x*y^2-1/6*x^3

NOTE:

In the case of a single variable, the Taylor series has the form

f(x) = sum(1/n!,n = 0 .. infinity) f^{n} (x-a)^n = sum(1/n!,n = 0 .. infinity) ((x-a)*diff(%?,x))^n f (a)

In the case of two variables it can be written as

f(x,y) = sum(1/n!,n = 0 .. infinity) ((x-a)*diff(%?,x)+(y-b)*diff(%?,y))^n f(a,b)