Post Reply 
Multivariable Taylor series
03-31-2019, 11:01 AM
Post: #1
Multivariable Taylor series
Is it possible to compute an i-order taylor series for an n-variable function using the built in library? We learned about higher order differentials in calc 2 yesterday, I tried using the ``taylor`` function but the output I got didn't make much sense to me.
Find all posts by this user
Quote this message in a reply
03-31-2019, 02:03 PM
Post: #2
RE: Multivariable Taylor series
Example:
Code:
series(subst(sin(x+y)+cos(y*x),[x,y],h*[x,y]),h=0,6,polynom)(h=1)
Find all posts by this user
Quote this message in a reply
03-31-2019, 03:44 PM
Post: #3
RE: Multivariable Taylor series
Thank you very much for that hint, sadly I'm not yet that familiar with the HP CAS as to fully understand what that expression does. Here are some questions:

1. What does ``polynom`` mean in that context? from the documentation I can see the ``series`` function takes only two arguments.
2. Where is the center of the approximation defined? I assumed it's being defined at the origin, like the maclaurin series. If this is true, would there be a way to define the approximation at some arbitrary point?

I tried wrapping the statements in a single function. Would this be a correct way to do it? From limited testing I can say both the function and the expression return the same expressions
Code:

maclaurin_ord(expr_rep,vars,order):=(series(expr_rep(vars = (reserved*vars)),reserved = 0,order,polynom))(reserved = 1)

Also if it's not too much to ask I'd love if you could explain the meaning behind the substitution ``x=h*x`` and ``y=h*y``.
Find all posts by this user
Quote this message in a reply
03-31-2019, 06:47 PM
Post: #4
RE: Multivariable Taylor series
series does univariate series expansion. subst does a change of scale on x and y in order to have a univariate series expansion at x=y=0 (h=0). If you want a series expansion in (u,v) at (x0,y0) you will do subst(...,[x,y],[x0+h*u,y0+h*v]).
polynom is an optional arg to series to remove the remainder term.
Find all posts by this user
Quote this message in a reply
03-31-2019, 11:46 PM
Post: #5
RE: Multivariable Taylor series
So these are the functions I was able to come up with:

Code:
maclaurin_mv(expr_rep,vars,order):=(series(expr_rep(vars = (reserved*vars)),reserved = 0,order,polynom))(reserved = 1)
taylor_mv(expr_rep,vars,order,center_rep):=(maclaurin_mv(expr_rep(vars = (vars+center_rep)),vars,order)))(vars = (vars-center_rep))

The taylor version simply moves the origin of the function to ``center_rep``, expands the maclaurin series and then offsets the function back to its origin.

If you have any comments on my solution, like how I could improve it, please do post them. I'm open to criticism.
Find all posts by this user
Quote this message in a reply
04-02-2019, 08:04 PM
Post: #6
RE: Multivariable Taylor series
I'm getting these "Running non recursive evaluator" warnings whenever I call the ``taylor_mv`` or the ``maclaurin_mv`` functions I posted above. Evaluating the ``series(...)`` expression does not bring up the warning though. This would not happen at the time of making the previous post, I did not alter the functions but for some reason the calculator thinks it's appropriate to warn me about this now, I purged all of the user-defined variables (except for these two function definitions) but the warning persists. The result for these functions is still the same thought, the warnings do not seem to affect the output.

   
Results in:

   
Find all posts by this user
Quote this message in a reply
04-03-2019, 06:45 AM
Post: #7
RE: Multivariable Taylor series
Try this CAS program (you can paste it directly on the CAS commandline on the emulator)
Code:
tay(f,v,l,o):=begin
  local k,r;
  purge(r);
  k:=subst(f,v,r*v+l);
  k:=series(k,r=0,o,polynom);
  k:=subst(k,r=1);
  return k;
end:;
Find all posts by this user
Quote this message in a reply
04-04-2019, 05:55 PM
Post: #8
RE: Multivariable Taylor series
Well, I just looked at the source code and found that multivariate series expansion is already implemented :-) For example:
series(sin(x+y),[x,y],[1,2],5)
Find all posts by this user
Quote this message in a reply
04-05-2019, 11:09 AM
Post: #9
RE: Multivariable Taylor series
Oh that's great! Thanks for all the help. Also this source code you're talking about. Is it the calculator source code? Is it open source?
Find all posts by this user
Quote this message in a reply
04-05-2019, 12:19 PM
Post: #10
RE: Multivariable Taylor series
I don't know if you're aware of it, but Mr. Bernard Parisse is CAS developer, so he has access to source code for sure. :-)

Prime, 15C CE
Find all posts by this user
Quote this message in a reply
04-06-2019, 05:24 AM
Post: #11
RE: Multivariable Taylor series
The source code of the CAS is based on giac, and giac is open source. You can find a tarball on my webpage, or look at Geogebra giac source tree https://dev.geogebra.org/trac/browser/tr...c/src/giac
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)