On May 3, 8:27 pm, Tom Bachmann <[email protected]> wrote:
> >> The example mentioned above [exp(x)/loggamma(1/x)] is typical for the
> >> kind of expansion we do in limits, in this case we need two terms. This
> >> takes about 0.5 seconds currently.
>
> > This seems to me can be done with a bivariate series
> > in x and w, where w = 1/y = 1/log(x)
>
> Maybe this was a bad example. My point is not the log(x) - this should
> be treated as an independent symbol, yes. My point is can your fast
> taylor function cooperate with the ordinary series expansion code for
> things it does not know how to expand?


I made a change in taylor; now it has an optional parameter
pol_pars for the symbols which should be treated as polynomial
parameters in lpoly.
Now taylor can do the example almost automatically

>>> from sympy import *
>>> from sympy.polys.ltaylor import taylor
>>> from time import time as tm
>>> x,y=symbols('x,y')
>>> h=3
>>> p = (x*exp(x))/expand((x*(y/2 + log(2*pi)/2 + x/12 - 1/x - y/x)))
>>> t0=tm();p1=taylor(p,x,0,h);'%.3f'%(tm()-t0)
'0.014'
>>> t0=tm();p2=series(p,x,0,h);'%.3f'%(tm()-t0)
'0.411'
>>> expand(p1-p2)
O(x**3)

Here is the result of a single run for higher values of h
h      taylor    series
4      0.009     0.996
5      0.011     2.415
6      0.011     5.071
7      0.016     9.811
for h >= 5 expand(p1-p2) does not give O(x**h), but doing
>>> for i in range(1,12):
...  print expand(p1.subs(y,i) - p2.subs(y,i))
gives always O(x**h)
so I guess that they are equal.


I say almost automatically because I multiplied numerator and
denominator by x; not doing that taylor would call series.

Mario

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sympy?hl=en.

Reply via email to