How to evaluate A Taylor series at a specific value

05112018, 11:44 PM
Post: #1




How to evaluate A Taylor series at a specific value
Just got the Prime and was able to get the Taylor expansion for a function. But cannot figure out how to evaluate it at a specific value of x. Thanks!


05122018, 03:40 AM
(This post was last modified: 05122018 03:41 AM by Tim Wessman.)
Post: #2




RE: How to evaluate A Taylor series at a specific value
Put your cursor on the "taylor" part of the input, or select the function in the menu and press the HELP button. Does any of the help for the taylor function explain what you need?
TW Although I work for HP, the views and opinions I post here are my own. 

05122018, 10:13 AM
Post: #3




RE: How to evaluate A Taylor series at a specific value
Thanks but no, it gives me the syntax for using the Taylor function but does not include an option to evaluate the polynomial at, say, x = 3. I can change the Taylor to be centered at x = 3, but that is not the same.


05122018, 02:25 PM
Post: #4




RE: How to evaluate A Taylor series at a specific value
CAS:
p:=taylor(sin(x),x=0,5,polynom); p(x=3) 

05122018, 02:36 PM
(This post was last modified: 05122018 02:53 PM by Joe Horn.)
Post: #5




RE: How to evaluate A Taylor series at a specific value
EDIT: Yikes, while I was writing the following reply, Bernard beat me to it with his simpler method above. I leave the following here for historical purposes.
There might be a simpler way, but this way only takes two steps and it does work. (1) In CAS, execute taylor(function) (2a) select and copy the result to the command line, then backspace the entire "order_size" term (2b) press the template key (C) and tap the third item (the "where" function) (2c) type x=whatever value you want, and press Enter (3) optional: compare with the exact value Example for sin(x) where x=0.5: Note: The default order for the taylor() function is 5. If a different order is desired, just specify it using taylor's syntax, e.g. taylor(sin(x),x,7)) for order 7. <0ɸ0> Joe 

05122018, 02:44 PM
Post: #6




RE: How to evaluate A Taylor series at a specific value
(Variation on a theme):
taylor(sin(x))x = 0.5 Dale 

05122018, 02:53 PM
Post: #7




RE: How to evaluate A Taylor series at a specific value
Thanks all for the very quick replies! I knew there had to be a way. Still getting used to the Prime.


05122018, 02:56 PM
(This post was last modified: 05122018 02:58 PM by Joe Horn.)
Post: #8




RE: How to evaluate A Taylor series at a specific value
(05122018 02:44 PM)DrD Wrote: (Variation on a theme): Hmmmm.... That seems to return sin(.5), not the desired result. Not sure why. Perhaps the x gets substituted right away, resulting in taylor(sin(.5))? <0ɸ0> Joe 

05122018, 03:01 PM
Post: #9




RE: How to evaluate A Taylor series at a specific value
Probably due to settings ...
[attachment=5930] 

05122018, 03:06 PM
Post: #10




RE: How to evaluate A Taylor series at a specific value
(05122018 03:01 PM)DrD Wrote: Probably due to settings ... That's not the desired result. That's sin(.5). See my screen shot above and compare the two outputs to yours. <0ɸ0> Joe 

05122018, 03:13 PM
(This post was last modified: 05122018 03:20 PM by DrD.)
Post: #11




RE: How to evaluate A Taylor series at a specific value
I see what you mean. I tried it another way, and it seems to just return the SIN(x), not the taylor series evaluation. Oopsie!
Same thing if you make it into a function of x: f(x):=taylor(SIN(x)); f(.5) ⇒ sin(.5) = 0.479425538604 Ignores the tayor() series expansion. Is that fair play, or bug? 

05122018, 04:00 PM
Post: #12




RE: How to evaluate A Taylor series at a specific value
Bernard's example used an extra, undocumented 4th paramter: polynom. This appears to return the expansion without the O term. If we use his syntax, it works:
taylor(sin(x),x,5,polynom) = x1/6*x^3+1/120*x^5 taylor(sin(x),x,5,polynom)x=(1/2) = 1841/3840 = 0.479427083333 Ceci n'est pas une signature. 

05122018, 04:42 PM
Post: #13




RE: How to evaluate A Taylor series at a specific value
The trick is trying to remember the tricks!


05122018, 04:53 PM
(This post was last modified: 05122018 05:06 PM by Mark Hardman.)
Post: #14




RE: How to evaluate A Taylor series at a specific value
Ceci n'est pas une signature. 

08212018, 03:00 PM
Post: #15




RE: How to evaluate A Taylor series at a specific value  
08212018, 04:47 PM
(This post was last modified: 08212018 04:48 PM by parisse.)
Post: #16




RE: How to evaluate A Taylor series at a specific value
But a Taylor expansion has two parts: the polynomial part and the remainder term. Unfortunately students tend to forget the remainder term, and that will not help if the calculator ignores it as well. That's why you have taylor(.) and taylor(.,polynom) on the HP. And if you don't remind the polynom trick, you can still run f:=taylor(sin(x),x=0,5) then fx=0.5 and ignore the order_size term.
:) 

08212018, 07:37 PM
Post: #17




RE: How to evaluate A Taylor series at a specific value
(08212018 04:47 PM)parisse Wrote: But a Taylor expansion has two parts: the polynomial part and the remainder term. Unfortunately students tend to forget the remainder term, and that will not help if the calculator ignores it as well. That's why you have taylor(.) and taylor(.,polynom) on the HP. And if you don't remind the polynom trick, you can still run f:=taylor(sin(x),x=0,5) then fx=0.5 and ignore the order_size term. Best answer. Thanks a lot. Guy R. KOMAN, hp 50G, hp Prime Rev. C 

08212018, 08:54 PM
Post: #18




RE: How to evaluate A Taylor series at a specific value
(05122018 02:56 PM)Joe Horn Wrote:(05122018 02:44 PM)DrD Wrote: (Variation on a theme): This is somewhat related to the original question. Computer software is not as adept at identifying the intended order of operations. While taylor(sin(x))x = 0.5 seems "obvious" to most readers, one must ask (from the point of view of the software) when should substitution occur? Should it be after the evaluation of the taylor() command (or more generally, any command), or should it occur before the evaluation? Even extra parentheses would not help; think carefully as to why. To avoid such ambiguity, users should separate the operations into two separate steps. Graph 3D  QPI  SolveSys 

08222018, 02:09 PM
Post: #19




RE: How to evaluate A Taylor series at a specific value
Much like the comma operator in C. When you use the comma operator:
x = 5, 6; the order of execution is fixed and the results are clear. But, in a function call: x = f(g(), h()); the comma is *not* a comma operator but a list separator and the operations can be done in any order. Probably in the order YACC does it. 8^) 

08222018, 06:56 PM
(This post was last modified: 08222018 08:14 PM by Albert Chan.)
Post: #20




RE: How to evaluate A Taylor series at a specific value
(05122018 02:56 PM)Joe Horn Wrote:(05122018 02:44 PM)DrD Wrote: taylor(sin(x))x = 0.5 This is a bug. Evaluate a taylor series while carrying the O[x] term is meaningless. This is how Mathematica hande it: In[1]:= taylor = Series[Sin[x], {x, 0, 5}] Out[1]= x  x^3/6 + x^5/120 + O[x]^6 In[2]:= taylor /. x > 0.5 SeriesData::ssdn: Attempt to evaluate a series at the number 0.5; returning Indeterminate. Out[2]= Indeterminate In[3]:=Normal[taylor] /. x > 0.5 (* Drop the O[x] term, then substitute *) Out[3]= 0.479427 BTW, Mathematica (v 4.0) had the bug too, if x had Pi in it. In[4]:= taylor /. x> 1/2 + Pi/10^10 // N Out[4]= 1. 0.5  0.166667 0.125 + .00833333 0.03125 + O[0.5]^6 In[5]:= % // Normal (* above should be Indeterminate too ! *) Out[5]= 0.479427 BTW, you can test evaluation order with this: (x/x) x = 0 For Mathematica, it is evaluation before substitution, result = 1, not 0/0 

« Next Oldest  Next Newest »

User(s) browsing this thread: