I am trying to evaluate a code of the Power Series Solution method to get the results. Also, the time of evaluation depends on the parameters I am using. When the iteration point is 50, 60, or 80, it takes less time(10 mins to 1 hour) than when the iteration point is 100 or 120(like two to three days). So is there any code that makes it faster to get the result? Here is an example. When I am giving the iteration value 100, it takes two days whereas in the case of 40, 50, or 80 it takes 15-20 mins, and for smaller values of $qE$ it takes very large time.
g[x_] = (1 +
1/(4 a^4) (8 a^2 (a z - Log[1 + a z]) + (-2 a^2 + qE^2 +
qM^2) (a z (6 - a z) + 2 (-3 - 2 a z + a^2 z^2) Log[1 + a z] +
2 Log[1 + a z]^2) +
2 a^2 (a z (4 - a z) + 2 Log[z] (a z (-2 + a z) + 2 Log[1 + a z]) +
4 PolyLog[2, -a z])) -
1/(a zh (-2 + a zh) +
2 Log[1 + a zh]) (a z (-2 + a z) + 2 Log[1 + a z]) (1 +
1/(4 a^4) (8 a^2 (a zh - Log[1 + a zh]) + (-2 a^2 + qE^2 +
qM^2) (a zh (6 - a zh) +
2 (-3 - 2 a zh + a^2 zh^2) Log[1 + a zh] +
2 Log[1 + a zh]^2) +
2 a^2 (a zh (4 - a zh) +
2 Log[zh] (a zh (-2 + a zh) + 2 Log[1 + a zh]) +
4 PolyLog[2, -a zh])))) /. z -> x /. zh -> xh;
A[x_] = -Log[1 + a x];
F[x_] = g[x]/x^2;
G[x_] = g[x]/(x^2 Exp[2 A[x]])
(* (1/(x^2))(1 + a x)^2 (1 + (
8 a^2 (a x - Log[1 + a x]) + (-2 a^2 + qE^2 + qM^2) (a x (6 - a x) +
2 (-3 - 2 a x + a^2 x^2) Log[1 + a x] + 2 Log[1 + a x]^2) +
2 a^2 (a x (4 - a x) + 2 Log[x] (a x (-2 + a x) + 2 Log[1 + a x]) +
4 PolyLog[2, -a x]))/(
4 a^4) - ((a x (-2 + a x) + 2 Log[1 + a x]) (1 + (
8 a^2 (a xh - Log[1 + a xh]) + (-2 a^2 + qE^2 +
qM^2) (a xh (6 - a xh) + 2 (-3 - 2 a xh + a^2 xh^2) Log[1 + a xh] +
2 Log[1 + a xh]^2) +
2 a^2 (a xh (4 - a xh) +
2 Log[xh] (a xh (-2 + a xh) + 2 Log[1 + a xh]) +
4 PolyLog[2, -a xh]))/(4 a^4)))/(a xh (-2 + a xh) + 2 Log[1 + a xh])
) *)
Scoeff = -((x^4 G[x])/(x - xh));
Scoeffa0 = Series[Scoeff, {a, 0, 0}] // Normal
(* -((x^2 (-4 x^2 - 4 x xh - 4 xh^2 - 4 x^2 xh^2 + qE^2 x^3 xh^3 +
qM^2 x^3 xh^3))/(4 xh^3)) *)
Clear[xh]
Scoeffa0 /. qE -> 0 /. qM -> 0 // Expand
(* x^4/xh^3 + x^3/xh^2 + x^2/xh + x^4/xh *)
tcoeff = -2 x^3 G[x] - 2 I x^2 ω Sqrt[G[x]/F[x]] - (
x^4 G[x] Derivative[1][F][x])/(2 F[x]) - 1/2 x^4 Derivative[1][G][x];
tcoeffa0 = Series[tcoeff, {a, 0, 0}] // Normal // Expand
(* -2 x^3 - qE^2 x^5 - qM^2 x^5 + (3 x^4)/xh^3 + (3 x^4)/xh + 3/4 qE^2 x^4 xh + 3/4 qM^2 x^4 xh - 2 I x^2 ω *)
ucoeff = L x^3 + L^2 x^3 - L x^2 xh - L^2 x^2 xh - (
x^4 G[x] Derivative[1][F][x])/(2 F[x]) + (
x^3 xh G[x] Derivative[1][F][x])/(2 F[x]) - 1/2 x^4 Derivative[1][G][x] +
1/2 x^3 xh Derivative[1][G][x] // Simplify;
ucoeffa0 = Series[ucoeff, {a, 0, 0}] // Normal // Expand;
QNM Calculation
Clear[qE, qM, s, t, u, Sn, Tn, Un, P, aa, ex, expressao, rh, xh]
L = 0;
qM = 0;
qE = 5;
(*a=0.01;*)
rh = 2; xh = 1/rh;
s[x_] = Scoeffa0 // Simplify
t[x_, ω_] = tcoeffa0 // Simplify
u[x_] = ucoeffa0 // Simplify
(*
1/4 x^2 (8 + 16 x + 40 x^2 - 25 x^3)
-2 x^3 + (315 x^4)/8 - 25 x^5 - 2 I x^2 ω
-1 + 2 x - (105 x^3)/16 + (155 x^4)/8 - (25 x^5)/2 *)
Sn = Function[n, SeriesCoefficient[Series[s[x], {x, xh, n}], n]];
Tn = Function[n, SeriesCoefficient[Series[t[x, ω], {x, xh, n}], n]];
Un = Function[n, SeriesCoefficient[Series[u[x], {x, xh, n}], n]];
P = Function[{n, ω}, n (n - 1) Sn[0] + n Tn[0]];
Clear[aa, Nit, ex]
aa[0] = 1;
Nit = 100;
aa[n_] :=
aa[n] = Simplify[-1/
P[n, ω] Sum[(k (k - 1) Sn[n - k] + k Tn[n - k] + Un[n - k]) aa[
k], {k, 0, n - 1}]];
ex[n_] := ex[n] = Sum[aa[i]*(-xh)^i, {i, 0, n}];
expressao := Sum[aa[i]*(-xh)^(i), {i, 0, Nit}]
QNMs = FindRoot[expressao == 0, {ω, 100 - 200*I}, AccuracyGoal -> 10][[1]][[2]]
wroots = SolveValues[expressao == 0, ω] // N```
In[]
/Out[]
means the code cannot be copied, pasted, and executed in Mma. If you remove them, you will be much more likely to get someone to examine and test your code. Further, a fairly common practice is to put output between comment markers(* ... *)
so that the output won't be executed if it is pasted into Mma. If you don't make these edits, then each person who tries to help you will have to make the edits themselves. Or they can just skip the question, whichever seems a better use of their time. $\endgroup$