Happy new year! :) Recently, I am practicing laplace transform technique for solving pdes.
In this extemely helpful post, @xzczd mentioned that "The last step is to transform the solution back, but sadly InverseLaplaceTransform can't handle tsol.".
So, I tried to numerically do inervese laplace transfrom using both built in command InversLaplaceTransform and external package GWR command, but the code is so slow. Also, the result seems not correct when comparing the answer therein.
So, where is the problem. Am i using command wrong? Below is my code. Thanks.
Remove["Global`*"] // Quiet;
<< NumericalLaplaceInversion.m;
(LaplaceTransform[x'[t],t,s])
(s LaplaceTransform[x[t],t,s]-x[0])
f[x_] = x (1 - x);
pde = D[u[t, x], {t, 2}] + D[u[t, x], {x, 4}] == 0;
ic = {u[0, x] == f@x, Derivative[1, 0][u][0, x] == 0};
bc = {u[t, 0] == 0, u[t, 1] == 0, Derivative[0, 2][u][t, 0] == 0,
Derivative[0, 2][u][t, 1] == 0};
odeUgly = LaplaceTransform[{pde, bc}, t, s] /. Rule @@@ ic;
ode = odeUgly /.
HoldPattern@LaplaceTransform[a_[t, x_], __] :> a[s, x] //
Flatten;
(s is a parameter, not a variable, no its derivatives
u[s,x]===U[x]
)
odesol = u[s, x] /. First@DSolve[ode, u[s, x], x] // Simplify;
(odesol=DSolveValue[ode,u[s,x],x]//Simplify)
uatx[x_] = Function[s, odesol // Evaluate];
(uatx[z])
(usolGWR[ti_,xi_]:=GWR[uatx[xi//Rationalize],ti]//Chop;
datGWR=Table[{x,usolGWR[0.2,x]},{x,$MachineEpsilon,1,0.1}]
ListLinePlot[datGWR,PlotRange[Rule]{{0,1},{-0.3,0.3}},Mesh->All])
usol[ti_, xi_] :=
InverseLaplaceTransform[uatx[Rationalize@xi][s], s, N@ti] // Chop;
dat = Table[{x, usol[0.2, x]}, {x, 0, 1, 0.1}] // Quiet;
ListLinePlot[dat, PlotRange -> {{0 - 0.01, 1 + 0.01}, {-0.3, 0.3}},
Mesh -> All]

DSolveValue[……]line is wrong. After transformingteqnis actually an BVP of ODE, so it should beDSolveValue[……, x]. But after the correctionDSolveValuereturns unevaluated at least in v12.3.1 (undoubtedly a bug), so, useDSolveinstead. – xzczd Jan 06 '22 at 02:29