Hi Tom
> 1) Would it be possible to incorporate the new expansion method into the
> sympy.core.expr methods series/nseries? I.e. instead of calling a new
> function taylor, we would simply call series and get a quick response if
> possible.
> 3) Do you keep track of orders?
> In the example you showed I did not see any O(...) terms.
I did not put the O(x^n) in the output of taylor(p,x,0,n)
When taylor(p,x,0,n) uses QQ or SR the order is always O(x^n) and is
not
indicated in the output; when it uses series(p,x,0,n) it gives the
order.
Changing taylor so that it works for expansions around x !=0 and
adding
the order it seems to me that it would always give the output of
series.
> 2) Does this work with special functions? For example say we want to
> find a series expansion for exp(x)/loggamma(1/x). The asymptotic series
> expansion for loggamma returns this:
>
> In [1]: loggamma(1/x).nseries(x,n=3,logx=y)
> Out[1]:
> y log(2⋅π) x 1 y
> ─ + ──────── + ── - ─ - ─ + O(x**3)
> 2 2 12 x x
>
> After that can the fast polys code take over?
> 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)
exp(x)/loggamma(1/x) =
-w*(x*exp(x)*(1-x/2+w -x*w*log(2*pi)/2 -x**2*w/12)**-1 + O(x**4) +
O(w**k))
multivariate series are not yet in lpoly, but I plan to
translate them from rmpoly.
Using rmpoly
import sys
from time import time
from rmpoly import *
from sympy import *
rp, x,w = rgens('x,w',8,sympify)
hx = 4
hw = 3
t0 = time()
p1 = 1 - x/2 + w - x*w*log(2*pi)/2 - x**2*w/12
p1 = p1.pow_trunc(-1,['x','w'],[hx,hw-1]).mul_trunc(w,'w',hw)
p2 = -x.exp('x',hx).mul_trunc(x,'x',hx)
p = p2.mul_trunc(p1,'x',hx)
t1 = time()
print p1
print '%.2f' %(t1-t0)
The output is
+(-5/12 + 3*log(2*pi)/8)*w^2*x^3 +(-2/3 + log(2*pi)/2)*w^2*x^2 +(-1 +
log(2*pi)/2)*w^2*x +(-1)*w^2 +(1/8)*w*x^3 +(1/4)*w*x^2 +(1/2)*w*x
+(1)*w
0.01
Is this the result expected? If I have misunderstood the
problem please tell me.
with hw=10 it takes 0.04s
I guess that in lpoly it would be something like
p1 = multi_taylor(-w*(x*exp(x)*(1-x/2+w -x*w*log(2*pi)/2 -x**2*w/
12)**-1, [x,y],[hx,hw])
and that it would be 2x or 3x slower.
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.