Message Boards Message Boards

1
|
4195 Views
|
4 Replies
|
2 Total Likes
View groups...
Share
Share this post:

How to speed up this asymptotic series expansion?

Posted 3 years ago

Hi, I need to expand the function

F[s_]:=(((1+s)^2+3*s^(3/2)*(1+s)^(1/2)*th-4*s*(1+s)*th+3*s^(1/2)*(1+s)^(3/2)*th+s^2*th^2))/
            (8 (s^(3/2)*(1+s)^(1/2)*((1+s)^(1/2)+s^(1/2)*th)^3));

in an asymptotic series around s=Infinity. In principle I am able to do this using Series[] command, but only for maximally 20 terms, whereas I need 40 or more. The problem is that the Series[] command slows down enormously when more than 20 terms are requested. Is there any method that can speed up such a series expansion? I already asked similar questions a few times on the list, since it is not the first time I face this problem, but nobody gave a solution. Previously I was able to convert my function to the function of z=1/s, and then apply the Taylor expansion around z=0, for which the coefficients were easily and rapidly computable without using the Series command. But in the present case this trick does not seem to work. I am using MATHEMATICA 10. Leslaw.

POSTED BY: Leslaw Bieniasz
4 Replies

It seems I managed to solve the problem in the same way as previously, that is by substituting z=1/s and calculating the coefficients of the ordinary Taylor series. But the necessary trick is to first divide the function by s^(3/2), to eliminate the singularity. By using the following code (version 2) I obtained 50 expansion coefficients in about 25 minutes. I still do not understand why Series[] is so much slower. Leslaw. The code:

nmax=20;
fun[s_]:=(((1+s)^2+3*s^(3/2)*(1+s)^(1/2)*th-4*s*(1+s)*th+3*s^(1/2)*(1+s)^(3/2)*th+s^2*th^2))/(8 (s^(3/2)*(1+s)^(1/2)*((1+s)^(1/2)+s^(1/2)*th)^3));
(* Version 1: calculation of the expansion coefficients using Series[] --------  *)
coeffs1=Table[Simplify[SeriesCoefficient[Series[fun[s],{s,∞,nmax}],n+1/2]],{n,0,nmax}]
(* Version 2: manual calculation of the expansion coefficients ----------------  *)
terms=Array[F,nmax+1,0];
(* Note the trick: I multiply fun by s^(3/2) because the leading expansion term is ~s^(-3/2)  *)
F[0]=Simplify[ReplaceRepeated[fun[s]*s^(3/2),{s->1/z}],Assumptions->{z>0}];
Do[F[k]=Simplify[D[F[k-1],z]],{k,1,nmax}];
Do[F[k]=(F[k]/(k!)),{k,0,nmax}];
coeffs2=Simplify[ReplaceRepeated[terms,{z->0}]]
POSTED BY: Leslaw Bieniasz
Posted 3 years ago

What do you mean by "slow" ? With 40 terms it takes about 1/4 of a second for Mathematica 10.4 (Windows 10):

AbsoluteTiming[f = Series[(8 (s^(3/2) (1 + s)^(1/2) ((1 + s)^(1/2) + s^(1/2)*th)^3)), {s, \[Infinity], 40}] // Normal;]
(* {0.27423, Null} *)
POSTED BY: Jim Baldwin

You have not copied the entire expression for F[s] (only the denominator). The expression is more complicated. For the entire expression and 40 terms I waited for about half an hour and aborted the calculations. Some nine months ago I had a similar problem with a much simpler formula, and then I had to wait in vain for three days (in a batch mode) as far as I remember. A replacement of the Series[] command by a recursive calculation of successive derivatives (after converting the problem to a Taylor expansion into powers of 1/s) then reduced the timing to a minute or so. I don't know how Series[] works (I'd love to, by the way, but this seems to be a secret), but in my opinion it either does a lot of unnecessary things, or is horribly unoptimal. Leslaw

POSTED BY: Leslaw Bieniasz
Posted 3 years ago

I only used what you originally posted. You might want to look at How to post.

But I agree that current function does not play well with Series.

POSTED BY: Jim Baldwin
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract