I’m trying to solve a problem from Modern Mathematical Methods for Scientists and Engineers using Maple, specifically applying the Fokas method (Unified Transform) to the heat equation on the half-line. The problem setup matches Example 9.1 from the book.
As you can se bellow I tried to solve it on Mathematica and on Maple but the Maple graphs of Short-time behavior are noticeably different from the book's.
I tried the following code on maple. In Maple, the short-time solution $u(x,t)$ is noticeably different from the analytical solution shown in the book and from Mathematica's results. This discrepancy is especially apparent in plots of $u(x,t)$ for small times $ t \in [0.1, 0.6] $, where the Maple solution appears to be damped or shifted incorrectly.
What could be causing Maple's numerical integration of this oscillatory complex integral to diverge from the expected solution?
restart;
with(plots);
with(ColorTools);
with(LinearAlgebra);
with(Student[VectorCalculus]);
Digits := 6;
V := (k, x, t) -> -1/2*I*exp(k*x*I - k^2*t)*(1/(k - I) + 1/(k + I) - k*(1/(k^2 + I) + 1/(k^2 - I)))/Pi;
k1 := r -> r*exp(1/8*I*Pi);
k2 := r -> r*exp(7/8*I*Pi);
dk1 := r -> exp(1/8*I*Pi);
dk2 := r -> exp(7/8*I*Pi);
u1 := proc(x::numeric, t::numeric) local integrand; try integrand := r -> Re(V(k1(r), x, t)*dk1(r) - V(k2(r), x, t)*dk2(r)); evalf(Int(integrand(r), r = 0 .. 200, epsilon = 0.1e-7, method = _Gquad)); catch: 0; end try; end proc;
approx_u := proc(x::numeric, t::numeric) evalf(exp(-x/sqrt(2))*cos(t - x/sqrt(2)) + u1(x, t)); end proc;
surf := plot3d((x, t) -> approx_u(x, t), 0 .. 3, 0 .. (Student[VectorCalculus]):-`*`(2, Pi), grid = [40, 40], axes = boxed, labels = ["x", "t", "u(x,t)"], title = "Fokas Method Solution of Half-Line Heat Equation", shading = zhue);
[seq(approx_u(0, t), t = 0. .. 0.6, 0.1)];
p1 := plot(x -> approx_u(x, 0.1), 0 .. 2, color = red);
p2 := plot(x -> approx_u(x, 0.2), 0 .. 2, color = green);
p3 := plot(x -> approx_u(x, 0.3), 0 .. 2, color = blue);
p4 := plot(x -> approx_u(x, 0.4), 0 .. 2, color = magenta);
p5 := plot(x -> approx_u(x, 0.5), 0 .. 2, color = RGB(1.0, 0.5, 0.));
p6 := plot(x -> approx_u(x, 0.6), 0 .. 2, color = cyan);
p0 := plot(exp(-x), x = 0 .. 2, linestyle = dash, color = black);
display([p0, p1, p2, p3, p4, p5, p6], legend = ["u(x,0)", "t=0.1", "t=0.2", "t=0.3", "t=0.4", "t=0.5", "t=0.6"], legendstyle = [location = right, font = [Helvetica, 12]], view = [0 .. 2, 0 .. 1.2], labels = ["x", "u(x,t)"], labelfont = [Helvetica, 12], axes = boxed, title = "Short-Time Behavior of u(x,t)");
Then I tried to solve the same problem on mathematica
(*Clear previous definitions*)ClearAll["Global`*"]
(*Define the kernel function for u1 and u2*)
V[k_, x_,
t_] := -I/(2 Pi) Exp[
I k x - k^2 t]*((1/(k - I) + 1/(k + I)) -
k*(1/(k^2 + I) + 1/(k^2 - I)))
(* =========RAY CONTOUR METHOD=========*)(*Define rays*)
k1[r_] := r Exp[I Pi/8];
k2[r_] := r Exp[I 7 Pi/8];
dk1[r_] := Exp[I Pi/8];
dk2[r_] := Exp[I 7 Pi/8];
(*u1 from ray contour*)
u1ray[x_?NumericQ, t_?NumericQ] :=
NIntegrate[
Re[V[k1[r], x, t]*dk1[r] - V[k2[r], x, t]*dk2[r]], {r, 0, Infinity},
AccuracyGoal -> 6, PrecisionGoal -> 6]
(*u2 from residue formula (exact)*)
u2ray[x_, t_] := Exp[-x/Sqrt[2]]*Cos[t - x/Sqrt[2]]
(*Full solution from ray method*)
uRay[x_?NumericQ, t_?NumericQ] := u1ray[x, t] + u2ray[x, t];
(*Plot full solution using ray contour*)Plot3D[
uRay[x, t], {x, 0.1, 3}, {t, 0.1, 2 Pi}, PlotPoints -> 40,
Mesh -> None, PlotLabel -> "Full Solution via Ray Contour",
AxesLabel -> {"x", "t", "u(x,t)"}]
Table[uRay[0, t], {t, 0, 0.6, 0.1}]
With[{times = {0.1, 0.2, 0.3, 0.4, 0.5, 0.6},
styles = ColorData[97, "ColorList"]},
Plot[Evaluate[Join[Table[uRay[x, t], {t, times}], {uRay[x, 0]}]], {x,
0, 2}, PlotStyle ->
Join[styles[[;; Length[times]]], {{Black, Dashed}}],
PlotLegends ->
LineLegend[Join[Table["t = " <> ToString[t], {t, times}], {"t = 0"}],
LegendLabel -> "Short-Time Behavior"], AxesLabel -> {"x", "u(x,t)"},
PlotLabel -> "Short-Time Behavior of u(x,t)"]]```







