Message Boards Message Boards

0
|
25613 Views
|
4 Replies
|
2 Total Likes
View groups...
Share
Share this post:

How to Get a Taylor Series for Multiple Variables?

The documentation says that Series operates sequentially for multiple variables. Therefore, it seems to me that it doesn't give a Taylor Series when there are multiple variables. For example:

Normal @ Series[(x + y)^2, {x, x0, 1}, {y, y0, 1}] // Expand

2 x x0 - x0^2 + 2 x y + 2 y y0 - y0^2

Note the 2 x y term. If I do a Taylor Series by brute force I get something different:

 ((x + y)^2 /. {x -> x0, 
     y -> y0}) + (D[(x + y)^2, {{x, y}}] /. {x -> x0, y -> y0}) . {x -
      x0, y - y0} // Expand

2 x x0 - x0^2 + 2 x0 y + 2 x y0 - 2 x0 y0 + 2 y y0 - y0^2

Is there any built-in function that will give me a Taylor series?

POSTED BY: Frank Kampas
4 Replies
Posted 4 years ago

POSTED BY: Liam Scanlon

This old code

Remove[bilgicTaylor];
bilgicTaylor[f_, varL_List?VectorQ, zeroL_List?VectorQ, 
  degree_Integer?NonNegative] :=
 Module[{X, tPD}, 
   (* total preDifferential *)
   X /: X[o_List]^n_Integer := Product[X[o], {i0, n}];
   X /: X[o_List] X[p_List] := X[o + p];
   tPD = Plus @@ (zeroL*
       Thread[X[
         Sort[Permutations[Join[{1}, Table[0, {Length[zeroL] - 1}]]], 
          Flatten[Position[#, 1] &]]]]);
   (* result *)
   f[Sequence @@ varL] + Sum[Expand[tPD^d]/d!, {d, 1, degree}] //. 
    X[oo_List] :> Derivative[Sequence @@ oo][f][Sequence @@ varL]
   ] /; Length[varL] == Length[zeroL]

should do it

In[18]:= Clear[k]
k[u_, v_] := (u + v)^2

In[20]:= bilgicTaylor[k, {x, y}, {x0, y0}, 2]
Out[20]= 2 x0 (x + y) + (x + y)^2 + 2 (x + y) y0 + 1/2 (2 x0^2 + 4 x0 y0 + 2 y0^2)

In[23]:= %20 // Simplify
Out[23]= (x + x0 + y + y0)^2

check it simply by undefining the k

Remove[k]
bilgicTaylor[k, {x, y}, {x0, y0}, 2]
POSTED BY: Udo Krause

Interesting. You transformed it to an expansion with one variable.

POSTED BY: Frank Kampas

One way it to take the directional derivative:

Normal@Series[
   f[x, y] /. Thread[{x, y} -> {x0, y0} + t {x - x0, y - y0}],
   {t, 0, 1}] /. t -> 1
POSTED BY: Gianluca Gorni
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract