OK.. I seemed to think that the series method gets the correct result. But 
it does not entirely...

>>> import sympy as sy
>>> x = Symbol("x")

# Basic calling of series method is "sy.series(function, x0=..., n=...)" 
where x0 is the point at which the expansion is taken at, while n is the 
order of the *error*! (*not* the number of terms *prior* to the error 
term!!) Other tools I have used imply that the error is of order (n+1) when 
n is specified, so this is sort of confusing.

>>> sy.series(sy.sin(x),x0=0)
 x - x**3/6 + x**5/120 + O(x**6)
>>> sy.series(sy.sin(x),x0=sy.pi/2)
 1 - (x - pi/2)**2/2 + (x - pi/2)**4/24 + O((x - pi/2)**6, (x, pi/2))
>>> sy.series(sy.sin(x),x0=sy.pi)
 pi + (x - pi)**3/6 - (x - pi)**5/120 - x + O((x - pi)**6, (x, pi))

# The above seems to be ok. But what if I expand to a different number of 
terms than the default?

>>> sy.series(sy.sin(x),x0=sy.pi/2,n=1)
 O(x - pi/2, (x, pi/2))
# The result *should* have been 1 + O(**1)! The value for sin(pi/2) is 
missing.

>>> sy.series(sy.sin(x),x0=sy.pi/2,n=2)
 1 + O((x - pi/2)**2, (x, pi/2))
# This result is ok.

>>> sy.series(sy.sin(x),x0=sy.pi/2,n=3)
 1 - (x - pi/2)**2/2 + O((x - pi/2)**3, (x, pi/2))
# This result is ok

>>> sy.series(sy.sin(x),x0=sy.pi/2,n=4)
1 - (x - pi/2)**2/2 + O((x - pi/2)**4, (x, pi/2))
# This result is ok

>>> sy.series(sy.sin(x),x0=sy.pi/2,n=5)
 1 - (x - pi/2)**2/2 + (x - pi/2)**4/24 + O((x - pi/2)**5, (x, pi/2))
# This result is ok
--
In *summary*: 
* there is an error when n=0, i.e., no error: the result should have been 
given as 1.
* it is also slightly confusing the way the number n of terms is defined -- 
this definition seems to be different from other tools...

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/1d967fbf-1b04-4881-b8b5-b91095b7cb8a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to