Message Boards Message Boards

1
|
5247 Views
|
10 Replies
|
1 Total Likes
View groups...
Share
Share this post:

Speed up this series expansion?

Posted 4 years ago

Hi, I wonder why the following commands:

Fun1[s_] := (1 - BesselK[0, Sqrt[s + gam]]/BesselK[1, Sqrt[s + gam]])/(s*Sqrt[s + gam]);
ser1 = Series[Fun1[s], {s, ?, 60}]; 

are still not completed after a day of calculations on a supercomputer? Is there any way to speed up the computations? Leslaw

POSTED BY: Leslaw Bieniasz
10 Replies
nmax=5;
coeffs = Array[F, nmax, 0]; 
F[0] = (z^2 + z (1 + th))/(2 ((Sqrt[z + 1] + th)^2)); Do[
F[k] = Simplify[D[F[k - 1], z]], {k, 1, nmax}]; Do[
F[k] = F[k]/k!, {k, 0, nmax}]; 
Total@Factor[ReplaceRepeated[coeffs, {z -> 0}]]

(* th/(8 (1 + th)^3) + 1/(2 (1 + th)) - (th (3 + th))/(16 (1 + th)^4) *)

(Series[(1 + z + z th)/(2 z ((Sqrt[1 + z] + Sqrt[z] th)^2)), {z, 
       Infinity, 4}] // Simplify) // Normal
(*-((th (3 + th))/(16 (1 + th)^4 z^4)) + th/(8 (1 + th)^3 z^3) + 1/((2 + 2 th) z) *)

Thanks, works for me now.

POSTED BY: Mariusz Iwaniuk

It does work for me, but the code is incomplete. Derivatives have to be evaluated at z=0 (which corresponds to z=infinity in the original problem). Hence one can add something like Factor[ReplaceRepeated[coeffs,{z->0}]] at the end, to obtain results maximally resembling those from the Series[] command (for small nmax). Lesław

POSTED BY: Leslaw Bieniasz

Your code dosen't work for me ?

POSTED BY: Mariusz Iwaniuk

In the meantime I attempted to construct the series expansion "by hand" as follows (the replacement of variables, z->1/z is involved, and the final code includes further processing, but this is unimportant for the performance): nmax=41; coeffs=Array[F,nmax,0]; F[0]=(z^2+z(1+th))/(2((Sqrt[z+1]+th)^2)); Do[F[k]=Simplify[D[F[k-1],z]],{k,1,nmax}];Do[F[k]=F[k]/k!,{k,0,nmax}]. This produces the requested expansion coefficients in a computing time of a few minutes! It is astonishing why the Series command cannot do the same thing within 3 days! Leslaw.

POSTED BY: Leslaw Bieniasz

Maybe you post a question on mathematica.stackexchange Maybe they can help you there because I don't know how to help you.

POSTED BY: Mariusz Iwaniuk
POSTED BY: Leslaw Bieniasz

Maple result converted to Mathematica code with only 20 terms. Converting is extremely CPU and RAM intensive.

See attached file.

I send you tomorrow series with 30 terms.

Regards M.I.

EDITED: 2020-01-16

I added file: Series only 30 terms.nb .You must change file extension to *.zip and extract file.

POSTED BY: Mariusz Iwaniuk

If I choose the maximum order 5 instead of 60 in the series, it works more quickly and produces an answer, but the formulae are very complicated so that probably this is why the calculations become very slow for the 60 case. However, we had a discussion several months ago which showed that the Series commands has bugs and produces wrong answers to this or similar problems. I noticed that chosing a large maximum order at least makes the initial terms reproducible upon order variations. I need 20 correct terms, and for this requiring 60 seems necessary. I will try to replace g+s by a single variable. By the way, can you send me the Maple results? Leslaw

POSTED BY: Leslaw Bieniasz
Anonymous User
Anonymous User
Posted 4 years ago

My first guess has to be with "s+g" that Mathematica doesn't know if it is two independent variables or a variable and a constant (noting you have separate J(x) - will s or g be constant or in which?). If J is designed for only one variable and tries to "solve" (rather than use table) with two - it could easily just end up in an infinite loop somewhere trying to perform it and waiting for a result it will not get.

Is there a proof the series, using J0(s,g) as you suggest terminates? The book and page citing it?

Fun1[s_] := (1 - BesselK[0, Sqrt[x]]/BesselK[1, Sqrt[x]])/(s*Sqrt[x]);
In[19]:= Series[Fun1[s], {s, \[Infinity], 60}] // Timing

Out[19]= {0.001181, SeriesData[d`s, 
DirectedInfinity[1], {
  d`v^Rational[-1, 2] (1 - BesselK[0, d`v^Rational[1, 2]]/BesselK[
    1, d`v^Rational[1, 2]])}, 1, 61, 1]}

(Is there some reason you cannot, here, say %/.x->(g+s)) ?)

I could ask questions like whether (s*Sqrt[g+s]) ends up being a solution to another besselK but have no time - but I understand such inputs to J are common after converting an ODE to a bessel form ODE by substitution.

I wonder at times why Mathematica doesn't seem to use a larger "table of equations" solutions to produce what (doesn't need to be solved because it's in a table). on the other hand i know some sol'n by mm are by table - but the tables seem to be "brief" when working in certain areas (where try to constrain variables doesn't seem to find more applicable sol'n).

POSTED BY: Anonymous User

Only comment. Comparison with Maple 2019.2.1, takes only 251.297 second.

enter image description here Regards M.I.

POSTED BY: Mariusz Iwaniuk
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