How can I expand a function in Mathematica to second order in two variables?

  • Context: Mathematica 
  • Thread starter Thread starter ice109
  • Start date Start date
  • Tags Tags
    Mathematica Weird
Click For Summary

Discussion Overview

The discussion focuses on deriving multivariate Taylor series expansions in Mathematica, specifically targeting second-order expansions in two variables. Participants explore the built-in functionalities of Mathematica and seek alternative methods to achieve the desired representation of series expansions.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant expresses confusion over Mathematica's default behavior in computing series expansions, noting that it processes variables successively rather than simultaneously.
  • Another participant suggests that while there is no built-in method to order terms by total degree, a workaround could be developed.
  • A proposed function, multiVarSeries, is shared to compute multivariate series expansions, but it is noted that it does not allow for separate order specifications for each variable.
  • One participant requests an adjustment to the function to compute terms up to a specified total order, expressing dissatisfaction with the current output that includes higher-order terms.
  • Concerns are raised about the lack of resources for learning Mathematica programming, with suggestions that workshops exist but may be costly.
  • Another participant reports an issue with a different approach using Normal[Series[Exp[x*t + y*t], {t, 0, 2}]], indicating it works for their case but not for their specific function.
  • Repeated inquiries about achieving a second-order expansion representation indicate ongoing confusion and a lack of resolution regarding the methods discussed.

Areas of Agreement / Disagreement

Participants do not reach a consensus on the best method for achieving the desired series expansion representation. Multiple competing views and approaches are presented, with some participants expressing frustration over the limitations of existing solutions.

Contextual Notes

Limitations include the lack of built-in functionality for ordering terms by total degree and the complexity of adjusting shared functions to meet specific user needs. There is also uncertainty regarding the effectiveness of different proposed methods for various functions.

Who May Find This Useful

This discussion may be useful for Mathematica users interested in multivariate calculus, particularly those seeking to understand or implement Taylor series expansions in their work.

ice109
Messages
1,708
Reaction score
6
does anyone know how to derive multivariate taylor series in mathematica? by default it is computed in a very strange: "Series performs a series expansion successively with respect to each variable. The result in this case is a series in x, whose coefficients are series in y. "
 
Physics news on Phys.org
What don't you like about this representation? If you want to have the terms ordered by the total degree of the monomials, there seems not to be a built-in way to do it. (But it shouldn't be too hard to come up with a work-around oneself ...)
 
Try using the function Collect:

Collect[Series[Exp[x y], {x, 0, 8}, {y, 0, 8}] , {x, y}]

If that's not what you want, then I fail to understand. I'm sure there must be a way to do what you are asking, however.
 
Now I understand the problem. That's strange that Mathematica does not have much material about multivariate series, so we can add it ourselves.

Code:
multiVarSeries[f_, x_List, a_List, k_Integer] :=  Block[{n, F}, 
  Evaluate[Fold[Sum, 
     Product[(1/n[i]!) (x[[i]] - a[[i]])^(n[i]), {i, 1, Length[x]}]
 ((Fold[D, F@@x, Table[{x[[i]], n[i]}, {i, 1, Length[x]}]]) /. 
        Table[x[[i]] -> a[[i]], {i, 1, Length[x]}]), 
     Table[{n[i], 1, k}, {i, 1, Length[x]}]]] /. F -> Function[x, f]]

Copy and paste that function into a new cell and then execute it with shift + enter. After that you can invoke the function. Here is a simple example:

multiVarSeries[Exp[x y], {x, y}, {0,0}, 2]

This says to expand the function Exp[x y] with respect to the variables x and y around the point {0,0} up to order 2 (in both variables, I don't let you specify the order separately for each individual variable). The output is of course:

\frac{x^3 y^3}{6}+\frac{x^2 y^2}{2}+x y
 
i don't know much about mathematica programming so can you adjust your function so that it computes to a total order of n? e.g. for order 2 xy terms are written out and x^2 and y^2 terms but not x*y^2. and you example seems to show terms up to order 3

ps
how can i learn to program mathematica
 
ice109 said:
i don't know much about mathematica programming so can you adjust your function so that it computes to a total order of n? e.g. for order 2 xy terms are written out and x^2 and y^2 terms but not x*y^2. and you example seems to show terms up to order

Yes, I understand your complaint with the function. One thing you can do is make n larger than you need and then use a filter to get only the terms you want. It is more work than it is worth for me to change the function to match that behavior.

how can i learn to program mathematica

There is no good way. If you are really wealthy, you can do workshops online with Wolfram Inc that will teach you how to program Mathematica. Otherwise you have to do what I did, which is to read the built-in help and practice for months.
 
well it doesn't work. i read on a grou somewhere the Normal[Series[Exp[x*t + y*t], {t, 0, 2}]] /. t -> 1 would work and it does but it doesn't work for my function. any ideas?
 
ice109 said:
well it doesn't work. i read on a grou somewhere the Normal[Series[Exp[x*t + y*t], {t, 0, 2}]] /. t -> 1 would work and it does but it doesn't work for my function. any ideas?

What doesn't work and what function are you trying to do this with?
 
so here i am again with the same problem. how in the heck do i get mathematica to give me this representation:
943f2353e0a301de0bfb79c59081582a.png

704c13f6bfba5c76307c1b7d1c1cac92.png

441cf1e77141e929014082c51cb68fe3.png


of a function expanded to second order in both of its arguments
 
Last edited by a moderator:

Similar threads

  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 8 ·
Replies
8
Views
10K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 3 ·
Replies
3
Views
5K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
Replies
2
Views
2K
  • · Replies 7 ·
Replies
7
Views
2K