Question: How to accelerate the calculation speed?

Plz help me! How to accelerate the calculation speed the following the program?

restart;
with(PDEtools); declare((u, W)(x, t)); KN := 10;
AFP := proc (C1, C2, C3, C4, H, KN, N) local ADM1, n, lambda, F, i, A0, A, U, W, u, L, R, NL, w, PDE1, IC1, d, Eq1, Eq2, Eq3, LI, trL, tr1, trN, Apr, AprK, trSol, Sol, AD; declare((u, W)(x, t)); ADM1 := proc (n) options operator, arrow; convert(subs(lambda = 0, value((Diff(F(Sum(lambda^i*U[i], i = 0 .. n)), `$`(lambda, n)))/factorial(n))), diff) end proc; A0[0] := F(U[0]); for n to KN do A0[n] := ADM1(n) end do; for n from 0 to KN do A[n] := convert(C1*(diff(subs({seq(U[i] = W[i](x, t), i = 0 .. KN)}, expand(subs(F(U[0]) = U[0]*exp(U[0]), A0[n]))), x)), diff)+convert(C2*subs({seq(U[i] = Diff(W[i](x, t), x), i = 0 .. KN)}, expand(subs(F(U[0]) = U[0]^2, A0[n]))), diff) end do; L := proc (w) options operator, arrow; diff(w(x, t), t) end proc; R := proc (w) options operator, arrow; C3*(diff(w(x, t), x)) end proc; NL := proc (w) options operator, arrow; C1*(diff(w(x, t)*exp(w(x, t)), t))-C2*(diff(w(x, t), x))^2 end proc; PDE1 := proc (w) options operator, arrow; L(w)-R(w) = -NL(w) end proc; IC1 := u(x, 0) = sum(2*(int(sin((d+1/2)*Pi*x/H), x = 0 .. H))*exp(-C4*(d+1/2)^2*Pi^2*t/H^2)*sin((d+1/2)*Pi*x/H)/H, d = 0 .. N); LI := proc (w) options operator, arrow; Int(w(x, t), t = 0 .. t) end proc; tr1 := u-rhs(IC1); Eq1 := LI(lhs(PDE1(u))) = LI(rhs(PDE1(u))); Eq2 := simplify(subs(lhs(Eq1) = tr1, Eq1)); trL := u = add(u[j](x, t), j = 0 .. KN); trN := LI(NL(u)) = Int(Sum(A[i], i = 0 .. KN), t = 0 .. t); Eq3 := subs(trL, lhs(Eq2)) = subs(trN, rhs(Eq2)); Apr[0] := u[0](x, t) = rhs(IC1); AprK := u[k+1](x, t) = -(Int(AD[k], t = 0 .. t)); for i from 0 to KN do Apr[i+1] := value(subs({seq(Apr[m], m = 0 .. i)}, subs({seq(W[m] = u[m], m = 0 .. i)}, subs(k = i, AD[i] = A[i], AprK)))) end do; trSol := {seq(Apr[i], i = 0 .. KN)}; value(subs(trSol, trL)) end proc;


 

Download AFP.mw

Please Wait...