We study the one-dimensional heat conduction equation on the half-line, subject to Dirichlet boundary conditions:
u
t

u
xx
,0<x<∞,t>0
(
1
)
u(x,0)
-x
e
,0<x<∞
(
2
)
u(0,t)cos(t),t>0
(
3
)
We compute the Fourier transform of
u
0
(x)
-x
e
on the half-line

u
(λ)
1
1+iλ
and
g
0
(t)cos(t)

g
0
(λ,t)
1
2
(λ+i)t
e
-1
λ+i
+
(λ-i)t
e
-1
λ-i
The contour
+
C
can be any curve between the real axis and the
∂
+
D
.
We choose the following trapezoidal contour
+
C
Thus, the solution reduces to:
u(x,t)
1
2π
∫
+
C
iλx-
2
λ
t
e

1
1+iλ
+
1
iλ-1
+iλ
1
2
λ
+i
+
1
2
λ
-i
λ.
To better understand the temporal evolution of the solution
u(x,t)
, we numerically evaluated and plotted the function for various values of
t
using the trapezoidal contour implementation.
Define the complex-valued function V(k,x,t)
v[k_,x_,t_]:=-I*1/2*Exp[I*k*x-k^2*t]*(1/(k-I)+1/(k+I)-k*(1/(k^2+I)+1/(k^2-I)))/Pi
Set L value
l=3/4;
Define the three contours k1,k2,k3
k1[r_]:=l+(3/4)*I+r*Exp[I*Pi/6];​​k2[r_]:=-l+(3/4)*I+r*Exp[I*5*Pi/6];​​k3[s_]:=s+(3/4)*I;
Derivatives of the contours
dk1[r_]:=D[k1[r],r];​​dk2[r_]:=D[k2[r],r];​​dk3[s_]:=D[k3[s],s];
Define the approxU function with NumericQ guards
approxU[x_?NumericQ,t_?NumericQ]:=Module[{temp1,temp2},temp1=NIntegrate[Re[v[k1[r],x,t]*dk1[r]-v[k2[r],x,t]*dk2[r]],{r,0,Infinity},AccuracyGoal->6,PrecisionGoal->6,MaxRecursion->20];​​temp2=NIntegrate[Re[v[k3[s],x,t]*dk3[s]],{s,-l,l},AccuracyGoal->6,PrecisionGoal->6,MaxRecursion->20];​​temp1+temp2]
Example: Evaluate at a point
approxU[0.5,0.1]
Out[]=
0.658113
Step 4: Plot the 3D surface
Plot3D[approxU[x,t],{x,0,3},{t,0,2Pi},AxesLabel->{"x","t","u(x,t)"},PlotLabel->"Fokas Method Solution of Half-Line Heat Equation",Mesh->None]
Out[]=
In[]:=
Table[approxU[0,t],{t,0,0.6,0.1}]
Out[]=
{1.,0.995004,0.980067,0.955336,0.921061,0.877583,0.825336}
With[{times={0.1,0.2,0.3,0.4,0.5,0.6},styles=ColorData[97,"ColorList"]},Plot[Evaluate[Join[Table[approxU[x,t],{t,times}],{u[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)"]]
Out[]=
Short-Time Behavior
t = 0.1
t = 0.2
t = 0.3
t = 0.4
t = 0.5
t = 0.6
t = 0
In[]:=
With[{times={0.5,1,1.5,2,2.5,3},styles=ColorData[97,"ColorList"]},Plot[Evaluate[Join[Table[approxU[x,t],{t,times}],{u[x,0]}(*Thisisu(x,0)*)]],{x,0,2},PlotStyle->Join[styles[[;;Length[times]]],(*applydistinctcolorpert*){{Black,Dashed}}(*styleforu(x,0)*)],PlotLegends->LineLegend[Join[Table["t = "<>ToString[t],{t,times}],{"u(x,0)"}],LegendLabel->"Long-Time Behavior"],AxesLabel->{"x","u(x,t)"},PlotLabel->"Long-Time Behavior of u(x,t)"]]
Out[]=
Long-Time Behavior
t = 0.5
t = 1
t = 1.5
t = 2
t = 2.5
t = 3
u(x,0)

CITE THIS NOTEBOOK

Application of the unified transform (Fokas method) to the one-dimensional heat equation on the half line​
by Athanasios Paraskevopoulos​
Wolfram Community, STAFF PICKS, December 23, 2025
​https://community.wolfram.com/groups/-/m/t/3595944