Partial Differential Equations: Exact Solutions Subject to Boundary Conditions This document gives examples of Fourier series and integral transform (Laplace and Fourier) solutions to problems involving a PDE and boundary and/or initial conditions. It also describes how, for certain problems, pdsolve can automatically adjust the arbitrary functions and constants entering the solution of the partial differential equations (PDEs) such that the boundary conditions (BCs) are satisfied.
Two Examples Solved Automatically and Step-by-step
Example 1: Adjusting an Arbitrary Function _F1(...)
restart;with⁡PDEtools:
U≔diff_table⁡u⁡x,t:
A substance convecting through a tube at velocity c (for example, a radioactive decaying chemical dissolved in water) has its density u⁡x,t modeled by a convection-decay type of equation
pde1≔Ut+c⁢Ux=−λ⁢U
pde1≔c⁢∂∂xu⁡x,t+∂∂tu⁡x,t=−λ⁢u⁡x,t
where the size of λ indicates how fast the substance is decaying. In this case, the boundary condition is a generic function of x indicating the value of the density at t=0.
bc1≔evalU,t=0=φx
bc1≔u⁡x,0=φ⁡x
Step-by-step Solution
The following is an exact solution for pde1. For now, bc1 is not considered.
sol1≔pdsolve⁡pde1
sol1≔u⁡x,t=f__1⁡t⁢c−xc⁢ⅇ−λ⁢xc
Perform the following steps to find the form of the mapping of _F1 that matches bc1 when t=0.
Consider t=0.
e1≔eval⁡sol1t=0|sol1t=0,bc1
e1≔φ⁡x=f__1⁡−xc⁢ⅇ−λ⁢xc
Introduce a new variable q equal to the argument of _F1.
tr≔q=−xc;itr≔isolate⁡tr,x
tr≔q=−xc
itr≔x=−q⁢c
Evaluate at this value of x and then isolate _F1(q). The following mapping is obtained.
eval⁡e1,itr
φ⁡−q⁢c=f__1⁡q⁢ⅇλ⁢q
e2≔isolate⁡,_F1⁡q
e2≔f__1⁡q=φ⁡−q⁢cⅇλ⁢q
ans_F≔_F1=unapply⁡rhs⁡,q
ans_F≔f__1=q↦φ⁡−q⋅cⅇλ⋅q
The solution to the PDE and BC is obtained evaluating the general solution at this value of _F1.
sol1
u⁡x,t=f__1⁡c⁢t−xc⁢ⅇ−λ⁢xc
ans1≔simplify⁡eval⁡,ans_F,exp
ans1≔u⁡x,t=φ⁡−c⁢t+x⁢ⅇ−λ⁢t
Verify this result using pdetest.
pdetest⁡ans1,pde1,bc1
0,0
Summary: The system of PDEs and BCs is
sys1≔pde1,bc1
sys1≔c⁢∂∂xu⁡x,t+∂∂tu⁡x,t=−λ⁢u⁡x,t,u⁡x,0=φ⁡x
The following is the solution computed by pdsolve automatically by performing the steps explained in the Step-by-step Solution section above.
pdsolve⁡sys1
u⁡x,t=φ⁡−c⁢t+x⁢ⅇ−λ⁢t
The approach used in this example serves also to address nonlinear equations of the form ∂∂t⁢u⁡x,t+c⁢∂∂x⁢u⁡x,t=Φ⁡x,t,u⁡x,t
Example 2: Periodic Boundary Conditions
Consider the heat equation that models the temperature u⁡x,t
pde2≔Ut=κ⁢Ux,x
pde2≔∂∂tu⁡x,t=κ⁢∂2∂x2u⁡x,t
where κ is any constant of proportionality.
Assume that the boundary conditions at x=0 and x=L are as follows:
bc2≔u⁡0,t=0,u⁡L,t=0
Similar to Example 1, the following is a solution for pde2. For now, bc2 is not considered.
sol2≔pdsolve⁡pde2,build
sol2≔u⁡x,t=c__3⁢ⅇκ⁢_c1⁢t⁢c__1⁢ⅇ_c1⁢x+c__3⁢ⅇκ⁢_c1⁢t⁢c__2ⅇ_c1⁢x
This time, pdsolve computes a complete (that is, not the most general) solution using separation of variables. The solution appears in terms of arbitrary constants _C1,_C2,_C3 and the separation variable _c1.
The integration constants can be redefined to absorb _C3:
zz≔_C1=_C1_C3,_C2=_C2_C3
zz≔c__1=c__1c__3,c__2=c__2c__3
Now, evaluate the solution at x=0 and x=L and impose the given boundary conditions to build a system (e1 and e2, so two equations) to be solved for these three constants.
e1≔eval⁡eval⁡sol2x=0|sol2x=0,bc21,zz
e1≔0=c__1⁢ⅇκ⁢_c1⁢t+ⅇκ⁢_c1⁢t⁢c__2
e2≔eval⁡eval⁡sol2x=L|sol2x=L,bc22,zz
e2≔0=ⅇκ⁢_c1⁢t⁢c__1⁢ⅇ_c1⁢L+ⅇκ⁢_c1⁢t⁢c__2ⅇ_c1⁢L
Solve for the constants.
_EnvAllSolutions≔true
solve⁡e1,e2,_C1,_C2,_c1
c__1=0,c__2=0,_c1=_c1,c__1=−c__2,c__2=c__2,_c1=−π2⁢_Z1~2L2
The first solution above leads to a solution of no interest: u⁡x,t=0. The second solution above is the one we want.
ans2≔eval⁡sol2,2
ans2≔u⁡x,t=−c__3⁢ⅇ−κ⁢π2⁢_Z1~2⁢tL2⁢c__2⁢ⅇ−π2⁢_Z1~2L2⁢x+c__3⁢ⅇ−κ⁢π2⁢_Z1~2⁢tL2⁢c__2ⅇ−π2⁢_Z1~2L2⁢x
Here pdetest verifies the answer for pde[2] and the first boundary condition, but fails with the second one.
pdetest⁡ans2,pde2,bc2
0,0,−c__2⁢c__3⁢ⅇ2⁢π⁢−1L2⁢L⁢_Z1~−1⁢ⅇ−π⁢_Z1~⁢L3⁢−1L2⁢signum⁡_Z1~+π⁢_Z1~⁢κ⁢tL2
However, the answer computed is correct. The second boundary condition can be constructed by evaluating the answer at x=L. This task can be performed within pdetest.
simplify⁡ans2x=L|ans2x=LassumingL::real
u⁡L,t=0
Summary: The system with periodic boundary conditions is
sys2≔pde2,bc2
sys2≔∂∂tu⁡x,t=κ⁢∂2∂x2u⁡x,t,u⁡0,t=0,u⁡L,t=0
The solution computed by pdsolve automatically by performing the steps summarized in the Step-by-step Solution section above:
pdsolve⁡sys2
u⁡x,t=∑n=1∞⁡csgn⁡1L⁢sin⁡n⁢π⁢xL⁢ⅇ−κ⁢π2⁢n2⁢tL2⁢f__1⁡n
pdetest⁡,sys2
0,0,0
Notes on this PDE and Initial Values / Boundary Conditions Problem
Given a problem with PDEs and some BCs, note the following:
Depending on how you write a general PDE solution, it becomes possible or nearly impossible to adjust it to match the BCs.
Certain particular PDE solutions are frequently easier to adjust than general solutions.
Some combinations, classified in the literature, of "certain types of PDEs" with "certain type of BCs" can be solved systematically by writing the PDE solution in a special form.
By passing PDEs alone to pdsolve, it is not possible to predict the form of the PDE solution. On the other hand, pdsolve accepts a HINT argument so that solutions of a "certain type" can be requested.
Three Textbook Examples
A bar loses heat across its lateral boundary at a rate proportional to the temperature u⁡x,t and its BCs state that the temperature at the two ends of the bar are equal to 1.
This problem is modeled by the following equation.
restart
sys3≔∂∂tu⁡x,t=k⁢∂2∂x2u⁡x,t−a⁢u⁡x,t,u⁡0,t=1,u⁡1,t=1
pdsolve⁡sys3
u⁡x,t=ⅇak+1⁢∑n=1∞⁡f__1⁡n⁢ⅇ−t⁢π2⁢k⁢n2+a⁢sin⁡n⁢π⁢x+ⅇa⁢xk+ⅇ−a⁢x−1kⅇak+1
pdetest⁡,sys3
The following is a textbook example where the solution is computed by constructing an infinite series and then reversed using the boundary conditions to compute a closed formula for the coefficients of the series. The three boundary conditions specify the value of u⁡x,t at two points (values of x) and at t=0 as a generic function f⁡x.
sys4≔∂∂tu⁡x,t=k⁢∂2∂x2u⁡x,t,u⁡0,t=0,u⁡λ,t=0,u⁡x,0=f⁡x
pdsolve⁡sys4
u⁡x,t=2⁢∑n=1∞⁡sin⁡n⁢π⁢xλ⁢ⅇ−π2⁢n2⁢k⁢tλ2⁢∫0λf⁡x⁢sin⁡n⁢π⁢xλⅆxλ
The following is the wave equation with conditions at t=0 for u⁡x,t and its time derivative ∂∂t⁢u⁡x,t, as well as conditions at the boundaries x = 0 and x = 1:
sys5≔∂2∂t2u⁡x,t=116⁢∂2∂x2u⁡x,t−15⁢∂∂tu⁡x,t,u⁡0,t=0,u⁡1,t=0,u⁡x,0=x⁢1−x,D2⁡u⁡x,0=x⁢1−x
sys5≔∂2∂t2u⁡x,t=∂2∂x2u⁡x,t16−∂∂tu⁡x,t5,u⁡0,t=0,u⁡1,t=0,u⁡x,0=x⁢1−x,D2⁡u⁡x,0=x⁢1−x
pdsolve⁡sys5
u⁡x,t=∑n=1∞⁡−44⁢−1n−1⁢I+25⁢π2⁢n2−422⁢ⅇ−2+I⁢25⁢π2⁢n2−4⁢t20−ⅇ−2+I⁢25⁢π2⁢n2−4⁢t20⁢I−25⁢π2⁢n2−422⁢sin⁡n⁢π⁢x25⁢π2⁢n2−4⁢n3⁢π3
pdetest⁡,sys5
0,0,0,−4⁢∑n=1∞⁡−1n−1⁢sin⁡n⁢π⁢xn3π3+x2−x,−4⁢∑n=1∞⁡−1n−1⁢sin⁡n⁢π⁢xn3π3+x2−x
To verify the conditions at t = 0 which pdetest is unable to check, we use plots.
First, we plot together the solution at t = 0 (1000 terms) and the quadratic expression x⋅1−x and see that they are identical:
plot⁡subs⁡infinity=1000,t=0,rhs,x⁢1−x,x=0..1
Then, we plot together the derivative of the solution at t = 0 (1000 terms) and the quadratic expression x⋅1−x and see that they are identical:
plot⁡subs⁡infinity=1000,t=0,∂∂trhs,x⁢1−x,x=0..1
More Examples
Set infolevel = 2 to receive information on the method used.
infolevelpdsolve≔2
pde1≔∂2∂x2u⁡x,t−∂2∂t2u⁡x,tc2=0;iv1≔u⁡x,0=f⁡x,D2⁡u⁡x,0=g⁡x;pdsolve⁡pde1,iv1
pde1≔∂2∂x2u⁡x,t−∂2∂t2u⁡x,tc2=0
iv1≔u⁡x,0=f⁡x,D2⁡u⁡x,0=g⁡x
* trying method "SpecializeArbitraryFunctions" for 2nd order PDEs
-> trying "LinearInXT"
<- submethod "LinearInXT" successful
<- method "SpecializeArbitraryFunctions" for 2nd order PDEs successful
u⁡x,t=∫−c⁢t+xc⁢t+xg⁡x1ⅆx12⁢c+f⁡−c⁢t+x2+f⁡c⁢t+x2
pde2≔∂∂tu⁡x,t=k⁢∂2∂x2u⁡x,t;iv2≔u⁡x,0=x;pdsolve⁡pde2,iv2
pde2≔∂∂tu⁡x,t=k⁢∂2∂x2u⁡x,t
iv2≔u⁡x,0=x
* trying method "SpecializeArbitraryConstants" for 2nd order PDEs
* trying method "Wave" for 2nd order PDEs
-> trying "Cauchy"
-> trying "SemiInfiniteDomain"
-> trying "WithSourceTerm"
* trying method "Heat" for 2nd order PDEs
* trying method "Series" for 2nd order PDEs
-> trying "TwoBC"
-> trying "ThreeBCsincos"
-> trying "FourBC"
-> trying "ThreeBC"
-> trying "ThreeBCPeriodic"
-> trying "ThreeVariables"
-> trying adding missing boundary conditions
* trying method "Laplace" for 2nd order PDEs
-> trying a Laplace transformation
* trying method "Fourier" for 2nd order PDEs
-> trying a fourier transformation
<- fourier transformation successful
<- method "Fourier" for 2nd order PDEs successful
u⁡x,t=x
with⁡inttrans,fourier,invfourier
fourier,invfourier
iv2.1≔u⁡x,0=φ⁡x;ans2.1≔pdsolve⁡pde2,iv2.1
iv2.1≔u⁡x,0=φ⁡x
ans2.1≔u⁡x,t=ℱ−1⁡ℱ⁡φ⁡x,x,s⁢ⅇ−k⁢s2⁢t,s,x
ans2.1φ⁡x=x7|ans2.1φ⁡x=x7
u⁡x,t=ℱ−1⁡ℱ⁡φ⁡x,x,sφ⁡x=x7|ℱ⁡φ⁡x,x,sφ⁡x=x7⁢ⅇ−k⁢s2⁢t,s,x
pdetest⁡,pde2,iv2.1φ⁡x=x7|iv2.1φ⁡x=x7
k⁢−2⁢I⁢ℱ−1⁡s⁢∂∂xℱ⁡φ⁡x,x,sφ⁡x=x7|ℱ⁡φ⁡x,x,sφ⁡x=x7⁢ⅇ−k⁢s2⁢t,s,x−ℱ−1⁡∂2∂x2ℱ⁡φ⁡x,x,sφ⁡x=x7|ℱ⁡φ⁡x,x,sφ⁡x=x7⁢ⅇ−k⁢s2⁢t,s,x,ℱ−1⁡ℱ⁡φ⁡x,x,sφ⁡x=x7|ℱ⁡φ⁡x,x,sφ⁡x=x7,s,x−x7
convert⁡ans2.1,Int
u⁡x,t=∫−∞∞∫−∞∞φ⁡x⁢ⅇ−I⁢x⁢sⅆx⁢ⅇ−k⁢s2⁢t+I⁢s⁢xⅆs2⁢π
pde3≔∂∂tu⁡x,t=k⁢∂2∂x2u⁡x,t;iv3≔u⁡x,0=μ,u⁡0,t=λ;pdsolve⁡pde3,iv3
pde3≔∂∂tu⁡x,t=k⁢∂2∂x2u⁡x,t
iv3≔u⁡x,0=μ,u⁡0,t=λ
-> trying "NonhomogeneousBC"
<- Laplace transformation successful
<- method "Laplace" for 2nd order PDEs successful
<- submethod "NonhomogeneousBC" successful
<- submethod "WithSourceTerm" successful
<- method "Series" for 2nd order PDEs successful
u⁡x,t=λ−μ⁢ℒ−1⁡1ⅇk⁢s⁢xk⁢s,s,t+μ
pde4≔∂2∂x2u⁡x,t−∂2∂t2u⁡x,tc2=0;iv4≔u⁡x,0=f⁡x,D2⁡u⁡x,0=g⁡x,u⁡0,t=0;pdsolve⁡pde4,iv4assuming0<x,0<t
pde4≔∂2∂x2u⁡x,t−∂2∂t2u⁡x,tc2=0
iv4≔u⁡x,0=f⁡x,D2⁡u⁡x,0=g⁡x,u⁡0,t=0
<- submethod "SemiInfiniteDomain" successful
<- method "Wave" for 2nd order PDEs successful
u⁡x,t=f⁡c⁢t+x−f⁡c⁢t−x+∫c⁢t−xc⁢t+xg⁡ζⅆζcx<c⁢tf⁡c⁢t+x+f⁡−c⁢t+x+∫−c⁢t+xc⁢t+xg⁡ζⅆζcc⁢t<x2
pde5≔∂2∂t2u⁡x,t−c2⁢∂2∂x2u⁡x,t=f⁡x,t;iv5≔u⁡0,t=0,D1⁡u⁡0,t=0;pdsolve⁡pde5,iv5
pde5≔∂2∂t2u⁡x,t−∂2∂x2u⁡x,t⁢c2=f⁡x,t
iv5≔u⁡0,t=0,D1⁡u⁡0,t=0
u⁡x,t=∫0x∫t−x−τct+x−τc−f⁡τ,ζ2⁢cⅆζⅆτ
pde6≔∂∂tu⁡x,t=u⁡x,t⁢∂2∂x2u⁡x,t;iv6≔u⁡0,t=0,u⁡l,t=0;pdsolve⁡pde6,iv6
pde6≔∂∂tu⁡x,t=u⁡x,t⁢∂2∂x2u⁡x,t
iv6≔u⁡0,t=0,u⁡l,t=0
-> trying SpecializeArbitraryConstants
<- trying SpecializeArbitraryConstants successful
<- method "SpecializeArbitraryConstants" for 2nd order PDEs successful
u⁡x,t=_c1⁢x⁢−x+l2⁢_c1⁢t−2⁢c__3
pdetest⁡,pde6,iv6
See Also
pdetest, pdsolve
Return to Index of Example Worksheets
Download Help Document