How to evaluate A Taylor series at a specific value

08222018, 07:52 PM
Post: #21




RE: How to evaluate A Taylor series at a specific value
 is evaluated more like a program, where x would be like an argument. taylor(sin(x))x=0.5 will evaluate sin(x) to sin(0.5) before taylor is called.
It's hard to evaluate . You don't want to get sin(1) for sin(x)x=2 if x:=1; has been run, yet you want to get sin(6) for sin(a*x)x=2 if a:=3. I don't like this notation, I prefer subst. 

08222018, 08:50 PM
Post: #22




RE: How to evaluate A Taylor series at a specific value
(08222018 06:56 PM)Albert Chan Wrote: This is a bug. Why would the evaluate of a function that contains an error term magically drop the error term? Just because a certain piece of software has decided to follow a particular convention does not mean that it is necessarily universal  or even mathematically correct. (x/x)  x=0 is indeterminate. The expression x/x is undefined at 0. Even if one were to "evaluate first", the expression x/x only evaluates to 1 when x is nonzero. Graph 3D  QPI  SolveSys 

08222018, 09:23 PM
Post: #23




RE: How to evaluate A Taylor series at a specific value
(08222018 08:50 PM)Han Wrote: Why would the evaluate of a function that contains an error term magically drop the error term? Exactly ! Taylor series that carried the error term should not be evaluable, at any x. The fact that taylor(sin(x))  x=0.5 can return anything is not right. Unless ... (see below) Quote:(x/x)  x=0 is indeterminate. The expression x/x is undefined at 0. It were meant to test the CAS order of evaluation. If CAS does evaluation before substitution, x/x simplied as 1 But, if CAS return 0/0, taylor(sin(x))  x=0.5 return sin(0.5) make sense. 

08232018, 02:30 PM
Post: #24




RE: How to evaluate A Taylor series at a specific value
(08222018 07:52 PM)parisse Wrote:  is evaluated more like a program, where x would be like an argument. If "" is like running a program with argument x: taylor(sin(x))x=0.5 ==> (lambda x: taylor(sin(x))) (0.5) ==> taylor(sin(0.5)) ==> sin(0.5) sin(x)x=2 ==> (lambda x: sin(x))(2) ==> sin(2) Why does "" hard to evaluate ? Why previous run of x := 1 affect it ? Maybe "" is simply "evaluate at" ? However, that imply taylor had a bug (post #23) 

08232018, 03:15 PM
Post: #25




RE: How to evaluate A Taylor series at a specific value
It is hard to evaluate because there are equally many cases where the "correct" behavior is substituting before, vs substituting after. You can't know which is "correct" programmatically.
TW Although I work for HP, the views and opinions I post here are my own. 

08242018, 12:08 AM
(This post was last modified: 08242018 12:08 AM by Han.)
Post: #26




RE: How to evaluate A Taylor series at a specific value
(08232018 02:30 PM)Albert Chan Wrote:(08222018 07:52 PM)parisse Wrote:  is evaluated more like a program, where x would be like an argument. Consider the expression a*x^2. Suppose 'x' is left undefined and we execute: a:=3; a*x^2; Most people would expect the second expression to return 3*x^2 and not a*x^2. Now suppose the parameter 'a' were removed and apply the same thought process to 'x' within an expression using the  operator. Do you see where this could be ambiguous? (pun optional) Graph 3D  QPI  SolveSys 

08242018, 01:06 AM
(This post was last modified: 08272018 03:19 PM by Albert Chan.)
Post: #27




RE: How to evaluate A Taylor series at a specific value
(08242018 12:08 AM)Han Wrote: Most people would expect the second expression to return 3*x^2 and not a*x^2. Thanks Han. From the user side, yes ... this is ambiguous. But, from CAS, there is no ambiguity, once order of evaluation is defined. It is like 1 + 2 * 3, if multiply before add, it is 7; without the precedence, it is 9 Since parisse (post #21) said that x:=1, followed by sin(x) x=2, will return sin(1), this suggest CAS is doing the expression first, before substitution. So, the trick is to think like CAS, and the ambiguity is gone. Just an example, my Casio evaluate 1/ABC as 1/(ABC), instead of expected 1/A*B*C So, ..., I just think like the calculator (especially important if it is RPN) Edit: my conclusion was wrong (as parisse later pointed out, the result is sin(2), not sin(1)) Going straight to hp50g reference manual, "" is the "where" command 

08242018, 06:21 AM
Post: #28




RE: How to evaluate A Taylor series at a specific value
This is wrong: x:=1 followed by sin(x)x=2 returns sin(2), and that's not easy to evaluate, you must have a "local" value of x (2) that takes precedence over the global value of x (1).


08242018, 07:42 AM
(This post was last modified: 08242018 09:03 AM by Albert Chan.)
Post: #29




RE: How to evaluate A Taylor series at a specific value
(08222018 07:52 PM)parisse Wrote: It's hard to evaluate . You don't want to get sin(1) for sin(x)x=2 if x:=1; has been run, (08242018 06:21 AM)parisse Wrote: This is wrong: x:=1 followed by sin(x)x=2 returns sin(2), and that's not easy to evaluate I am confused. What situation will sin(x)x=2 return sin(1) ? Edit: Sorry for the noise. Above expression always return sin(2) 

08242018, 02:08 PM
Post: #30




RE: How to evaluate A Taylor series at a specific value
(08242018 06:21 AM)parisse Wrote: This is wrong: x:=1 followed by sin(x)x=2 returns sin(2), and that's not easy to evaluate, you must have a "local" value of x (2) that takes precedence over the global value of x (1). It would be nice if you could use the "where" operator "" to temporarily undefine variables. For example: x:=1 followed by sin(x)x=? (I'm not sure what the syntax ought to be here, but basically mark x as undefined) would return sin(x), ignoring the value assigned to x. — Ian Abbott 

08242018, 06:58 PM
Post: #31




RE: How to evaluate A Taylor series at a specific value
You can already run expressionx=x


08242018, 08:23 PM
Post: #32




RE: How to evaluate A Taylor series at a specific value
(08242018 06:58 PM)parisse Wrote: You can already run expressionx=x That's a handy trick to know, thanks, although the semantics of that notation seems a little dodgy! — Ian Abbott 

08262018, 08:43 AM
Post: #33




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. Good point, parisse, I've implemented Lagrange remainder and Peano remainder (littleo notation) on the Nspire for the students. Thanks for reminding me Best, Aries 

08272018, 02:33 PM
Post: #34




RE: How to evaluate A Taylor series at a specific value
(08222018 07:52 PM)parisse Wrote:  is evaluated more like a program, where x would be like an argument. taylor(sin(x))x=0.5 will evaluate sin(x) to sin(0.5) before taylor is called. I see the difficulty in determining whether the x=0.5 should be evaluated before or after. Since taylor(sin(x))x=0.5 is evaluated before, but ∂(sin(x),x)x = 0.5 is evaluated after, I assume there is some way in the source code to indicate which functions are "before" and which are "after." Or is ∂() a special case? 

08272018, 03:10 PM
Post: #35




RE: How to evaluate A Taylor series at a specific value
Indeed. There are special evaluation rules for derivative and a few other functions but it's a nightmare to support non standard evaluation rules. That's why taylor or commands that are used by more advanced students follow standard rules.


08272018, 04:15 PM
Post: #36




RE: How to evaluate A Taylor series at a specific value
(08272018 02:33 PM)Wes Loewer Wrote: I see the difficulty in determining whether the x=0.5 should be evaluated before or after. It seems evaluation order is context based. This is my guess ... Differentiation had the dx, notifying the ∂(...) what to differentiate against. Variable x thus off limit for where substitution, until expression differentiated. In other words, where substitution is delayed. (same for integration) Regular expressions, there is no need to delay where replacement. We can think of where as running code with argument x, like parisse described earlier: f(x)x=a => (lambda x: f(x))(x=a) => f(a) taylor(sin(x))x=0.5, however, is inconsistent with above logic. It should be treated like ∂(...), since it had an off limit x, to "taylor" against. Perhaps implied x does not count ? What is the result of taylor(sin(x), x=0, 5)x=0.5 ? 

« Next Oldest  Next Newest »

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