3.1.1 Finite domain (bar), Both ends homogeneous BC

3.1.1.1 [151] General initial conditions
3.1.1.2 [152] Specific initial condition
3.1.1.3 [153] IC \(u=x(1-x)\)
3.1.1.4 [154] Haberman 2.3.3 (a)
3.1.1.5 [155] IC hat function
3.1.1.6 [156] Haberman 2.3.3 (b)
3.1.1.7 [157] Haberman 2.3.3 (c)
3.1.1.8 [158] Haberman 2.3.3 (d)
3.1.1.9 [159] domain from -1 to +1
3.1.1.10 [160] domain from -1 to +1
3.1.1.11 [161] with source that depends on space only (general case)
3.1.1.12 [162] with source that depends on space only (special case)
3.1.1.13 [163] with source that depends on space and time (general case)
3.1.1.14 [164] with source that depends on space and time (special case)
3.1.1.15 [165] Math 4567 Exam
3.1.1.16 [166] With source
3.1.1.17 [167] special initial condition
3.1.1.18 [168] Diffusion Reaction and Euler-Cauchy Sturm-Liouville
3.1.1.19 [169] Diffusion Reaction. Using growth form reaction term
3.1.1.20 [170] Diffusion Reaction, using logistic form for reaction term
3.1.1.21 [171] Diffusion Reaction, using Aleee form for reaction term
3.1.1.22 [172] Diffusion Reaction. Haberman 2.3.8
3.1.1.23 [173] Diffusion Reaction
3.1.1.24 [174] Diffusion Reaction
3.1.1.25 [175] Diffusion Reaction
3.1.1.26 [176] Diffusion convection (general case)
3.1.1.27 [177] Diffusion convection (special case)
3.1.1.28 [178] Haberman 2.4.2 (general case)
3.1.1.29 [179] Left end zero, right end insulated, no source
3.1.1.30 [180] One end insulated
3.1.1.31 [181] Haberman 2.3.7 (general case)
3.1.1.32 [182] specific case
3.1.1.33 [183] Haberman 2.4.1 (a)
3.1.1.34 [184] Both ends insulated, no source
3.1.1.35 [185] Haberman 2.4.1 (b) (special case)
3.1.1.36 [186] Haberman 2.4.1 (c) (special case)
3.1.1.37 [187] Haberman 2.4.1 (d)
3.1.1.38 [188] both ends insulated
3.1.1.39 [189] convection heat loss
3.1.1.40 [190] Pinchover and Rubinstein 6.25
3.1.1.41 [191] external source
3.1.1.42 [192] Diffusion Reaction (general case)
3.1.1.43 [193] Pinchover and Rubinstein 6.23
3.1.1.44 [194] Pinchover and Rubinstein 6.21
3.1.1.45 [195] Diffusion Reaction. Euler-Cauchy Sturm-Liouville
3.1.1.46 [196] convection heat loss
3.1.1.47 [197] Mixed BC
3.1.1.48 [198] Haberman 8.2.1 (f)

3.1.1.1 [151] General initial conditions

problem number 151

Added June 9, 2019

Solve the heat equation \[ u_t = u_{xx} \] For \(0<x<L\) and \(t>0\). The boundary conditions are \begin {align*} u(0,t) &= 0 \\ u(L,t) &= 0 \end {align*}

Initial condition is \(u(x,0)=f(x)\)

Mathematica

ClearAll["Global`*"]; 
pde =  D[u[x, t], t] == k*D[u[x, t], {x, 2}]; 
bc  = {u[0, t] == 0, u[L, t] == 0}; 
ic  = u[x, 0] == f[x]; 
sol =  AbsoluteTiming[TimeConstrained[DSolve[{pde, ic, bc}, u[x, t], {x, t},Assumptions->{k>0,L>0}], 60*10]]; 
sol =  sol /. {K[1] -> n}
 

\[\left \{\left \{u(x,t)\to \sum _{n=1}^{\infty }\frac {2 e^{-\frac {k n^2 \pi ^2 t}{L^2}} \left (\int _0^L f(x) \sin \left (\frac {n \pi x}{L}\right ) \, dx\right ) \sin \left (\frac {n \pi x}{L}\right )}{L}\right \}\right \}\]

Maple

restart; 
pde := diff(u(x,t), t) = k*diff(u(x,t), x, x); 
bc  := u(0,t) = 0, u(L,t) = 0; 
ic  := u(x,0) = f(x); 
cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol', pdsolve([pde, ic, bc],u(x,t)) assuming k>0,L>0),output='realtime'));
 

\[u \left ( x,t \right ) =\sum _{n=1}^{\infty } \left ( 2\,{\frac {1}{L}\sin \left ( {\frac {n\pi \,x}{L}} \right ) {{\rm e}^{-{\frac {{\pi }^{2}{n}^{2}kt}{{L}^{2}}}}}\int _{0}^{L}\!f \left ( x \right ) \sin \left ( {\frac {n\pi \,x}{L}} \right ) \,{\rm d}x} \right ) \]

Hand solution

Solve

\[ u_{t}=ku_{xx}\] BC\begin {align*} u\left ( 0,t\right ) & =0\qquad t>0\\ u\left ( L,t\right ) & =0\qquad t>0 \end {align*}

Initial conditions\[ u\left ( x,0\right ) =f\left ( x\right ) \qquad 0<x<L \] Solution

Using separation of variables, let \(u\left ( x,t\right ) =X\left ( x\right ) T\left ( t\right ) \). Substituting this back into the PDE gives\begin {align*} T^{\prime }X & =kX^{\prime \prime }T\\ \frac {1}{k}\frac {T^{\prime }}{T} & =\frac {X^{\prime \prime }}{X}=-\lambda \end {align*}

Where the separation constant is some real value \(-\lambda \). This gives the following two ODE’s to solve\begin {align} T^{\prime }+\lambda kT & =0\tag {1}\\ X^{\prime \prime }+\lambda X & =0 \tag {2} \end {align}

Starting with the spatial ODE in order to obtain the eigenvalues and eigenfunctions. The boundary conditions on the spatial ODE become\begin {align*} X\left ( 0\right ) & =0\\ X\left ( L\right ) & =0 \end {align*}

There are three cases to consider, depending on if \(\lambda <0,\lambda =0,\lambda >0\). Each one of these cases give a different solution.

Case 1 Assuming \(\lambda <0\). Therefore \(-\lambda \) is positive say \(\mu \). The solution (2) can now be written as\begin {equation} X\left ( x\right ) =c_{1}\cosh \left ( \sqrt {\mu }x\right ) +c_{2}\sinh \left ( \sqrt {\mu }x\right ) \tag {3B} \end {equation} Applying left boundary conditions to (3B) gives\[ 0=c_{1}\] The solution (3B) now reduces to\[ X\left ( x\right ) =c_{2}\sinh \left ( \sqrt {\mu }x\right ) \] Applying right side boundary conditions to the above results in\[ 0=c_{2}\sinh \left ( \sqrt {\mu }L\right ) \] But \(\sinh \left ( \sqrt {\mu }L\right ) \neq 0\) since it was assumed \(\mu \) is not zero and \(\sinh \) is only zero when its argument is zero. The only possibility then is that \(c_{2}=0,\) which leads to trivial solution. Therefore \(\lambda <0\) is not an eigenvalue.

Case 2. Assuming \(\lambda =0\). The ODE becomes \(X^{\prime \prime }=0\), which has the solution \[ X\left ( x\right ) =c_{1}x+c_{2}\] Applying left side B.C. gives\[ 0=c_{2}\] The solution now reduces to \[ X\left ( x\right ) =c_{1}x \] Applying right side B.C. gives\[ 0=c_{1}L \] Leading to the trivial solution. Therefore \(\lambda =0\) is not an eigenvalue.

Case 3 Assuming \(\lambda >0\). In this case equation \(\sqrt {-\lambda }\) is complex and solution to equation (2) can be expressed in terms of trig functions using Euler relation which results in\begin {equation} X\left ( x\right ) =c_{1}\cos \left ( \sqrt {\lambda }x\right ) +c_{2}\sin \left ( \sqrt {\lambda }x\right ) \tag {4} \end {equation} Applying left side B.C. gives\[ 0=c_{1}\] Solution (4) now reduces to\begin {equation} X\left ( x\right ) =C_{2}\sin \left ( \sqrt {\lambda }x\right ) \tag {5} \end {equation} Applying right side B.C. gives\[ 0=C_{2}\sin \left ( \sqrt {\lambda }L\right ) \] Non-trivial solution implies \(\sin \left ( \sqrt {\lambda }L\right ) =0\) or \(\sqrt {\lambda }L=n\pi \) for \(n=1,2,3,\cdots \). Therefore the eigenvalues are\[ \lambda _{n}=\left ( \frac {n\pi }{L}\right ) ^{2}\qquad n=1,2,3,\cdots \] And the corresponding eigenfunctions from (5) are\begin {equation} X_{n}\left ( x\right ) =C_{n}\sin \left ( \sqrt {\lambda _{n}}x\right ) \tag {6} \end {equation} Now that the eigenvalues are known, the solution to the time ODE (1) can be found.\[ T^{\prime }+\lambda _{n}kT=0 \] This has the solution (using an integrating factor method)\begin {equation} T_{n}\left ( t\right ) =e^{-\lambda _{n}kt} \tag {7} \end {equation} The constant of integration is not needed for (7) since it will be absorbed with the constant of integration coming from solution of the spatial ODE (6) when these solutions are multiplied with each others below. Therefore the fundamental solution is\[ u_{n}\left ( x,t\right ) =T_{n}\left ( t\right ) X_{n}\left ( x\right ) \] Linear combination of fundamental solutions is also a solution (since this is a linear PDE). Therefore the general solution is given by\begin {align} u\left ( x,t\right ) & =\sum _{n=1}^{\infty }u_{n}\nonumber \\ & =\sum _{n=1}^{\infty }T_{n}\left ( t\right ) X_{n}\left ( x\right ) \nonumber \\ & =\sum _{n=1}^{\infty }C_{n}e^{-k\lambda _{n}t}\sin \left ( \sqrt {\lambda _{n}}x\right ) \tag {8} \end {align}

The initial condition is now used to determine \(c_{n}\), . At \(t=0\), \(u\left ( x,0\right ) =f\left ( x\right ) \) and the above becomes\[ f\left ( x\right ) =\sum _{n=1}^{\infty }C_{n}\sin \left ( \sqrt {\lambda _{n}}x\right ) \] Multiplying both sides of the above equation by eigenfunction \(\sin \left ( \sqrt {\lambda _{m}}x\right ) \) and integrating over the domain of \(f\left ( x\right ) \) gives\[ \int _{0}^{L}f\left ( x\right ) \sin \left ( \sqrt {\lambda _{m}}x\right ) dx=\int _{0}^{L}\sum _{n=1}^{\infty }C_{n}\sin \left ( \sqrt {\lambda _{n}}x\right ) \sin \left ( \sqrt {\lambda _{m}}x\right ) dx \] Interchanging the order of summation and integration gives\[ \int _{0}^{L}f\left ( x\right ) \sin \left ( \sqrt {\lambda _{m}}x\right ) dx=\sum _{n=1}^{\infty }C_{n}\int _{0}^{L}\sin \left ( \sqrt {\lambda _{n}}x\right ) \sin \left ( \sqrt {\lambda _{m}}x\right ) dx \] By the orthogonality of the sine functions, all terms in the right side vanish except when \(n=m\), leading to\begin {align*} \int _{0}^{L}f\left ( x\right ) \sin \left ( \sqrt {\lambda _{m}}x\right ) dx & =C_{m}\int _{0}^{L}\sin ^{2}\left ( \sqrt {\lambda _{m}}x\right ) dx\\ & =C_{m}\frac {L}{2} \end {align*}

Therefore (replacing \(m\) back to \(n\) now, since it is arbitrary)\[ C_{n}=\frac {2}{L}\int _{0}^{L}f\left ( x\right ) \sin \left ( \sqrt {\lambda _{n}}x\right ) dx\qquad n=1,2,3,\cdots \]

Summary of solution \[ u\left ( x,t\right ) =\sum _{n=1}^{\infty }C_{n}e^{-\left ( \frac {n\pi }{L}\right ) ^{2}\lambda _{n}t}\sin \left ( \frac {n\pi }{L}x\right ) \]

____________________________________________________________________________________

3.1.1.2 [152] Specific initial condition

problem number 152

Added June 20, 2019

Solve the heat equation \[ u_t = k u_{xx} \] For \(0<x<L\) and \(t>0\). The boundary conditions are \begin {align*} u(0,t) &= 0 \\ u(L,t) &= 0 \end {align*}

Initial condition is \(u(x,0)=f(x)\) using the following specific values \begin {align*} f(x) &= 100\\ k&=\frac {1}{100}\\ L&=10 \end {align*}

Mathematica

ClearAll["Global`*"]; 
k=1/100; 
 L=10; 
 f=100; 
pde =  D[u[x, t], t] == k*D[u[x, t], {x, 2}]; 
bc  = {u[0, t] == 0, u[L, t] == 0}; 
ic  = u[x, 0] == f; 
sol =  AbsoluteTiming[TimeConstrained[DSolve[{pde, ic, bc}, u[x, t], {x, t}], 60*10]]; 
sol =  sol /. {K[1] -> n}
 

\[\left \{\left \{u(x,t)\to \sum _{n=1}^{\infty }-\frac {200 \left (-1+(-1)^n\right ) e^{-\frac {n^2 \pi ^2 t}{10000}} \sin \left (\frac {n \pi x}{10}\right )}{n \pi }\right \}\right \}\]

Maple

restart; 
k:=1/100; 
L:=10; 
f:=100; 
pde := diff(u(x,t), t) = k*diff(u(x,t), x, x); 
bc  := u(0,t) = 0, u(L,t) = 0; 
ic  := u(x,0) = f; 
cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol', pdsolve([pde, ic, bc],u(x,t))),output='realtime'));
 

\[u \left ( x,t \right ) =\sum _{n=1}^{\infty }-200\,{\frac { \left ( \left ( -1 \right ) ^{n}-1 \right ) \sin \left ( 1/10\,n\pi \,x \right ) }{n\pi }{{\rm e}^{-{\frac {{\pi }^{2}{n}^{2}t}{10000}}}}}\]

Hand solution

The basic solution for this type of PDE was already given in problem 3.1.1.1 on page 397 as\begin {align*} u\left ( x,t\right ) & =\sum _{n=1}^{\infty }C_{n}e^{-\left ( \frac {n\pi }{L}\right ) ^{2}\lambda _{n}t}\sin \left ( \frac {n\pi }{L}x\right ) \\ C_{n} & =\frac {2}{L}\int _{0}^{L}f\left ( x\right ) \sin \left ( \frac {n\pi }{L}x\right ) dx\qquad n=1,2,3,\cdots \end {align*}

In this case \(L=10,k=\frac {1}{100},f\left ( x\right ) =100\). Hence the solution becomes\begin {align*} C_{n} & =\frac {2}{10}\int _{0}^{10}100\sin \left ( \frac {n\pi }{10}x\right ) dx\\ & =\frac {200}{\pi n}\left ( 1-\cos \left ( n\pi \right ) \right ) \\ & =\frac {200}{\pi n}\left ( 1+\left ( -1\right ) ^{n+1}\right ) \end {align*}

Hence\[ u\left ( x,t\right ) =\frac {200}{\pi }\sum _{n=1}^{\infty }\frac {1}{n}\left ( 1+\left ( -1\right ) ^{n+1}\right ) e^{-\left ( \frac {n\pi }{10}\right ) ^{2}\lambda _{n}t}\sin \left ( \frac {n\pi }{10}x\right ) \] The following is an animation of the solution

Source code used for the above

____________________________________________________________________________________

3.1.1.3 [153] IC \(u=x(1-x)\)

problem number 153

Added June 11, 2019

Solve the heat equation \[ u_t = \frac {1}{100} u_{xx} \] For \(0<x<1\) and \(t>0\). The boundary conditions are \begin {align*} u(0,t) &= 0 \\ u(L,t) &= 0 \end {align*}

Initial condition is \(u(x,0)=x(1-x)\)

Mathematica

ClearAll["Global`*"]; 
pde =  D[u[x, t], t] == 1/100*D[u[x, t], {x, 2}]; 
bc  = {u[0, t] == 0, u[1, t] == 0}; 
ic  = u[x, 0] == x*(1-x); 
sol =  AbsoluteTiming[TimeConstrained[DSolve[{pde, ic, bc}, u[x, t], {x, t},Assumptions->{k>0,L>0}], 60*10]]; 
sol =  sol /. {K[1] -> n}
 

\[\left \{\left \{u(x,t)\to \sum _{n=1}^{\infty }-\frac {4 \left (-1+(-1)^n\right ) e^{-\frac {1}{100} n^2 \pi ^2 t} \sin (n \pi x)}{n^3 \pi ^3}\right \}\right \}\]

Maple

restart; 
pde := diff(u(x,t), t) = 1/100*diff(u(x,t), x, x); 
bc  := u(0,t) = 0, u(1,t) = 0; 
ic  := u(x,0) = x*(1-x); 
cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol', pdsolve([pde, ic, bc],u(x,t))),output='realtime'));
 

\[u \left ( x,t \right ) =\sum _{n=1}^{\infty }-4\,{\frac { \left ( \left ( -1 \right ) ^{n}-1 \right ) \sin \left ( n\pi \,x \right ) }{{n}^{3}{\pi }^{3}}{{\rm e}^{-{\frac {{\pi }^{2}{n}^{2}t}{100}}}}}\]

Hand solution

Solve \(u_{t}=\frac {1}{100}u_{xx}\) with \(0<x<1\) and initial conditions \(u\left ( x,0\right ) =x\left ( 1-x\right ) \)

The basic solution for this type of PDE was already given in problem 3.1.1.1 on page 397 as\[ u\left ( x,t\right ) =\sum _{n=1}^{\infty }B_{n}e^{-k\lambda _{n}t}\sin \left ( \sqrt {\lambda _{n}}x\right ) \] Where \(\lambda _{n}=\left ( \frac {n\pi }{L}\right ) ^{2},n=1,2,3,\cdots \) and \(\sin \left ( \sqrt {\lambda _{n}}x\right ) \) are the eigenfunctions. Here \(L=1\) and \(k=\frac {1}{100}\). Hence the solution becomes\[ u\left ( x,t\right ) =\sum _{n=1}^{\infty }B_{n}e^{-k\left ( n\pi \right ) ^{2}t}\sin \left ( n\pi x\right ) \] At \(t=0\)\[ x\left ( 1-x\right ) =\sum _{n=1}^{\infty }B_{n}\sin \left ( n\pi x\right ) \] Multiplying both sides by \(\sin \left ( m\pi x\right ) \) and integrating gives\[ \int _{0}^{1}x\left ( 1-x\right ) \sin \left ( m\pi x\right ) dx=\int _{0}^{1}\sum _{n=1}^{\infty }B_{n}\sin \left ( n\pi x\right ) \sin \left ( m\pi x\right ) dx \] By orthogonality of sin function the above simplifies to\begin {align*} \int _{0}^{1}x\left ( 1-x\right ) \sin \left ( n\pi x\right ) dx & =B_{n}\int _{0}^{1}\sin ^{2}\left ( n\pi x\right ) dx\\ \int _{0}^{1}x\left ( 1-x\right ) \sin \left ( n\pi x\right ) dx & =\frac {1}{2}B_{n} \end {align*}

But \(\int _{0}^{1}x\left ( 1-x\right ) \sin \left ( n\pi x\right ) dx=\frac {2\left ( 1+\left ( -1\right ) ^{n+1}\right ) }{n^{3}\pi ^{3}}\). Hence\[ B_{n}=\frac {4\left ( 1+\left ( -1\right ) ^{n+1}\right ) }{n^{3}\pi ^{3}}\] And the solution becomes\[ u\left ( x,t\right ) =\sum _{n=1}^{\infty }\frac {4\left ( 1+\left ( -1\right ) ^{n+1}\right ) }{n^{3}\pi ^{3}}e^{-k\left ( n\pi \right ) ^{2}t}\sin \left ( n\pi x\right ) \] This is animation of the solution for \(30\) seconds. (Animation will only show in the HTML version)

Source code used for the above

____________________________________________________________________________________

3.1.1.4 [154] Haberman 2.3.3 (a)

problem number 154

This is problem 2.3.3, part (a) from Richard Haberman applied partial differential equations, 5th edition.

Consider the heat equation \[ u_t = k u_{xx} \] Subject to boundary conditions \(u(0,t)=0\) and \(u(L,t)=0\) with the temperature initially \(u(x,0)=6 \sin \left ( \frac {9 \pi x}{L} \right )\)

Mathematica

ClearAll["Global`*"]; 
NumericQ[L] =. ; 
pde =  D[u[x, t], t] == k*D[u[x, t], {x, 2}]; 
bc  = {u[0, t] == 0, u[L, t] == 0}; 
ic  = u[x, 0] == 6*Sin[(9*Pi*x)/L]; 
NumericQ[L] = True; 
sol =  AbsoluteTiming[TimeConstrained[DSolve[{pde, bc, ic}, u[x, t], {x, t}], 60*10]]; 
 NumericQ[L] =. ;
 

\[\left \{\left \{u(x,t)\to 6 e^{-\frac {81 \pi ^2 k t}{L^2}} \sin \left (\frac {9 \pi x}{L}\right )\right \}\right \}\]

Maple

restart; 
interface(showassumed=0); 
pde := diff(u(x,t),t)=k*diff(u(x,t),x$2); 
bc  := u(0,t)=0,u(L,t)=0; 
ic  := u(x,0)=6*sin(9*Pi*x/L); 
cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol',pdsolve([pde,bc,ic],u(x,t)) assuming k>0,L>0),output='realtime'));
 

\[u \left ( x,t \right ) =6\,\sin \left ( 9\,{\frac {\pi \,x}{L}} \right ) {{\rm e}^{-81\,{\frac {{\pi }^{2}kt}{{L}^{2}}}}}\]

Hand solution

Solve \(u_{t}=ku_{xx}\) with \(0<x<L\) and initial conditions \(u\left ( x,0\right ) =6\sin \left ( \frac {9\pi x}{L}\right ) \).

The basic solution for this type of PDE was already given in problem 3.1.1.1 on page 397 as\[ u\left ( x,t\right ) =\sum _{n=1}^{\infty }B_{n}e^{-k\lambda _{n}t}\sin \left ( \sqrt {\lambda _{n}}x\right ) \] Where \(\lambda _{n}=\left ( \frac {n\pi }{L}\right ) ^{2},n=1,2,3,\cdots \) and \(\sin \left ( \sqrt {\lambda _{n}}x\right ) \) are the eigenfunctions. At \(t=0\)\[ 6\sin \left ( \frac {9\pi x}{L}\right ) =\sum _{n=1}^{\infty }B_{n}\sin \left ( \frac {n\pi }{L}x\right ) \] For \(n=9\)\[ 6\sin \left ( \frac {9\pi x}{L}\right ) =B_{9}\sin \left ( \frac {9\pi }{L}x\right ) \] Hence \(B_{9}=6\) and all other terms are zero. Therefore the solution is\begin {align*} u\left ( x,t\right ) & =B_{9}\sin \left ( \sqrt {\lambda _{9}}x\right ) e^{-k\lambda _{9}t}\\ & =6\sin \left ( \frac {9\pi }{L}x\right ) e^{-k\left ( \frac {9\pi }{L}\right ) ^{2}t}\\ & =6\sin \left ( \frac {9\pi }{L}x\right ) e^{-k\frac {81\pi ^{2}}{L^{2}}t} \end {align*}

____________________________________________________________________________________

3.1.1.5 [155] IC hat function

problem number 155

Added Feb 10, 2018.

Solve the heat equation

\[ u_t = u_{xx} \]

For \(0<x<L\) and \(t>0\). The boundary conditions are \begin {align*} u(0,t) &= 0 \\ u(40,t) &= 0 \end {align*}

Initial condition is

\(u\left (x,0\right ) =\left \{ \begin {array} [c]{ccc}x & 0 \leq x < 20\\ 40-x & 20 \geq x \leq 40 \end {array} \right . \)

Mathematica

ClearAll["Global`*"]; 
f = Piecewise[{{x, Inequality[0, LessEqual, x, Less, 20]}, {40 - x, 20 <= x <= 40}}]; 
pde =  D[u[x, t], t] == D[u[x, t], {x, 2}]; 
bc  = {u[0, t] == 0, u[40, t] == 0}; 
ic  = u[x, 0] == f; 
sol =  AbsoluteTiming[TimeConstrained[DSolve[{pde, ic, bc}, u[x, t], x, t], 60*10]]; 
sol =  sol /. K[1] -> n;
 

\[\left \{\left \{u(x,t)\to \sum _{n=1}^{\infty }\frac {640 e^{-\frac {n^2 \pi ^2 t}{1600}} \cos \left (\frac {n \pi }{4}\right ) \sin ^3\left (\frac {n \pi }{4}\right ) \sin \left (\frac {n \pi x}{40}\right )}{n^2 \pi ^2}\right \}\right \}\]

Maple

restart; 
interface(showassumed=0); 
f:=piecewise(0<x and x<20,x,20<x and x<40,(40-x)); 
pde := diff(u(x,t),t)=diff(u(x,t),x$2); 
ic  := u(x,0)=f; 
bc  := u(0,t)=0,u(40,t)=0; 
cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol',pdsolve([pde,ic,bc],u(x,t))),output='realtime'));
 

\[u \left ( x,t \right ) =\sum _{n=1}^{\infty }160\,{\frac {\sin \left ( 1/40\,n\pi \,x \right ) \sin \left ( 1/2\,\pi \,n \right ) }{{\pi }^{2}{n}^{2}}{{\rm e}^{-{\frac {{\pi }^{2}{n}^{2}t}{1600}}}}}\]

Hand solution

Solve \(u_{t}=ku_{xx}\) with \(0<x<40\) and initial conditions \(u\left ( x,0\right ) =f\left ( x\right ) \) as hat function.

The basic solution for this type of PDE was already given in problem 3.1.1.1 on page 397 as\[ u\left ( x,t\right ) =\sum _{n=1}^{\infty }B_{n}e^{-k\lambda _{n}t}\sin \left ( \sqrt {\lambda _{n}}x\right ) \] Where \(\lambda _{n}=\left ( \frac {n\pi }{L}\right ) ^{2},n=1,2,3,\cdots \) and \(\sin \left ( \sqrt {\lambda _{n}}x\right ) \) are the eigenfunctions. Here \(L=40\) and \(k=1\). Hence the solution becomes

\[ u\left ( x,t\right ) =\sum _{n=1}^{\infty }B_{n}e^{-\left ( \frac {n\pi }{40}\right ) ^{2}t}\sin \left ( \frac {n\pi }{40}x\right ) \]

At \(t=0\)

\[ f\left ( x\right ) =\sum _{n=1}^{\infty }B_{n}\sin \left ( \frac {n\pi }{40}x\right ) \]

Multiplying both sides by \(\sin \left ( m\pi x\right ) \) and integrating gives

\[ \int _{0}^{40}f\left ( x\right ) \sin \left ( \frac {m\pi }{40}x\right ) dx=\int _{0}^{40}\sum _{n=1}^{\infty }B_{n}\sin \left ( \frac {n\pi }{40}x\right ) \sin \left ( \frac {m\pi }{40}x\right ) dx \]

By orthogonality of sin function the above simplifies to

\begin {align*} \int _{0}^{40}f\left ( x\right ) \sin \left ( \frac {n\pi }{40}x\right ) dx & =B_{n}\int _{0}^{40}\sin ^{2}\left ( \frac {n\pi }{40}x\right ) dx\\ \int _{0}^{20}x\sin \left ( \frac {n\pi }{40}x\right ) dx+\int _{20}^{40}\left ( 40-x\right ) \sin \left ( \frac {n\pi }{40}x\right ) dx & =20B_{n} \end {align*}

But \(\int _{0}^{20}x\sin \left ( \frac {n\pi }{40}x\right ) dx+\int _{20}^{40}\left ( 40-x\right ) \sin \left ( \frac {n\pi }{40}x\right ) dx=\frac {3200}{n^{2}\pi ^{2}}\sin \left ( \frac {n\pi }{2}\right ) \). Hence

\[ B_{n}=\frac {160}{n^{2}\pi ^{2}}\sin \left ( \frac {n\pi }{2}\right ) \]

And the solution becomes

\[ u\left ( x,t\right ) =\sum _{n=1}^{\infty }\frac {160}{n^{2}\pi ^{2}}\sin \left ( \frac {n\pi }{2}\right ) e^{-\left ( \frac {n\pi }{40}\right ) ^{2}t}\sin \left ( \frac {n\pi }{40}x\right ) \]

When \(n\) is even the terms are zero Hence

\[ u\left ( x,t\right ) =\sum _{n=1,3,5,\cdots }^{\infty }\frac {160}{n^{2}\pi ^{2}}\sin \left ( \frac {n\pi }{2}\right ) e^{-\left ( \frac {n\pi }{40}\right ) ^{2}t}\sin \left ( \frac {n\pi }{40}x\right ) \]

Or

\[ u\left ( x,t\right ) =\sum _{n=1}^{\infty }\frac {160}{\left ( 2n-1\right ) ^{2}\pi ^{2}}\sin \left ( \frac {\left ( 2n-1\right ) \pi }{2}\right ) e^{-\left ( \frac {\left ( 2n-1\right ) \pi }{40}\right ) ^{2}t}\sin \left ( \frac {\left ( 2n-1\right ) \pi }{40}x\right ) \]

This is animation of the solution for \(400\) seconds. (Animation will only show in the HTML version)

Source code used for the above

____________________________________________________________________________________

3.1.1.6 [156] Haberman 2.3.3 (b)

problem number 156

This is problem 2.3.3, part (b) from Richard Haberman applied partial differential equations, 5th edition.

Consider the heat equation

\[ \frac { \partial u}{\partial t} = k \frac { \partial ^2 u}{\partial x^2} \]

Subject to boundary conditions \(u(0,t)=0\) and \(u(L,t)=0\) with the temperature initially \(u(x,0)=3 \sin \frac {\pi x}{L} - \sin \frac {3 \pi x}{L}\)

Mathematica

ClearAll["Global`*"]; 
NumericQ[L] =. ; 
pde =  D[u[x, t], t] == k*D[u[x, t], {x, 2}]; 
bc  = {u[0, t] == 0, u[L, t] == 0}; 
ic  = u[x, 0] == 3*Sin[(Pi*x)/L] - Sin[(3*Pi*x)/L]; 
NumericQ[L] = True; 
sol =  AbsoluteTiming[TimeConstrained[DSolve[{pde, bc, ic}, u[x, t], {x, t}], 60*10]]; 
 NumericQ[L] =. ;
 

\[\left \{\left \{u(x,t)\to e^{-\frac {9 \pi ^2 k t}{L^2}} \sin \left (\frac {\pi x}{L}\right ) \left (3 e^{\frac {8 \pi ^2 k t}{L^2}}-2 \cos \left (\frac {2 \pi x}{L}\right )-1\right )\right \}\right \}\]

Maple

restart; 
interface(showassumed=0); 
assume(L>0); 
pde := diff(u(x,t),t)=k*diff(u(x,t),x$2); 
bc  := u(0,t)=0,u(L,t)=0; 
ic  := u(x,0)=3*sin(Pi*x/L)-sin(3*Pi*x/L); 
cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol',pdsolve([pde,bc,ic],u(x,t))),output='realtime'));
 

\[u \left ( x,t \right ) =3\,\sin \left ( {\frac {\pi \,x}{L}} \right ) {{\rm e}^{-{\frac {{\pi }^{2}kt}{{L}^{2}}}}}-\sin \left ( 3\,{\frac {\pi \,x}{L}} \right ) {{\rm e}^{-9\,{\frac {{\pi }^{2}kt}{{L}^{2}}}}}\]

Hand solution

Solve \(u_{t}=ku_{xx}\) with \(0<x<L\) and initial conditions \(u\left ( x,0\right ) =3\sin \left ( \frac {\pi x}{L}\right ) -\sin \left ( \frac {3\pi x}{L}\right ) \).

The basic solution for this type of PDE was already given in problem 3.1.1.1 on page 397 as\[ u\left ( x,t\right ) =\sum _{n=1}^{\infty }B_{n}e^{-k\lambda _{n}t}\sin \left ( \sqrt {\lambda _{n}}x\right ) \] Where the eigenvalues are \(\lambda _{n}=\left ( \frac {n\pi }{L}\right ) ^{2}\) for \(n=1,2,3,\cdots \) and \(\sin \left ( \sqrt {\lambda _{n}}x\right ) \) are the eigenfunctions.

Initial conditions are now applied. Setting \(t=0\), the above becomes\[ u\left ( x,0\right ) =3\sin \frac {\pi x}{L}-\sin \frac {3\pi x}{L}=\sum _{n=1}^{\infty }B_{n}\sin \left ( \frac {n\pi }{L}x\right ) \] As the series is unique, the terms coefficients must match for those shown only, and all other \(B_{n}\) terms vanish. This means that by comparing terms\[ 3\sin \left ( \frac {\pi x}{L}\right ) -\sin \left ( \frac {3\pi x}{L}\right ) =B_{1}\sin \left ( \frac {\pi x}{L}\right ) +B_{3}\sin \left ( \frac {3\pi }{L}x\right ) \] Therefore \begin {align*} B_{1} & =3\\ B_{3} & =-1 \end {align*}

And all other \(B_{n}=0\). The solution is\[ u\left ( x,t\right ) =3\sin \left ( \frac {\pi }{L}x\right ) e^{-k\left ( \frac {\pi }{L}\right ) ^{2}t}-\sin \left ( \frac {3\pi }{L}x\right ) e^{-k\left ( \frac {3\pi }{L}\right ) ^{2}t}\]

____________________________________________________________________________________

3.1.1.7 [157] Haberman 2.3.3 (c)

problem number 157

This is problem 2.3.3, part (c) from Richard Haberman applied partial differential equations, 5th edition.

Consider the heat equation

\[ u_t = k u_{xx} \]

Subject to boundary conditions \(u(0,t)=0\) and \(u(L,t)=0\) with the temperature initially \(u(x,0)=2 \cos \frac {3 \pi x}{L}\)

Mathematica

ClearAll["Global`*"]; 
pde =  D[u[x, t], t] == k*D[u[x, t], {x, 2}]; 
bc  = {u[0, t] == 0, u[L, t] == 0}; 
ic  = u[x, 0] == 2*Cos[(3*Pi*x)/L]; 
sol =  AbsoluteTiming[TimeConstrained[DSolve[{pde, bc, ic}, u[x, t], {x, t}, Assumptions -> L > 0], 60*10]]; 
sol =  sol/. K[1]->n;
 

\[\left \{\left \{u(x,t)\to \sum _{n=1}^{\infty }\frac {4 \left (1+(-1)^n\right ) e^{-\frac {k n^2 \pi ^2 t}{L^2}} n \sin \left (\frac {n \pi x}{L}\right )}{\left (n^2-9\right ) \pi }\right \}\right \}\] but \(n=3\) should be special case

Maple

restart; 
interface(showassumed=0); 
pde := diff(u(x,t),t)=k*diff(u(x,t),x$2); 
bc  := u(0,t)=0,u(L,t)=0; 
ic  := u(x,0)=2*cos(3*Pi*x/L); 
cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol',pdsolve([pde,bc,ic],u(x,t)) assuming L>0),output='realtime'));
 

\[u \left ( x,t \right ) =1/5\,{\frac {1}{\pi } \left ( 5\,\sum _{n=4}^{\infty }4\,{\frac {n \left ( \left ( -1 \right ) ^{n}+1 \right ) }{\pi \, \left ( {n}^{2}-9 \right ) }\sin \left ( {\frac {n\pi \,x}{L}} \right ) {{\rm e}^{-{\frac {{\pi }^{2}{n}^{2}kt}{{L}^{2}}}}}}\pi -16\,\sin \left ( 2\,{\frac {\pi \,x}{L}} \right ) {{\rm e}^{-4\,{\frac {{\pi }^{2}kt}{{L}^{2}}}}} \right ) }\] handled \(n=3\) case correctly.

Hand solution

Solve \(u_{t}=ku_{xx}\) with \(0<x<L\) and initial conditions \(u\left ( x,0\right ) =2\cos \left ( \frac {3\pi x}{L}\right ) \).

The basic solution for this type of PDE was already given in problem 3.1.1.1 on page 397 as\[ u\left ( x,t\right ) =\sum _{n=1}^{\infty }B_{n}e^{-k\lambda _{n}t}\sin \left ( \sqrt {\lambda _{n}}x\right ) \] Where \(\lambda _{n}=\left ( \frac {n\pi }{L}\right ) ^{2},n=1,2,3,\cdots \) and \(\sin \left ( \sqrt {\lambda _{n}}x\right ) \) are the eigenfunctions. Initial conditions are now applied. Setting \(t=0\), the above becomes\[ u\left ( x,0\right ) =2\cos \left ( \frac {3\pi }{L}x\right ) =\sum _{n=1}^{\infty }B_{n}\sin \left ( \frac {n\pi }{L}x\right ) \] Multiplying both sides by \(\sin \left ( \frac {m\pi }{L}x\right ) \) and integrating\begin {align*} \int _{0}^{L}2\cos \left ( \frac {3\pi }{L}x\right ) \sin \left ( \frac {m\pi }{L}x\right ) dx & =\int _{0}^{L}\sum _{n=1}^{\infty }B_{n}\sin \left ( \frac {n\pi }{L}x\right ) \sin \left ( \frac {m\pi }{L}x\right ) dx\\ & =\sum _{n=1}^{\infty }B_{n}\int _{0}^{L}\sin \left ( \frac {n\pi }{L}x\right ) \sin \left ( \frac {m\pi }{L}x\right ) dx \end {align*}

By orthogonality of \(\sin \) functions the above simplifies to\begin {align*} \int _{0}^{L}2\cos \left ( \frac {3\pi }{L}x\right ) \sin \left ( \frac {m\pi }{L}x\right ) dx & =B_{m}\int _{0}^{L}\sin ^{2}\left ( \frac {m\pi }{L}x\right ) dx\\ & =B_{m}\frac {L}{2}\\ B_{m} & =\frac {4}{L}\int _{0}^{L}\cos \left ( \frac {3\pi }{L}x\right ) \sin \left ( \frac {m\pi }{L}x\right ) dx \end {align*}

For \(m=3,B_{3}=0\). For \(m\neq 3\)\begin {align*} B_{m} & =\frac {4}{L}\left ( \frac {1+\left ( -1\right ) ^{m}}{m^{2}-9}\frac {nL}{\pi }\right ) \\ & =\frac {4n}{\pi }\left ( \frac {1+\left ( -1\right ) ^{m}}{m^{2}-9}\right ) \end {align*}

Hence the solution becomes\begin {align*} u\left ( x,t\right ) & =\sum _{n=1,n\neq 3}^{\infty }\frac {4n}{\pi }\left ( \frac {1+\left ( -1\right ) ^{n}}{n^{2}-9}\right ) \sin \left ( \frac {n\pi }{L}x\right ) e^{-k\left ( \frac {n\pi }{L}\right ) ^{2}t}\\ & =\frac {4}{\pi }\sum _{n=1,n\neq 3}^{\infty }n\left ( \frac {1+\left ( -1\right ) ^{n}}{n^{2}-9}\right ) \sin \left ( \frac {n\pi }{L}x\right ) e^{-k\left ( \frac {n\pi }{L}\right ) ^{2}t} \end {align*}

When \(n\) is odd, all terms become zero, hence the above can be also be written as\[ u\left ( x,t\right ) =\frac {8}{\pi }\sum _{n=2,4,6,\cdots }^{\infty }\left ( \frac {n}{n^{2}-9}\right ) \sin \left ( \frac {n\pi }{L}x\right ) e^{-k\left ( \frac {n\pi }{L}\right ) ^{2}t}\]

____________________________________________________________________________________

3.1.1.8 [158] Haberman 2.3.3 (d)

problem number 158

This is problem 2.3.3, part (d) from Richard Haberman applied partial differential equations, 5th edition.

Consider the heat equation

\[ \frac { \partial u}{\partial t} = k \frac { \partial ^2 u}{\partial x^2} \]

Subject to boundary conditions \(u(0,t)=0\) and \(u(L,t)=0\) with the temperature initially \(u\left ( x,0\right ) =\left \{ \begin {array} [c]{ccc}1 & & 0<x\leq \frac {L}{2}\\ 2 & & \frac {L}{2}<x\leq L \end {array} \right . \)

Mathematica

ClearAll["Global`*"]; 
pde =  D[u[x, t], t] == k*D[u[x, t], {x, 2}]; 
bc  = {u[0, t] == 0, u[L, t] == 0}; 
ic  = u[x, 0] == Piecewise[{{1, Inequality[0, Less, x, LessEqual, L/2]}, {2, L/2 < x < L}}]; 
sol =  AbsoluteTiming[TimeConstrained[DSolve[{pde, bc, ic}, u[x, t], {x, t}, Assumptions -> L > 0], 60*10]]; 
sol =  sol /. K[1] -> n;
 

\[\left \{\left \{u(x,t)\to \sum _{n=1}^{\infty }\frac {4 e^{-\frac {k n^2 \pi ^2 t}{L^2}} \left (4 \cos \left (\frac {n \pi }{2}\right )+3\right ) \sin ^2\left (\frac {n \pi }{4}\right ) \sin \left (\frac {n \pi x}{L}\right )}{n \pi }\right \}\right \}\]

Maple

restart; 
interface(showassumed=0); 
pde := diff(u(x,t),t)=k*diff(u(x,t),x$2); 
bc  := u(0,t)=0,u(L,t)=0; 
ic  := u(x,0)=piecewise(0<x and x<=L/2,1,L/2<x and x<L,2); 
cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol',pdsolve([pde,bc,ic],u(x,t)) assuming L>0),output='realtime'));
 

\[u \left ( x,t \right ) =\sum _{n=1}^{\infty }{\frac {2\,\cos \left ( 1/2\,\pi \,n \right ) +2-4\, \left ( -1 \right ) ^{n}}{\pi \,n}\sin \left ( {\frac {n\pi \,x}{L}} \right ) {{\rm e}^{-{\frac {{\pi }^{2}{n}^{2}kt}{{L}^{2}}}}}}\]

Hand solution

The basic solution for this type of PDE was already given in problem 3.1.1.1 on page 397 as\[ u\left ( x,t\right ) =\sum _{n=1}^{\infty }B_{n}e^{-k\lambda _{n}t}\sin \left ( \sqrt {\lambda _{n}}x\right ) \] Where \(\lambda _{n}=\left ( \frac {n\pi }{L}\right ) ^{2},n=1,2,3,\cdots \) and \(\sin \left ( \sqrt {\lambda _{n}}x\right ) \) are the eigenfunctions. Initial conditions are now applied. Setting \(t=0\), the above becomes\begin {equation} f\left ( x\right ) =\sum _{n=1}^{\infty }B_{n}\sin \left ( \frac {n\pi }{L}x\right ) \tag {3} \end {equation} Where \[ f\left ( x\right ) =\left \{ \begin {array} [c]{ccc}1 & & 0<x\leq \frac {L}{2}\\ 2 & & \frac {L}{2}<x<L \end {array} \right . \] Multiplying both sides of (3) by \(\sin \left ( \frac {m\pi }{L}x\right ) \) and integrating over the domain gives\[ \int _{0}^{L}\sin \left ( \frac {m\pi }{L}x\right ) f\left ( x\right ) dx=\int _{0}^{L}\left [ \sum _{n=1}^{\infty }B_{n}\sin \left ( \frac {m\pi }{L}x\right ) \sin \left ( \frac {n\pi }{L}x\right ) \right ] dx \] Interchanging the order of integration and summation\[ \int _{0}^{L}\sin \left ( \frac {m\pi }{L}x\right ) f\left ( x\right ) dx=\sum _{n=1}^{\infty }\left [ B_{n}\left ( \int _{0}^{L}\sin \left ( \frac {m\pi }{L}x\right ) \sin \left ( \frac {n\pi }{L}x\right ) dx\right ) \right ] \] But \(\int _{0}^{L}\sin \left ( \frac {m\pi }{L}x\right ) \sin \left ( \frac {n\pi }{L}x\right ) dx=0\) for \(n\neq m\), hence only one term survives\[ \int _{0}^{L}\sin \left ( \frac {m\pi }{L}x\right ) f\left ( x\right ) dx=B_{m}\int _{0}^{L}\sin ^{2}\left ( \frac {m\pi }{L}x\right ) dx \] Renaming \(m\) back to \(n\) and since \(\int _{0}^{L}\sin ^{2}\left ( \frac {m\pi }{L}x\right ) dx=\frac {L}{2}\) the above becomes\begin {align*} \int _{0}^{L}\sin \left ( \frac {n\pi }{L}x\right ) f\left ( x\right ) dx & =\frac {L}{2}B_{n}\\ B_{n} & =\frac {2}{L}\int _{0}^{L}\sin \left ( \frac {n\pi }{L}x\right ) f\left ( x\right ) dx\\ & =\frac {2}{L}\left ( \int _{0}^{\frac {L}{2}}\sin \left ( \frac {n\pi }{L}x\right ) f\left ( x\right ) dx+\int _{\frac {L}{2}}^{L}\sin \left ( \frac {n\pi }{L}x\right ) f\left ( x\right ) dx\right ) \\ & =\frac {2}{L}\left ( \int _{0}^{\frac {L}{2}}\sin \left ( \frac {n\pi }{L}x\right ) dx+2\int _{\frac {L}{2}}^{L}\sin \left ( \frac {n\pi }{L}x\right ) dx\right ) \\ & =\frac {2}{L}\left ( \left . \frac {-\cos \left ( \frac {n\pi }{L}x\right ) }{\frac {n\pi }{L}}\right \vert _{0}^{\frac {L}{2}}+2\left . \frac {-\cos \left ( \frac {n\pi }{L}x\right ) }{\frac {n\pi }{L}}\right \vert _{\frac {L}{2}}^{L}\right ) \\ & =\frac {2}{n\pi }\left ( \left ( -\cos \left ( \frac {n\pi }{L}x\right ) \right ) _{0}^{\frac {L}{2}}+2\left ( -\cos \left ( \frac {n\pi }{L}x\right ) \right ) _{\frac {L}{2}}^{L}\right ) \\ & =\frac {2}{n\pi }\left ( \left [ -\cos \left ( \frac {n\pi }{L}\frac {L}{2}\right ) +\cos \left ( 0\right ) \right ] +2\left [ -\cos \left ( n\pi \right ) +\cos \left ( \frac {n\pi }{2}\right ) \right ] \right ) \\ & =\frac {2}{n\pi }\left ( -\cos \left ( \frac {n\pi }{2}\right ) +1-2\cos \left ( n\pi \right ) +2\cos \left ( \frac {n\pi }{2}\right ) \right ) \\ & =\frac {2}{n\pi }\left ( \cos \left ( \frac {n\pi }{2}\right ) +1-2\cos \left ( n\pi \right ) \right ) \end {align*}

Hence the solution is\[ u\left ( x,t\right ) =\sum _{n=1}^{\infty }B_{n}\sin \left ( \frac {n\pi }{L}x\right ) e^{-k\left ( \frac {n\pi }{L}\right ) ^{2}t}\] With \begin {align*} B_{n} & =\frac {2}{n\pi }\left ( \cos \left ( \frac {n\pi }{2}\right ) -2\cos \left ( n\pi \right ) +1\right ) \\ & =\frac {2}{n\pi }\left ( 1-2\left ( -1\right ) ^{n}+\cos \left ( \frac {n\pi }{2}\right ) \right ) \\ & =\frac {2}{n\pi }\left ( 1+2\left ( -1\right ) ^{n+1}+\cos \left ( \frac {n\pi }{2}\right ) \right ) \end {align*}

Therefore\[ u\left ( x,t\right ) =\sum _{n=1}^{\infty }\frac {2}{n\pi }\left ( 1-2\left ( -1\right ) ^{n}+\cos \left ( \frac {n\pi }{2}\right ) \right ) \sin \left ( \frac {n\pi }{L}x\right ) e^{-k\left ( \frac {n\pi }{L}\right ) ^{2}t}\]

____________________________________________________________________________________

3.1.1.9 [159] domain from -1 to +1

problem number 159

Solve the heat equation

\[ \frac { \partial u}{\partial t} = \frac { \partial ^2 u}{\partial x^2} \]

For \(-1<x<1\) and \(t>0\). The boundary conditions are zero at both ends. Initial condition is \(u(x,0)=f(x)\)

Mathematica

ClearAll["Global`*"]; 
pde =  D[u[x, t], {t, 1}] == D[u[x, t], {x, 2}]; 
ic  = u[x, 0] == f[x]; 
bc  = {u[-1, t] == 0, u[1, t] == 0}; 
sol =  AbsoluteTiming[TimeConstrained[DSolve[{pde, bc, ic}, u[x, t], {x, t}], 60*10]];
 

Failed

Maple

restart; 
interface(showassumed=0); 
pde := diff(u(x,t),t) =diff(u(x,t),x$2); 
ic  := u(x,0) = f(x); 
bc  := u(-1,t)=0,  u(1,t)=0; 
cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol',pdsolve([pde, ic, bc],u(x,t)) assuming t>0),output='realtime'));
 

\[u \left ( x,t \right ) =\sum _{n=1}^{\infty } \left ( \sin \left ( 1/2\,n\pi \, \left ( 1+x \right ) \right ) {{\rm e}^{-1/4\,{\pi }^{2}{n}^{2}t}}\int _{-1}^{1}\!f \left ( x \right ) \sin \left ( 1/2\,n\pi \, \left ( 1+x \right ) \right ) \,{\rm d}x \right ) \]

Hand solution

Solve \(u_{t}=ku_{xx}\) with \(-1<x<1\) and initial conditions \(u\left ( x,0\right ) =f\left ( x\right ) \) and B.C. \(u\left ( -1,t\right ) =u\left ( 1,t\right ) =0\).

Let \(\xi =x+1\) where \(x=-1\cdots 1\) Therefore \(\xi =0\cdots 2\). This also implies mapping the initial temperature to \(f\left ( x+a\right ) \). Now the ODE is solved\begin {align*} u_{t} & =u_{\xi \xi }\\ u\left ( 0,t\right ) & =0\\ u\left ( 2,t\right ) & =0 \end {align*}

The basic solution for this type of PDE was already given in problem 3.1.1.1 on page 397 as\[ u\left ( \xi ,t\right ) =\sum _{n=1}^{\infty }B_{n}e^{-k\lambda _{n}t}\sin \left ( \sqrt {\lambda _{n}}\xi \right ) \]

Where \(\lambda _{n}=\left ( \frac {n\pi }{L}\right ) ^{2},n=1,2,3,\cdots \) and \(\sin \left ( \sqrt {\lambda _{n}}\xi \right ) \) are the eigenfunctions. Here \(L=2\). Hence the solution becomes

\[ u\left ( \xi ,t\right ) =\sum _{n=1}^{\infty }B_{n}e^{-k\left ( \frac {n\pi }{2}\right ) ^{2}t}\sin \left ( \frac {n\pi }{2}\xi \right ) \]

Changing back to \(x\ \)\[ u\left ( x,t\right ) =\sum _{n=1}^{\infty }B_{n}e^{-k\left ( \frac {n\pi }{2}\right ) ^{2}t}\sin \left ( \frac {n\pi }{2}\left ( x+1\right ) \right ) \]

At \(t=0\)

\[ f\left ( x\right ) =\sum _{n=1}^{\infty }B_{n}e^{-k\left ( \frac {n\pi }{2}\right ) ^{2}t}\sin \left ( \frac {n\pi }{2}\left ( x+1\right ) \right ) \]

Multiplying both sides by \(\sin \left ( \frac {m\pi }{2}\left ( x+1\right ) \right ) \) and integrating gives

\[ \int _{-1}^{1}f\left ( x\right ) \sin \left ( \frac {m\pi }{2}\left ( x+1\right ) \right ) dx=\int _{-1}^{1}\sum _{n=1}^{\infty }B_{n}\sin \left ( \frac {m\pi }{2}\left ( x+1\right ) \right ) \sin \left ( \frac {n\pi }{2}\left ( x+1\right ) \right ) dx \]

By orthogonality of sin function the above simplifies to

\begin {align*} \int _{-1}^{1}f\left ( x\right ) \sin \left ( \frac {n\pi }{2}\left ( x+1\right ) \right ) dx & =B_{n}\int _{-1}^{1}\sin ^{2}\left ( \frac {n\pi }{2}\left ( x+1\right ) \right ) dx\\ \int _{-1}^{1}f\left ( x\right ) \sin \left ( \frac {n\pi }{2}\left ( x+1\right ) \right ) dx & =B_{n} \end {align*}

Hence

\[ B_{n}=\int _{-1}^{1}f\left ( x\right ) \sin \left ( \frac {n\pi }{2}\left ( x+1\right ) \right ) dx \]

And the solution becomes

\[ u\left ( x,t\right ) =\sum _{n=1}^{\infty }\left ( \int _{-1}^{1}f\left ( x\right ) \sin \left ( \frac {n\pi }{2}\left ( x+1\right ) \right ) dx\right ) e^{-k\left ( \frac {n\pi }{2}\right ) ^{2}t}\sin \left ( \frac {n\pi }{2}\left ( x+1\right ) \right ) \]

____________________________________________________________________________________

3.1.1.10 [160] domain from -1 to +1

problem number 160

Solve the heat equation

\[ \frac { \partial u}{\partial t} = \frac { \partial ^2 u}{\partial x^2} \]

For \(-1<x<1\) and \(t>0\). The boundary conditions are zero at both ends. Initial condition is \(u(x,0)=1-x^2\)

Mathematica

ClearAll["Global`*"]; 
pde =  D[u[x, t], {t, 1}] == D[u[x, t], {x, 2}]; 
ic  = u[x, 0] == 1-x^2; 
bc  = {u[-1, t] == 0, u[1, t] == 0}; 
sol =  AbsoluteTiming[TimeConstrained[DSolve[{pde, bc, ic}, u[x, t], {x, t}], 60*10]];
 

Failed

Maple

restart; 
interface(showassumed=0); 
pde := diff(u(x,t),t) =diff(u(x,t),x$2); 
ic  := u(x,0) = 1-x^2; 
bc  := u(-1,t)=0,  u(1,t)=0; 
cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol',pdsolve([pde, ic, bc],u(x,t)) assuming t>0),output='realtime'));
 

\[u \left ( x,t \right ) =\sum _{n=1}^{\infty }-16\,{\frac {\sin \left ( 1/2\,n\pi \, \left ( 1+x \right ) \right ) {{\rm e}^{-1/4\,{\pi }^{2}{n}^{2}t}} \left ( \left ( -1 \right ) ^{n}-1 \right ) }{{n}^{3}{\pi }^{3}}}\]

Hand solution

Solve \(u_{t}=u_{xx}\) with \(-1<x<1\) and initial conditions \(u\left ( x,0\right ) =f\left ( x\right ) =1-x^{2}\) and B.C. \(u\left ( -1,t\right ) =u\left ( 1,t\right ) =0\).

The basic solution for this type of PDE was already given in problem 3.1.1.9 on page 435 as

\[ u\left ( x,t\right ) =\sum _{n=1}^{\infty }\left ( \int _{-1}^{1}f\left ( x\right ) \sin \left ( \frac {n\pi }{2}\left ( x+1\right ) \right ) dx\right ) e^{-k\left ( \frac {n\pi }{2}\right ) ^{2}t}\sin \left ( \frac {n\pi }{2}\left ( x+1\right ) \right ) \]

Replacing \(f\left ( x\right ) =1-x^{2}\) then

\begin {align*} \int _{-1}^{1}f\left ( x\right ) \sin \left ( \frac {n\pi }{2}\left ( x+1\right ) \right ) dx & =\int _{-1}^{1}\left ( 1-x^{2}\right ) \sin \left ( \frac {n\pi }{2}\left ( x+1\right ) \right ) dx\\ & =\frac {16\left ( 1+\left ( -1\right ) ^{n+1}\right ) }{n^{3}\pi ^{3}} \end {align*}

Hence the solution becomes, using \(k=1\)

\[ u\left ( x,t\right ) =\sum _{n=1}^{\infty }\frac {16\left ( 1+\left ( -1\right ) ^{n+1}\right ) }{n^{3}\pi ^{3}}e^{-\left ( \frac {n\pi }{2}\right ) ^{2}t}\sin \left ( \frac {n\pi }{2}\left ( x+1\right ) \right ) \]

This is animation of the solution for \(2\) seconds. (Animation will only show in the HTML version)

Source code used for the above

____________________________________________________________________________________

3.1.1.11 [161] with source that depends on space only (general case)

problem number 161

Added July 3, 2019

Solve the heat equation for \(u(x,t)\) \[ u_t= k u_{xx} + Q(x) \] For \(0<x<L\) and \(t>0\). The boundary conditions are \begin {align*} u(0,t)&=0 \\ u(L,t) &= 0\\ \end {align*}

Initial condition is \(u(x,0)=f(x)\)

Mathematica

ClearAll["Global`*"]; 
pde =  D[u[x, t], t] == k*D[u[x, t], {x, 2}] + Q[x]; 
bc  = {u[0, t] == 0, u[L, t] == 0}; 
ic  = u[x, 0] == f[x]; 
sol =  AbsoluteTiming[TimeConstrained[DSolve[{pde, ic, bc}, u[x, t], {x, t},Assumptions->{k>0,L>0}], 60*10]];
 

Failed

Maple

restart; 
pde := diff(u(x,t),t)= k*diff(u(x,t),x$2) + Q(x); 
bc  := u(0, t) = 0, u(L, t) = 0; 
ic  := u(x, 0) = f(x); 
cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol', pdsolve([pde, ic, bc], u(x, t)) assuming L>0,k>0),output='realtime'));
 

\[u \left ( x,t \right ) ={\frac {1}{Lk} \left ( \sum _{n=1}^{\infty } \left ( 2\,{\frac {1}{k{L}^{2}}\sin \left ( {\frac {n\pi \,x}{L}} \right ) {{\rm e}^{-{\frac {{\pi }^{2}{n}^{2}kt}{{L}^{2}}}}}\int _{0}^{L}\! \left ( f \left ( {\it \_a} \right ) Lk+\int _{0}^{{\it \_a}}\!\int _{0}^{{\it \_z1}}\!Q \left ( {\it \_z1} \right ) \,{\rm d}{\it \_z1}\,{\rm d}{\it \_z1}L-\int _{0}^{L}\!\int _{0}^{{\it \_z1}}\!Q \left ( {\it \_z1} \right ) \,{\rm d}{\it \_z1}\,{\rm d}{\it \_z1}{\it \_a} \right ) \sin \left ( {\frac {\pi \,n{\it \_a}}{L}} \right ) \,{\rm d}{\it \_a}} \right ) Lk-\int _{0}^{x}\!\int _{0}^{{\it \_a}}\!Q \left ( {\it \_a} \right ) \,{\rm d}{\it \_a}\,{\rm d}{\it \_a}L+\int _{0}^{L}\!\int _{0}^{{\it \_a}}\!Q \left ( {\it \_a} \right ) \,{\rm d}{\it \_a}\,{\rm d}{\it \_a}x \right ) }\]

Hand solution

Let the solution be\begin {equation} u\left ( x,t\right ) =\sum _{n=1}^{\infty }a_{n}\left ( t\right ) \Phi _{n}\left ( x\right ) \tag {1} \end {equation} Where \(\Phi _{n}\left ( x\right ) \) are the eigenfunctions of the eigenvalue problem for the pde \(u_{t}=ku_{xx}\) with \(u\left ( 0,x\right ) =0,u\left ( L,x\right ) =0\). This was solved in problem 3.1.1.1 on page 397 and \(\Phi _{n}\left ( x\right ) \) was found as\begin {align*} \Phi _{n}\left ( x\right ) & =\sin \left ( \sqrt {\lambda _{n}}x\right ) \\ \lambda _{n} & =\left ( \frac {n\pi }{L}\right ) ^{2}\qquad n=1,2,3,\cdots \end {align*}

Hence (1) becomes\begin {equation} u\left ( x,t\right ) =\sum _{n=1}^{\infty }a_{n}\left ( t\right ) \sin \left ( \sqrt {\lambda _{n}}x\right ) \tag {1A} \end {equation} Substituting this back into the original given PDE gives\[ \sum _{n=1}^{\infty }a_{n}^{\prime }\left ( t\right ) \Phi _{n}\left ( x\right ) =k\sum _{n=1}^{\infty }a_{n}\left ( t\right ) \Phi _{n}^{\prime \prime }\left ( x\right ) +\sum _{n=1}^{\infty }q_{n}\Phi _{n}\left ( x\right ) \] Where \(Q\left ( x\right ) =\sum _{n=1}^{\infty }q_{n}\Phi _{n}\left ( x\right ) \). Since \(\Phi _{n}^{\prime \prime }\left ( x\right ) =-\lambda _{n}\Phi _{n}\left ( x\right ) \), then the above simplifies to\begin {align} \sum _{n=1}^{\infty }a_{n}^{\prime }\left ( t\right ) \Phi _{n}\left ( x\right ) & =-k\sum _{n=1}^{\infty }a_{n}\left ( t\right ) \lambda _{n}\Phi _{n}\left ( x\right ) +\sum _{n=1}^{\infty }q_{n}\Phi _{n}\left ( x\right ) \nonumber \\ a_{n}^{\prime }\left ( t\right ) +k\lambda _{n}a_{n}\left ( t\right ) & =q_{n}\tag {2} \end {align}

We now need to find \(q_{n}\). By orthogonality\[ \int _{0}^{L}Q\left ( x\right ) \Phi _{n}\left ( x\right ) dx=\int _{0}^{L}q_{n}\Phi _{n}^{2}\left ( x\right ) dx \] But \(\int _{0}^{L}\Phi _{n}^{2}\left ( x\right ) dx=\int _{0}^{L}\sin ^{2}\left ( \frac {n\pi }{L}x\right ) dx=\frac {L}{2}\) and the above becomes\[ q_{n}=\frac {2}{L}\int _{0}^{L}Q\left ( x\right ) \Phi _{n}\left ( x\right ) dx \] Using the above in (2) gives\[ a_{n}^{\prime }\left ( t\right ) +k\lambda _{n}a_{n}\left ( t\right ) =\frac {2}{L}\int _{0}^{L}Q\left ( x\right ) \Phi _{n}\left ( x\right ) dx \] The integrating factor is \(I=e^{k\lambda _{n}t}\). Hence the above becomes\begin {align*} \frac {d}{dt}\left ( a_{n}\left ( t\right ) e^{k\lambda _{n}t}\right ) & =\frac {2}{L}e^{k\lambda _{n}t}\int _{0}^{L}Q\left ( x\right ) \Phi _{n}\left ( x\right ) dx\\ a_{n}\left ( t\right ) e^{k\lambda _{n}t} & =\int _{0}^{t}\frac {2}{L}e^{k\lambda _{n}s}\left ( \int _{0}^{L}Q\left ( x\right ) \Phi _{n}\left ( x\right ) dx\right ) ds+a_{n}\left ( 0\right ) \\ a_{n}\left ( t\right ) & =a_{n}\left ( 0\right ) e^{-k\lambda _{n}t}+e^{-k\lambda _{n}t}\int _{0}^{t}\frac {2}{L}e^{k\lambda _{n}s}\left ( \int _{0}^{L}Q\left ( x\right ) \Phi _{n}\left ( x\right ) dx\right ) ds \end {align*}

Therefore the solution (1A) becomes\begin {equation} u\left ( x,t\right ) =\sum _{n=1}^{\infty }\left [ a_{n}\left ( 0\right ) e^{-k\lambda _{n}t}+e^{-k\lambda _{n}t}\int _{0}^{t}\frac {2}{L}e^{k\lambda _{n}\tau }\left ( \int _{0}^{L}Q\left ( s\right ) \Phi _{n}\left ( s\right ) ds\right ) d\tau \right ] \Phi _{n}\left ( x\right ) \tag {3} \end {equation} At \(t=0\)\begin {align*} f\left ( x\right ) & =\sum _{n=1}^{\infty }a_{n}\left ( 0\right ) \Phi _{n}\left ( x\right ) \\ \int _{0}^{L}f\left ( x\right ) \Phi _{n}\left ( x\right ) dx & =\int _{0}^{L}a_{n}\left ( 0\right ) \Phi _{n}^{2}\left ( x\right ) dx\\ a_{n}\left ( 0\right ) & =\frac {2}{L}\int _{0}^{L}f\left ( x\right ) \Phi _{n}\left ( x\right ) dx \end {align*}

The solution (3) becomes\begin {align*} u\left ( x,t\right ) & =\sum _{n=1}^{\infty }\left [ \left ( \frac {2}{L}\int _{0}^{L}f\left ( s\right ) \Phi _{n}\left ( s\right ) ds\right ) e^{-k\lambda _{n}t}+e^{-k\lambda _{n}t}\int _{0}^{t}\frac {2}{L}e^{k\lambda _{n}\tau }\left ( \int _{0}^{L}Q\left ( s\right ) \Phi _{n}\left ( s\right ) ds\right ) d\tau \right ] \Phi _{n}\left ( x\right ) \\ & =\sum _{n=1}^{\infty }e^{-k\lambda _{n}t}\Phi _{n}\left ( x\right ) \left ( \frac {2}{L}\int _{0}^{L}f\left ( s\right ) \Phi _{n}\left ( s\right ) ds\right ) +\sum _{n=1}^{\infty }e^{-k\lambda _{n}t}\Phi _{n}\left ( x\right ) \left ( \int _{0}^{t}\frac {2}{L}e^{k\lambda _{n}\tau }\left ( \int _{0}^{L}Q\left ( s\right ) \Phi _{n}\left ( s\right ) ds\right ) d\tau \right ) \end {align*}

Where \begin {align*} \Phi _{n}\left ( x\right ) & =\sin \left ( \sqrt {\lambda _{n}}x\right ) \\ \lambda _{n} & =\left ( \frac {n\pi }{L}\right ) ^{2}\qquad n=1,2,3,\cdots \end {align*}

____________________________________________________________________________________

3.1.1.12 [162] with source that depends on space only (special case)

problem number 162

Added July 4, 2019

Solve the heat equation for \(u(x,t)\) \[ u_t= k u_{xx} + Q(x) \] For \(0<x<L\) and \(t>0\). The boundary conditions are \begin {align*} u(0,t) &=0 \\ u(L,t) &= 0\\ \end {align*}

Initial condition is \(u(x,0)=f(x)\) using the following values \begin {align*} L &=5 \\ k &= \frac {1}{10}\\ f(x)&=x(5-x)\\ Q(x)&=x \end {align*}

Mathematica

ClearAll["Global`*"]; 
L=5; k=1/10; f=x*(5-x); Q=x; 
pde =  D[u[x, t], t] == k*D[u[x, t], {x, 2}] + Q; 
bc  = {u[0, t] == 0, u[L, t] == 0}; 
ic  = u[x, 0] == f; 
sol =  AbsoluteTiming[TimeConstrained[DSolve[{pde, ic, bc}, u[x, t], {x, t},Assumptions->{k>0,L>0}], 60*10]]; 
sol = sol/.K[1]->n;
 

\[\left \{\left \{u(x,t)\to \sum _{n=1}^{\infty }-\frac {100 \left (-1+(-1)^n\right ) e^{-\frac {1}{250} n^2 \pi ^2 t} \sin \left (\frac {n \pi x}{5}\right )}{n^3 \pi ^3}+\sum _{n=1}^{\infty }-\frac {2500 (-1)^n \left (1-e^{-\frac {1}{250} n^2 \pi ^2 t}\right ) \sin \left (\frac {n \pi x}{5}\right )}{n^3 \pi ^3}\right \}\right \}\]

Maple

restart; 
L=5; 
k=1/10; 
f=x*(5-x); 
Q=x; 
pde := diff(u(x,t),t)= k*diff(u(x,t),x$2) + Q; 
bc  := u(0, t) = 0, u(L, t) = 0; 
ic  := u(x, 0) = f; 
cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol', pdsolve([pde, ic, bc], u(x, t)) assuming L>0,k>0),output='realtime'));
 

\[u \left ( x,t \right ) =1/2\,{\frac {1}{k} \left ( 2\,\sum _{n=1}^{\infty }2\,{\frac { \left ( -{\pi }^{2}fk{n}^{2}+{L}^{2}Q \right ) \left ( \left ( -1 \right ) ^{n}-1 \right ) }{k{n}^{3}{\pi }^{3}}\sin \left ( {\frac {n\pi \,x}{L}} \right ) {{\rm e}^{-{\frac {{\pi }^{2}{n}^{2}kt}{{L}^{2}}}}}}k+Qx \left ( L-x \right ) \right ) }\]

Hand solution

Solve \begin {align*} u_{t} & =ku_{xx}+Q\left ( x\right ) \\ u\left ( 0,t\right ) & =0\\ u\left ( L,0\right ) & =0\\ u\left ( x,0\right ) & =f\left ( x\right ) \end {align*}

With \(k=\frac {1}{10},L=5,f\left ( x\right ) =x\left ( 5-x\right ) ,Q\left ( x\right ) =x.\)

The general problem above was solved in 3.1.1.11 on page 445 and the solution is\[ u\left ( x,t\right ) =\sum _{n=1}^{\infty }e^{-k\lambda _{n}t}\Phi _{n}\left ( x\right ) \left ( \frac {2}{L}\int _{0}^{L}f\left ( s\right ) \Phi _{n}\left ( s\right ) ds\right ) +\sum _{n=1}^{\infty }e^{-k\lambda _{n}t}\Phi _{n}\left ( x\right ) \left ( \int _{0}^{t}\frac {2}{L}e^{k\lambda _{n}\tau }\left ( \int _{0}^{L}Q\left ( s\right ) \Phi _{n}\left ( s\right ) ds\right ) d\tau \right ) \] Where \begin {align*} \Phi _{n}\left ( x\right ) & =\sin \left ( \sqrt {\lambda _{n}}x\right ) \\ \lambda _{n} & =\left ( \frac {n\pi }{L}\right ) ^{2}\qquad n=1,2,3,\cdots \end {align*}

Substituting the specific values given above into this solution gives\begin {align*} u\left ( x,t\right ) & =\sum _{n=1}^{\infty }e^{-\frac {1}{10}\left ( \frac {n\pi }{5}\right ) ^{2}t}\sin \left ( \frac {n\pi }{5}x\right ) \left ( \frac {2}{5}\int _{0}^{5}s\left ( 5-s\right ) \sin \left ( \frac {n\pi }{5}s\right ) ds\right ) \\ & +\sum _{n=1}^{\infty }e^{-\frac {1}{10}\left ( \frac {n\pi }{5}\right ) ^{2}t}\sin \left ( \frac {n\pi }{5}x\right ) \left ( \int _{0}^{t}\frac {2}{5}e^{\frac {1}{10}\left ( \frac {n\pi }{5}\right ) ^{2}\tau }\left ( \int _{0}^{5}s\sin \left ( \frac {n\pi }{5}s\right ) ds\right ) d\tau \right ) \end {align*}

Animation is below

Source code used for the above

____________________________________________________________________________________

3.1.1.13 [163] with source that depends on space and time (general case)

problem number 163

Added June 23, 2019

Solve the heat equation for \(u(x,t)\) \[ u_t= k u_{xx} + Q(x,t) \] For \(0<x<L\) and \(t>0\). The boundary conditions are \begin {align*} u(0,t)&=0 \\ u(L,t) &= 0\\ \end {align*}

Initial condition is \(u(x,0)=f(x)\)

Mathematica

ClearAll["Global`*"]; 
pde =  D[u[x, t], t] == k*D[u[x, t], {x, 2}] + Q[x,t]; 
bc  = {u[0, t] == 0, u[L, t] == 0}; 
ic  = u[x, 0] == f[x]; 
sol =  AbsoluteTiming[TimeConstrained[DSolve[{pde, ic, bc}, u[x, t], {x, t},Assumptions->{k>0,L>0}], 60*10]];
 

Failed

Maple

restart; 
pde := diff(u(x,t),t)= k*diff(u(x,t),x$2) + Q(x,t); 
bc  := u(0, t) = 0, u(L, t) = 0; 
ic  := u(x, 0) = f(x); 
cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol', pdsolve([pde, ic, bc], u(x, t)) assuming L>0,k>0),output='realtime'));
 

\[u \left ( x,t \right ) =\sum _{n=1}^{\infty } \left ( 2\,{\frac {1}{L}\sin \left ( {\frac {n\pi \,x}{L}} \right ) {{\rm e}^{-{\frac {{\pi }^{2}{n}^{2}kt}{{L}^{2}}}}}\int _{0}^{L}\!f \left ( \tau \right ) \sin \left ( {\frac {\pi \,n\tau }{L}} \right ) \,{\rm d}\tau } \right ) +\int _{0}^{t}\!\sum _{n=1}^{\infty } \left ( 2\,{\frac {1}{L}\sin \left ( {\frac {n\pi \,x}{L}} \right ) {{\rm e}^{-{\frac {{\pi }^{2}{n}^{2}k \left ( t-\tau \right ) }{{L}^{2}}}}}\int _{0}^{L}\!Q \left ( x,\tau \right ) \sin \left ( {\frac {n\pi \,x}{L}} \right ) \,{\rm d}x} \right ) \,{\rm d}\tau \]

Hand solution

Solving

\begin {align} u_{t} & =kv_{xx}+Q\left ( x,t\right ) \tag {1}\\ u\left ( 0,t\right ) & =0\nonumber \\ u\left ( L,t\right ) & =0\nonumber \\ u\left ( x,0\right ) & =f\left ( x\right ) \nonumber \end {align}

Let the solution be\begin {equation} u\left ( x,t\right ) =\sum _{n=1}^{\infty }a_{n}\left ( t\right ) \Phi _{n}\left ( x\right ) \tag {1} \end {equation} Where \(\Phi _{n}\left ( x\right ) \) are the eigenfunctions of the eigenvalue problem for the pde \(u_{t}=ku_{xx}\) with \(u\left ( 0,x\right ) =0,u\left ( L,x\right ) =0\). This was solved in problem 3.1.1.1 on page 397 and \(\Phi _{n}\left ( x\right ) \) was found as\begin {align*} \Phi _{n}\left ( x\right ) & =\sin \left ( \sqrt {\lambda _{n}}x\right ) \\ \lambda _{n} & =\left ( \frac {n\pi }{L}\right ) ^{2}\qquad n=1,2,3,\cdots \end {align*}

Hence (1) becomes\begin {equation} u\left ( x,t\right ) =\sum _{n=1}^{\infty }a_{n}\left ( t\right ) \sin \left ( \sqrt {\lambda _{n}}x\right ) \tag {1A} \end {equation} Substituting this back into the original given PDE gives\[ \sum _{n=1}^{\infty }a_{n}^{\prime }\left ( t\right ) \Phi _{n}\left ( x\right ) =k\sum _{n=1}^{\infty }a_{n}\left ( t\right ) \Phi _{n}^{\prime \prime }\left ( x\right ) +\sum _{n=1}^{\infty }q_{n}\left ( t\right ) \Phi _{n}\left ( x\right ) \] Where \(Q\left ( x,t\right ) =\sum _{n=1}^{\infty }q_{n}\left ( t\right ) \Phi _{n}\left ( x\right ) \). Since \(\Phi _{n}^{\prime \prime }\left ( x\right ) =-\lambda _{n}\Phi _{n}\left ( x\right ) \), then the above simplifies to\begin {align} \sum _{n=1}^{\infty }a_{n}^{\prime }\left ( t\right ) \Phi _{n}\left ( x\right ) & =-k\sum _{n=1}^{\infty }a_{n}\left ( t\right ) \lambda _{n}\Phi _{n}\left ( x\right ) +\sum _{n=1}^{\infty }q_{n}\left ( t\right ) \Phi _{n}\left ( x\right ) \nonumber \\ a_{n}^{\prime }\left ( t\right ) +k\lambda _{n}a_{n}\left ( t\right ) & =q_{n}\left ( t\right ) \tag {2} \end {align}

We now need to find \(q_{n}\left ( t\right ) \). By orthogonality\[ \int _{0}^{L}Q\left ( x,t\right ) \Phi _{n}\left ( x\right ) dx=\int _{0}^{L}q_{n}\left ( t\right ) \Phi _{n}^{2}\left ( x\right ) dx \] But \(\int _{0}^{L}\Phi _{n}^{2}\left ( x\right ) dx=\int _{0}^{L}\sin ^{2}\left ( \frac {n\pi }{L}x\right ) dx=\frac {L}{2}\) and the above becomes\[ q_{n}\left ( t\right ) =\frac {2}{L}\int _{0}^{L}Q\left ( x,t\right ) \Phi _{n}\left ( x\right ) dx \] Using the above in (2) gives\[ a_{n}^{\prime }\left ( t\right ) +k\lambda _{n}a_{n}\left ( t\right ) =\frac {2}{L}\int _{0}^{L}Q\left ( x,t\right ) \Phi _{n}\left ( x\right ) dx \] The integrating factor is \(I=e^{k\lambda _{n}t}\). Hence the above becomes\begin {align*} \frac {d}{dt}\left ( a_{n}\left ( t\right ) e^{k\lambda _{n}t}\right ) & =\frac {2}{L}e^{k\lambda _{n}t}\int _{0}^{L}Q\left ( x,t\right ) \Phi _{n}\left ( x\right ) dx\\ a_{n}\left ( t\right ) e^{k\lambda _{n}t} & =\int _{0}^{t}\frac {2}{L}e^{k\lambda _{n}s}\left ( \int _{0}^{L}Q\left ( x,s\right ) \Phi _{n}\left ( x\right ) dx\right ) ds+a_{n}\left ( 0\right ) \\ a_{n}\left ( t\right ) & =a_{n}\left ( 0\right ) e^{-k\lambda _{n}t}+e^{-k\lambda _{n}t}\int _{0}^{t}\frac {2}{L}e^{k\lambda _{n}s}\left ( \int _{0}^{L}Q\left ( x,s\right ) \Phi _{n}\left ( x\right ) dx\right ) ds \end {align*}

Therefore the solution (1A) becomes\begin {equation} u\left ( x,t\right ) =\sum _{n=1}^{\infty }\left [ a_{n}\left ( 0\right ) e^{-k\lambda _{n}t}+e^{-k\lambda _{n}t}\int _{0}^{t}\frac {2}{L}e^{k\lambda _{n}\tau }\left ( \int _{0}^{L}Q\left ( s,\tau \right ) \Phi _{n}\left ( s\right ) ds\right ) d\tau \right ] \Phi _{n}\left ( x\right ) \tag {3} \end {equation} At \(t=0\)\begin {align*} f\left ( x\right ) & =\sum _{n=1}^{\infty }a_{n}\left ( 0\right ) \Phi _{n}\left ( x\right ) \\ \int _{0}^{L}f\left ( x\right ) \Phi _{n}\left ( x\right ) dx & =\int _{0}^{L}a_{n}\left ( 0\right ) \Phi _{n}^{2}\left ( x\right ) dx\\ a_{n}\left ( 0\right ) & =\frac {2}{L}\int _{0}^{L}f\left ( x\right ) \Phi _{n}\left ( x\right ) dx \end {align*}

The solution (3) becomes\begin {align*} u\left ( x,t\right ) & =\sum _{n=1}^{\infty }\left [ \left ( \frac {2}{L}\int _{0}^{L}f\left ( s\right ) \Phi _{n}\left ( s\right ) ds\right ) e^{-k\lambda _{n}t}+e^{-k\lambda _{n}t}\int _{0}^{t}\frac {2}{L}e^{k\lambda _{n}\tau }\left ( \int _{0}^{L}Q\left ( s,\tau \right ) \Phi _{n}\left ( s\right ) ds\right ) d\tau \right ] \Phi _{n}\left ( x\right ) \\ & =\sum _{n=1}^{\infty }e^{-k\lambda _{n}t}\Phi _{n}\left ( x\right ) \left ( \frac {2}{L}\int _{0}^{L}f\left ( s\right ) \Phi _{n}\left ( s\right ) ds\right ) +\sum _{n=1}^{\infty }e^{-k\lambda _{n}t}\Phi _{n}\left ( x\right ) \left ( \int _{0}^{t}\frac {2}{L}e^{k\lambda _{n}\tau }\left ( \int _{0}^{L}Q\left ( s,\tau \right ) \Phi _{n}\left ( s\right ) ds\right ) d\tau \right ) \end {align*}

Where \begin {align*} \Phi _{n}\left ( x\right ) & =\sin \left ( \sqrt {\lambda _{n}}x\right ) \\ \lambda _{n} & =\left ( \frac {n\pi }{L}\right ) ^{2}\qquad n=1,2,3,\cdots \end {align*}

____________________________________________________________________________________

3.1.1.14 [164] with source that depends on space and time (special case)

problem number 164

Added July 5, 2019

Solve the heat equation for \(u(x,t)\) \[ u_t= k u_{xx} + Q(x,t) \] For \(0<x<L\) and \(t>0\). The boundary conditions are \begin {align*} u(0,t)&=0 \\ u(L,t) &= 0\\ \end {align*}

Initial condition is \(u(x,0)=f(x)\). Using the following values \begin {align*} L &=\pi \\ k &= \frac {1}{300}\\ Q(x,t) &= e^{-t} \sin (3 x)\\ f(x) &= x(\pi -x) \end {align*}

Mathematica

ClearAll["Global`*"]; 
L=Pi; f=x*(Pi-x); k=1/300; Q=Exp[-t]*Sin[3*x]; 
pde =  D[u[x, t], t] == k*D[u[x, t], {x, 2}] + Q; 
bc  = {u[0, t] == 0, u[L, t] == 0}; 
ic  = u[x, 0] == f; 
sol =  AbsoluteTiming[TimeConstrained[DSolve[{pde, ic, bc}, u[x, t], {x, t}], 60*10]]; 
sol = sol /. K[1] -> n
 

\[\left \{\left \{u(x,t)\to \sum _{n=1}^{\infty }-\frac {4 \left (-1+(-1)^n\right ) e^{-\frac {n^2 t}{300}} \sin (n x)}{n^3 \pi }+\frac {100}{97} e^{-t} \left (e^{97 t/100}-1\right ) \sin (3 x)\right \}\right \}\]

Maple

restart; 
L:=Pi; 
f:=x*(Pi-x); 
k:=1/300; 
Q:=exp(-t)*sin(3*x); 
pde := diff(u(x,t),t)= k*diff(u(x,t),x$2) + Q; 
bc  := u(0, t) = 0, u(L, t) = 0; 
ic  := u(x, 0) = f; 
cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol', pdsolve([pde, ic, bc], u(x, t))),output='realtime'));
 

\[u \left ( x,t \right ) =\sum _{n=1}^{\infty }-4\,{\frac { \left ( -1+ \left ( -1 \right ) ^{n} \right ) \sin \left ( nx \right ) }{{n}^{3}\pi }{{\rm e}^{-{\frac {{n}^{2}t}{300}}}}}-{\frac {100\,{{\rm e}^{-t}}\sin \left ( 3\,x \right ) }{97}}+{\frac {100\,\sin \left ( 3\,x \right ) }{97}{{\rm e}^{-{\frac {3\,t}{100}}}}}\]

Hand solution

Solving \begin {align*} u_{t} & =ku_{xx}+Q\left ( x,t\right ) \\ u\left ( 0,t\right ) & =0\\ u\left ( L,0\right ) & =0\\ u\left ( x,0\right ) & =f\left ( x\right ) \end {align*}

With \(k=\frac {1}{300},L=\pi ,f\left ( x\right ) =x\left ( \pi -x\right ) ,Q\left ( x\right ) =e^{-t}\sin \left ( 3x\right ) .\)

The general problem above was solved in 3.1.6.4 on page 798 and the solution is\begin {align*} u\left ( x,t\right ) & =\sum _{n=1}^{\infty }e^{-k\lambda _{n}t}\Phi _{n}\left ( x\right ) \left ( \frac {2}{L}\int _{0}^{L}f\left ( s\right ) \Phi _{n}\left ( s\right ) ds\right ) \\ & +\sum _{n=1}^{\infty }e^{-k\lambda _{n}t}\Phi _{n}\left ( x\right ) \left ( \int _{0}^{t}\frac {2}{L}e^{k\lambda _{n}\tau }\left ( \int _{0}^{L}Q\left ( s,\tau \right ) \Phi _{n}\left ( s\right ) ds\right ) d\tau \right ) \end {align*}

Where\begin {align*} \Phi _{n}\left ( x\right ) & =\sin \left ( \sqrt {\lambda _{n}}x\right ) \\ \lambda _{n} & =\left ( \frac {n\pi }{L}\right ) ^{2}\qquad n=1,2,3,\cdots \end {align*}

Substituting the specific values given above into this solution gives\begin {align*} \Phi _{n}\left ( x\right ) & =\sin \left ( nx\right ) \\ \lambda _{n} & =n^{2}\qquad n=1,2,3,\cdots \end {align*}

And\begin {align*} u\left ( x,t\right ) & =\sum _{n=1}^{\infty }e^{-\frac {1}{300}n^{2}t}\sin \left ( nx\right ) \left ( \frac {2}{\pi }\int _{0}^{\pi }s\left ( \pi -s\right ) \sin \left ( ns\right ) ds\right ) \\ & +\sum _{n=1}^{\infty }e^{-\frac {1}{300}n^{2}t}\sin \left ( nx\right ) \left ( \int _{0}^{t}\frac {2}{\pi }e^{\frac {1}{300}n^{2}\tau }e^{-\tau }\left ( \int _{0}^{\pi }\sin \left ( 3s\right ) \sin \left ( ns\right ) ds\right ) d\tau \right ) \end {align*}

But \(\int _{0}^{\pi }s\left ( \pi -s\right ) \sin \left ( ns\right ) ds=\frac {2-2\left ( -1\right ) ^{n}}{n^{3}}\) and \(\int _{0}^{\pi }\sin \left ( 3s\right ) \sin \left ( ns\right ) ds=0\)  when \(n\neq 3\) and for \(n=3\) it is \(\frac {\pi }{2}\). Hence the above reduces to\begin {align*} u\left ( x,t\right ) & =4\sum _{n=1}^{\infty }\left ( \frac {1-\left ( -1\right ) ^{n}}{\pi n^{3}}\right ) e^{-\frac {1}{300}n^{2}t}\sin \left ( nx\right ) +e^{-\frac {1}{300}\left ( 3\right ) ^{2}t}\sin \left ( 3x\right ) \left ( \int _{0}^{t}\frac {2}{\pi }e^{\frac {1}{300}\left ( 9\right ) ^{2}\tau }e^{-\tau }\left ( \frac {\pi }{2}\right ) d\tau \right ) \\ & =4\sum _{n=1}^{\infty }\left ( \frac {1-\left ( -1\right ) ^{n}}{\pi n^{3}}\right ) e^{-\frac {1}{300}n^{2}t}\sin \left ( nx\right ) +e^{-\frac {9t}{300}}\sin \left ( 3x\right ) \left ( \int _{0}^{t}e^{\frac {9\tau }{300}}e^{-\tau }d\tau \right ) \end {align*}

But \(\int _{0}^{t}e^{\frac {9\tau }{300}}e^{-\tau }d\tau =\frac {100}{97}-\frac {100e^{\frac {-97}{100}t}}{97}\). Hence the above becomes\begin {align*} u\left ( x,t\right ) & =4\sum _{n=1}^{\infty }\left ( \frac {1-\left ( -1\right ) ^{n}}{\pi n^{3}}\right ) e^{-\frac {1}{300}n^{2}t}\sin \left ( nx\right ) +e^{-\frac {9t}{300}}\sin \left ( 3x\right ) \left ( \frac {100}{97}-\frac {100e^{\frac {-97}{100}t}}{97}\right ) \\ & =4\sum _{n=1}^{\infty }\left ( \frac {1-\left ( -1\right ) ^{n}}{\pi n^{3}}\right ) e^{-\frac {1}{300}n^{2}t}\sin \left ( nx\right ) +\sin \left ( 3x\right ) \left ( \frac {100}{97}e^{-\frac {3t}{100}}-\frac {100e^{-t}}{97}\right ) \\ & =4\sum _{n=1}^{\infty }\left ( \frac {1-\left ( -1\right ) ^{n}}{\pi n^{3}}\right ) e^{-\frac {1}{300}n^{2}t}\sin \left ( nx\right ) -\frac {100e^{-t}}{97}\sin \left ( 3x\right ) +\frac {100}{97}e^{-\frac {3t}{100}}\sin \left ( 3x\right ) \end {align*}

Animation is below

Source code used for the above

____________________________________________________________________________________

3.1.1.15 [165] Math 4567 Exam

problem number 165

Added April 3, 2019.

Exam question. Math 4567 UMN. Spring 2019.

Solve the heat equation \[ u_t = u_{xx} + t(\pi -x) \] For \(0<x<\pi \) and \(t>0\). The boundary conditions are \begin {align*} u(0,t) &= 0 \\ u(\pi ,t) &=0 \end {align*}

Initial condition is \(u(x,0)=0\).

Mathematica

ClearAll["Global`*"]; 
pde =  D[u[x, t], t] == D[u[x, t], {x, 2}] + t*(Pi-x); 
bc  = {u[0,t] == 0, u[Pi,t] == 0}; 
ic  = u[x, 0] == 0; 
sol =  AbsoluteTiming[TimeConstrained[DSolve[{pde, ic, bc}, u[x, t], x, t, Assumptions -> t > 0], 60*10]]; 
sol =  sol /. K[1] -> n;
 

\[\left \{\left \{u(x,t)\to \sum _{n=1}^{\infty }\frac {2 \left (t n^2+e^{-n^2 t}-1\right ) \sin (n x)}{n^5}\right \}\right \}\]

Maple

restart; 
interface(showassumed=0); 
pde :=  diff(u(x,t),t)=diff(u(x,t),x$2)+t*(Pi-x); 
ic  :=  u(x,0)=0; 
bc  :=  u(0,t)=0, u(Pi,t)=0; 
cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol', pdsolve([pde,ic,bc],u(x,t)) assuming t>0),output='realtime'));
 

\[u \left ( x,t \right ) =\sum _{n=1}^{\infty }2\,{\frac {\sin \left ( nx \right ) \left ( {n}^{2}t+{{\rm e}^{-{n}^{2}t}}-1 \right ) }{{n}^{5}}}\]

Hand solution

Let \(u\left ( x,t\right ) =\sum _{n=1}^{\infty }B_{n}\left ( t\right ) X_{n}\left ( x\right ) \), where \(X_{n}\left ( x\right ) \) are the eigenfunctions of the homogeneous PDE \(u_{t}=u_{xx}\). These are known to be \(X_{n}\left ( x\right ) =\sin \left ( \sqrt {\lambda _{n}}x\right ) \) where \(\lambda _{n}=n^{2},n=1,2,3,\cdots \). Hence\[ X_{n}\left ( x\right ) =\sin \left ( nx\right ) \qquad n=1,2,3,\cdots \] Therefore the solution becomes\begin {equation} u\left ( x,t\right ) =\sum _{n=1}^{\infty }B_{n}\left ( t\right ) \sin \left ( nx\right ) \tag {A} \end {equation} Substituting this into the PDE \(u_{t}=u_{xx}+t\left ( \pi -x\right ) \) gives\[ \sum _{n=1}^{\infty }B_{n}^{\prime }\left ( t\right ) X_{n}\left ( x\right ) =\sum _{n=1}^{\infty }B_{n}\left ( t\right ) X_{n}^{\prime \prime }\left ( x\right ) +\sum _{n=1}^{\infty }q_{n}\left ( t\right ) X_{n}\left ( x\right ) \] Where \(\sum _{n=1}^{\infty }q_{n}\left ( t\right ) X_{n}\left ( x\right ) \) is the Fourier series expansion of \(t\left ( \pi -x\right ) \). But \(X_{n}^{\prime \prime }\left ( x\right ) =-\lambda _{n}X_{n}\left ( x\right ) =-n^{2}X_{n}\left ( x\right ) \). Hence the above becomes\begin {align} \sum _{n=1}^{\infty }B_{n}^{\prime }\left ( t\right ) X_{n}\left ( x\right ) & =-\sum _{n=1}^{\infty }n^{2}B_{n}\left ( t\right ) X_{n}\left ( x\right ) +\sum _{n=1}^{\infty }q_{n}\left ( t\right ) X_{n}\left ( x\right ) \nonumber \\ B_{n}^{\prime }\left ( t\right ) X_{n}\left ( x\right ) +n^{2}B_{n}\left ( t\right ) X_{n}\left ( x\right ) & =q_{n}\left ( t\right ) X_{n}\left ( x\right ) \nonumber \\ B_{n}^{\prime }\left ( t\right ) +n^{2}B_{n}\left ( t\right ) & =q_{n}\left ( t\right ) \tag {1} \end {align}

This is first order ODE which is now solved for \(B_{n}\). But first \(q_{n}\left ( t\right ) \) is found. Since \[ t\left ( \pi -x\right ) =\sum _{n=1}^{\infty }q_{n}\left ( t\right ) X_{n}\left ( x\right ) \] Applying orthogonality. Integrating both sides and multiplying by \(X_{m}\left ( x\right ) \) gives\begin {align*} \int _{0}^{\pi }t\left ( \pi -x\right ) X_{m}\left ( x\right ) dx & =\sum _{n=1}^{\infty }q_{n}\left ( t\right ) \int _{0}^{\pi }X_{n}\left ( x\right ) X_{m}\left ( x\right ) dx\\ & =\sum _{n=1}^{\infty }q_{n}\left ( t\right ) \int _{0}^{\pi }\sin \left ( nx\right ) \sin \left ( mx\right ) dx\\ & =q_{m}\left ( t\right ) \int _{0}^{\pi }\sin ^{2}\left ( mx\right ) dx\\ & =\frac {\pi }{2}q_{m}\left ( t\right ) \end {align*}

Therefore\begin {align*} q_{n}\left ( t\right ) & =\frac {2}{\pi }\int _{0}^{\pi }t\left ( \pi -x\right ) \sin \left ( nx\right ) dx\\ & =\frac {2t\left ( \pi n-\sin \left ( n\pi \right ) \right ) }{\pi n^{2}} \end {align*}

But \(n\) is integer, hence the above simplifies to \[ q_{n}\left ( t\right ) =\frac {2t}{n}\] Hence (1) becomes\[ B_{n}^{\prime }\left ( t\right ) +n^{2}B_{n}\left ( t\right ) =\frac {2t}{n}\] Integrating factor is \(I=e^{\int n^{2}dt}=e^{n^{2}t}\). The above becomes\[ \frac {d}{dt}\left ( B_{n}e^{n^{2}t}\right ) =\frac {2t}{n}e^{n^{2}t}\] Integrating\begin {align} B_{n}e^{n^{2}t} & =\frac {2}{n}\int _{0}^{t}se^{n^{2}s}ds+C\nonumber \\ B_{n}\left ( t\right ) & =\frac {2}{n}e^{-n^{2}t}\int _{0}^{t}se^{n^{2}s}ds+Ce^{-n^{2}t}\tag {2} \end {align}

At \(t=0,B_{n}\left ( 0\right ) =0\). The above reduces to\[ 0=C \] Therefore (2) becomes\begin {align*} B_{n}\left ( t\right ) & =\frac {2}{n}e^{-n^{2}t}\int _{0}^{t}se^{n^{2}s}ds\\ & =\frac {2}{n}\int _{0}^{t}se^{n^{2}\left ( s-t\right ) }ds\\ & =\frac {2\left ( n^{2}t+e^{-n^{2}t}-1\right ) }{n^{5}} \end {align*}

Hence Eq. (A) becomes\[ u\left ( x,t\right ) =\sum _{n=1}^{\infty }\frac {2\left ( n^{2}t+e^{-n^{2}t}-1\right ) }{n^{5}}\sin \left ( nx\right ) \]

____________________________________________________________________________________

3.1.1.16 [166] With source

problem number 166

Taken from Maple PDE help pages

Solve the heat equation for \(u(x,t)\) \[ u_t= k u_{xx} + Q(x,t) \] For \(0<x<1\) and \(t>0\). The boundary conditions are \begin {align*} u(0,t) &= 0 \\ u(1,t) &= 0 \\ \end {align*}

Initial condition is \(u(x,0)=f(x)\)

Mathematica

ClearAll["Global`*"]; 
pde =  D[u[x, t], t] == k*D[u[x, t], {x, 2}] + Q[x, t]; 
bc  = {u[0, t] == 0, u[1, t] == 0}; 
ic  = u[x, 0] == f[x]; 
sol =  AbsoluteTiming[TimeConstrained[DSolve[{pde, ic, bc}, u[x, t], x, t, Assumptions -> {k > 0, t > 0, x > 0, x < 1}], 60*10]];
 

Failed

Maple

restart; 
interface(showassumed=0); 
pde := diff(u(x, t), t) = k*(diff(u(x, t), x, x))+Q(x, t); 
bc  := u(0, t) = 0, u(l, t) = 0; 
ic  := u(x, 0) = f(x); 
cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol', pdsolve([pde, bc,ic], u(x, t)) assuming 0 <= x and  x <= l and k>0 and t>0),output='realtime'));
 

\[u \left ( x,t \right ) =\sum _{n=1}^{\infty } \left ( 2\,{\frac {1}{l}\sin \left ( {\frac {\pi \,nx}{l}} \right ) {{\rm e}^{-{\frac {{\pi }^{2}{n}^{2}kt}{{l}^{2}}}}}\int _{0}^{l}\!f \left ( x \right ) \sin \left ( {\frac {\pi \,nx}{l}} \right ) \,{\rm d}x} \right ) +\int _{0}^{t}\!\sum _{n=1}^{\infty } \left ( 2\,{\frac {1}{l}\sin \left ( {\frac {\pi \,nx}{l}} \right ) {{\rm e}^{{\frac {{\pi }^{2}{n}^{2}k \left ( -t+\tau \right ) }{{l}^{2}}}}}\int _{0}^{l}\!Q \left ( x,\tau \right ) \sin \left ( {\frac {\pi \,nx}{l}} \right ) \,{\rm d}x} \right ) \,{\rm d}\tau \]

____________________________________________________________________________________

3.1.1.17 [167] special initial condition

problem number 167

Added April 28, 2019.

Taken from https://mathematica.stackexchange.com/questions/197155/solving-a-heat-equation-problem

Solve \(u(x,t)\) \[ u_t = u_{xx} -9 u_x \] For \(0<x<1\) and \(t>0\). The boundary conditions are \begin {align*} u(0,t) &= 0\\ u(1,t) &= 0 \end {align*}

Initial condition \(u(x,0)=e^{\frac {45}{10}}( 5 \sin (\pi x)+ 9 \sin (2 \pi x)+2 \sin (3 \pi x)) \)

Mathematica

ClearAll["Global`*"]; 
pde = D[u[x, t], t] == D[u[x, t], {x, 2}] - 9*D[u[x, t], x]; 
ic  = u[x, 0] == Exp[45/10 x]*(5 Sin[Pi*x] + 9 Sin[2*Pi*x] + 2 Sin[3*Pi*x]); 
bc  = {u[0, t] == 0, u[1, t] == 0}; 
sol = AbsoluteTiming[TimeConstrained[DSolve[{pde, ic, bc}, u[x, t], {x, t}], 60*10]];
 

\[\left \{\left \{u(x,t)\to e^{-\frac {9}{4} \left (\left (9+4 \pi ^2\right ) t-2 x\right )} \sin (\pi x) \left (18 e^{5 \pi ^2 t} \cos (\pi x)+5 e^{8 \pi ^2 t}+4 \cos (2 \pi x)+2\right )\right \}\right \}\]

Maple

restart; 
pde := diff(u(x,t),t)= diff(u(x, t), x$2) - 9*diff(u(x,t),x); 
bc  := u(0,t)=0,u(1,t)=0; 
ic  := u(x, 0) = exp(45/10*x)*(5*sin(Pi*x) + 9*sin(2*Pi*x) + 2*sin(3*Pi*x)); 
cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol', pdsolve({pde, ic, bc}, u(x, t))),output='realtime'));
 

server hangs

Hand solution

Solve

\[ u_{t}=u_{xx}-9u_{x}\] IC\[ u\left ( x,0\right ) =e^{\frac {45}{10}x}\left ( 5\sin \left ( \pi x\right ) +9\sin \left ( 2\pi x\right ) +2\sin \left ( 3\pi x\right ) \right ) \] BC\begin {align*} u\left ( 0,x\right ) & =0\\ u\left ( 1,x\right ) & =0 \end {align*}

Let \(u=X\left ( x\right ) T\left ( t\right ) \), the PDE becomes\begin {align*} T^{\prime }X & =X^{\prime \prime }T-9X^{\prime }T\\ \frac {T^{\prime }}{T} & =\frac {X^{\prime \prime }}{X}-9\frac {X^{\prime }}{X}=-\lambda \end {align*}

Where \(\lambda \) is the seperation constant. From B.C. we know \(\lambda >0\). Hence the eigenvalue ODE is\[ X^{\prime \prime }-9X^{\prime }+\lambda X=0 \] The solution to the above is\begin {align*} X\left ( x\right ) & =C_{1}e^{\frac {1}{2}\left ( 9-\sqrt {81-4\lambda }\right ) x}+C_{2}e^{\frac {1}{2}\left ( 9+\sqrt {81-4\lambda }\right ) x}\\ & =e^{\frac {9x}{2}}\left ( C_{1}e^{-\frac {1}{2}\sqrt {81-4\lambda }x}+C_{2}e^{\frac {1}{2}\sqrt {81-4\lambda }x}\right ) \end {align*}

At \(X\left ( 0\right ) =0\) this gives\[ 0=C_{1}+C_{2}\] And at \(X\left ( 1\right ) =0\)\begin {align*} 0 & =e^{\frac {9}{2}}\left ( C_{1}e^{-\frac {1}{2}\sqrt {81-4\lambda }}+C_{2}e^{\frac {1}{2}\sqrt {81-4\lambda }}\right ) \\ 0 & =e^{\frac {9}{2}}\left ( C_{1}e^{-\frac {1}{2}\sqrt {81-4\lambda }}-C_{1}e^{\frac {1}{2}\sqrt {81-4\lambda }}\right ) \\ 0 & =C_{1}e^{\frac {9}{2}}\left ( e^{-\frac {1}{2}\sqrt {81-4\lambda }}-e^{\frac {1}{2}\sqrt {81-4\lambda }}\right ) \end {align*}

For nontrivial solution we want\begin {align} e^{-\frac {1}{2}\sqrt {81-4\lambda }}-e^{\frac {1}{2}\sqrt {81-4\lambda }} & =0\nonumber \\ e^{-\frac {1}{2}\sqrt {81-4\lambda }} & =e^{\frac {1}{2}\sqrt {81-4\lambda }} \tag {1} \end {align}

Case \(81-4\lambda >0\)

This means \(81-4\lambda \) must be zero or\[ \lambda =\frac {81}{4}\] But using this eigenvalue makes the eigenfunction zero as shown below\begin {align*} X\left ( x\right ) & =e^{\frac {9x}{2}}\left ( C_{1}e^{-\frac {1}{2}\sqrt {81-4\lambda }x}-C_{1}e^{\frac {1}{2}\sqrt {81-4\lambda }x}\right ) \\ & =C_{1}e^{\frac {9x}{2}}\left ( e^{-\frac {1}{2}\sqrt {81-4\lambda }x}-e^{\frac {1}{2}\sqrt {81-4\lambda }x}\right ) \\ & =C_{1}e^{\frac {9x}{2}}\left ( 1-1\right ) \\ & =0 \end {align*}

Therefore \(\lambda =\frac {81}{4}\) can not be used as eigenfunction.

Case \(81-4\lambda <0\)

Then (1) becomes\begin {align*} e^{-\frac {i}{2}\sqrt {4\lambda -81}} & =e^{\frac {i}{2}\sqrt {4\lambda -81}}\\ \cos \left ( \frac {1}{2}\sqrt {4\lambda -81}\right ) -i\sin \left ( \frac {1}{2}\sqrt {4\lambda -81}\right ) & =\cos \left ( \frac {1}{2}\sqrt {4\lambda -81}\right ) +i\sin \left ( \frac {1}{2}\sqrt {4\lambda -81}\right ) \\ 2i\sin \left ( \frac {1}{2}\sqrt {4\lambda -81}\right ) & =0\\ \sin \left ( \frac {1}{2}\sqrt {4\lambda -81}\right ) & =0\\ \frac {1}{2}\sqrt {4\lambda -81} & =n\pi \qquad n=1,2,\cdots \end {align*}

Hence\begin {align*} \frac {1}{4}\left ( 4\lambda -81\right ) & =n^{2}\pi ^{2}\\ 4\lambda & =81+4n^{2}\pi ^{2}\\ \lambda _{n} & =\frac {81}{4}+n^{2}\pi ^{2} \end {align*}

The corresponding eigenfunctions are (and since \(C_{2}=-C_{1}\)) then\begin {align*} X_{n}\left ( x\right ) & =C_{n}\left ( e^{\frac {1}{2}\left ( 9-\sqrt {81-4\lambda _{n}}\right ) x}-e^{\frac {1}{2}\left ( 9+\sqrt {81-4\lambda _{n}}\right ) x}\right ) \\ & =C_{n}\left ( e^{\frac {1}{2}\left ( 9-i\sqrt {4\lambda _{n}-81}\right ) x}-e^{\frac {1}{2}\left ( 9+i\sqrt {4\lambda _{n}-81}\right ) x}\right ) \\ & =C_{n}e^{\frac {9x}{2}}\left ( e^{-\frac {i}{2}\sqrt {4\lambda _{n}-81}x}-e^{\frac {i}{2}\sqrt {4\lambda _{n}-81}x}\right ) \\ & =C_{n}e^{\frac {9x}{2}}\left ( \cos \left ( \frac {1}{2}\sqrt {4\lambda _{n}-81}x\right ) -i\sin \left ( \frac {1}{2}\sqrt {4\lambda _{n}-81}x\right ) -\cos \left ( \frac {1}{2}\sqrt {4\lambda _{n}-81}x\right ) -\sin \left ( \frac {1}{2}\sqrt {4\lambda _{n}-81}x\right ) \right ) \\ & =C_{n}e^{\frac {9x}{2}}\left ( -2i\sin \left ( \frac {1}{2}\sqrt {4\lambda _{n}-81}x\right ) \right ) \\ & =A_{n}e^{\frac {9x}{2}}\sin \left ( \frac {1}{2}\sqrt {4\lambda _{n}-81}x\right ) \end {align*}

Hence the solution is\[ u\left ( x,t\right ) =\sum _{n=1}^{\infty }X_{n}\left ( t\right ) T_{n}\left ( t\right ) \] But \(T^{\prime }+\lambda _{n}T=0\) has solution \(T=e^{-\lambda _{n}t}\). Therefore the solution becomes\[ u\left ( x,t\right ) =\sum _{n=1}^{\infty }A_{n}e^{-\lambda _{n}t}e^{\frac {9x}{2}}\sin \left ( \frac {1}{2}\sqrt {4\lambda _{n}-81}x\right ) \] At \(t=0\)\[ e^{\frac {45}{10}x}\left ( 5\sin \left ( \pi x\right ) +9\sin \left ( 2\pi x\right ) +2\sin \left ( 3\pi x\right ) \right ) =\sum _{n=1}^{\infty }A_{n}e^{\frac {9x}{2}}\sin \left ( \frac {1}{2}\sqrt {4\lambda _{n}-81}x\right ) \] But \(\lambda _{n}=\frac {81}{4}+n^{2}\pi ^{2}\). The above becomes\begin {align*} e^{\frac {45}{10}x}\left ( 5\sin \left ( \pi x\right ) +9\sin \left ( 2\pi x\right ) +2\sin \left ( 3\pi x\right ) \right ) & =A_{1}e^{\frac {9x}{2}}\sin \left ( \frac {1}{2}\sqrt {4\left ( \frac {81}{4}+\pi ^{2}\right ) -81}x\right ) \\ & +A_{2}e^{\frac {9x}{2}}\sin \left ( \frac {1}{2}\sqrt {4\left ( \frac {81}{4}+4\pi ^{2}\right ) -81}x\right ) \\ & +A_{3}e^{\frac {9x}{2}}\sin \left ( \frac {1}{2}\sqrt {4\left ( \frac {81}{4}+9\pi ^{2}\right ) -81}x\right ) \\ & +\cdots \end {align*}

Or\begin {align*} e^{\frac {45}{10}x}\left ( 5\sin \left ( \pi x\right ) +9\sin \left ( 2\pi x\right ) +2\sin \left ( 3\pi x\right ) \right ) & =A_{1}e^{\frac {9x}{2}}\sin \left ( \frac {1}{2}\sqrt {4\pi ^{2}}x\right ) \\ & +A_{2}e^{\frac {9x}{2}}\sin \left ( \frac {1}{2}\sqrt {16\pi ^{2}}x\right ) \\ & +A_{3}e^{\frac {9x}{2}}\sin \left ( \frac {1}{2}\sqrt {36\pi ^{2}}x\right ) \\ & +\cdots \end {align*}

Or\begin {align*} e^{\frac {45}{10}x}\left ( 5\sin \left ( \pi x\right ) +9\sin \left ( 2\pi x\right ) +2\sin \left ( 3\pi x\right ) \right ) & =A_{1}e^{\frac {9x}{2}}\sin \left ( \pi x\right ) \\ & +A_{2}e^{\frac {9x}{2}}\sin \left ( 2\pi x\right ) \\ & +A_{3}e^{\frac {9x}{2}}\sin \left ( 3\pi x\right ) \\ & +\cdots \end {align*}

By comparing coefficients, we see that \(A_{1}e^{\frac {9x}{2}}=5e^{\frac {45}{10}x}\) or \(A_{1}=e^{\left ( \frac {45}{10}-\frac {9}{2}\right ) x}=5\) and \(A_{2}=9\) and \(A_{3}=2\) and and all other \(A_{n}\) for \(n>3\) are zero. Hence the solution becomes\begin {align*} u\left ( x,t\right ) & =5e^{-\lambda _{1}t}e^{\frac {9x}{2}}\sin \left ( \frac {1}{2}\sqrt {4\lambda _{1}-81}x\right ) +9e^{-\lambda _{2}t}e^{\frac {9x}{2}}\sin \left ( \frac {1}{2}\sqrt {4\lambda _{2}-81}x\right ) +2e^{-\lambda _{3}t}e^{\frac {9x}{2}}\sin \left ( \frac {1}{2}\sqrt {4\lambda _{3}-81}x\right ) \\ & =e^{-\left ( \frac {81}{4}+\pi ^{2}\right ) t}e^{\frac {9x}{2}}\sin \left ( \pi x\right ) +e^{-\left ( \frac {81}{4}+4\pi ^{2}\right ) t}e^{\frac {9x}{2}}\sin \left ( 2\pi x\right ) +e^{-\left ( \frac {81}{4}+9\pi ^{2}\right ) t}e^{\frac {9x}{2}}\sin \left ( 3\pi x\right ) \\ & =e^{-\frac {81}{4}t+\frac {9}{2}x}\left ( 5e^{-\pi ^{2}t}\sin \left ( \pi x\right ) +9e^{-4\pi ^{2}t}\sin \left ( 2\pi x\right ) +2e^{-9\pi ^{2}t}\sin \left ( 3\pi x\right ) \right ) \end {align*}

____________________________________________________________________________________

3.1.1.18 [168] Diffusion Reaction and Euler-Cauchy Sturm-Liouville

problem number 168

Added May 5, 2019.

Solve \(u(x,t)\) \[ u_t = x^2 u_{xx} + x u_x \] For \(1<x<b\) and \(t>0\). The boundary conditions are \begin {align*} u(1,t) &= 0\\ u(b,t) &= 0 \end {align*}

Initial condition \(u(x,0)=f(x) \)

Mathematica

ClearAll["Global`*"]; 
pde = D[u[x, t], t] == x^2*D[u[x, t], {x, 2}] + x*D[u[x, t], x]; 
ic  = u[x, 0] == f[x]; 
bc  = {u[1, t] == 0, u[b, t] == 0}; 
sol = AbsoluteTiming[TimeConstrained[DSolve[{pde, ic, bc}, u[x, t], {x, t}, Assumptions -> b > 1], 60*10]];
 

Failed

Maple

restart; 
pde := diff( u(x,t),t)= x^2*diff(u(x,t),x$2)+x*diff(u(x,t),x); 
bc  := u(1,t)=0,u(b,t)=0; 
ic  := u(x,0)=f(x); 
cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol', pdsolve({pde, ic, bc}, u(x, t)) assuming b>1 ),output='realtime'));
 

\[u \left ( x,t \right ) =\sum _{n=1}^{\infty } \left ( 2\,{\frac {1}{\ln \left ( b \right ) }\sin \left ( {\frac {\pi \,n\ln \left ( x \right ) }{\ln \left ( b \right ) }} \right ) {{\rm e}^{-{\frac {{\pi }^{2}{n}^{2}t}{ \left ( \ln \left ( b \right ) \right ) ^{2}}}}}\int _{1}^{b}\!{\frac {f \left ( x \right ) }{x}\sin \left ( {\frac {\pi \,n\ln \left ( x \right ) }{\ln \left ( b \right ) }} \right ) }\,{\rm d}x} \right ) \]

____________________________________________________________________________________

3.1.1.19 [169] Diffusion Reaction. Using growth form reaction term

problem number 169

Added December 29, 2018.

Solve for \(u(x,t)\) in \[ u_t = k u_{xx} + r u \] with \(k=\frac {1}{10},r=1\) and \(0<x<1\) and \(t>0\). With boundary conditions \begin {align*} u(0,t) &= 0\\ u(1,t) &=0 \end {align*}

And initial conditions \(u(x,0)=1\).

Mathematica

ClearAll["Global`*"]; 
k = 1/10; 
 r = 1; 
pde =  D[u[x, t], t] == k*D[u[x, t], {x, 2}] + r*u[x, t]; 
bc  = {u[0, t] == 0, u[1, t] == 0}; 
ic  = u[x, 0] == 1; 
sol =  AbsoluteTiming[TimeConstrained[DSolve[{pde, bc, ic}, u[x, t], {x, t}], 60*10]];
 

Failed

Maple

restart; 
k:=1/10; 
r:=1; 
pde := diff(u(x,t), t) = k*diff(u(x, t), x$2) + r*u(x,t); 
bc  := u(0,t)=0,u(1,t)=0; 
ic  := u(x,0) = 1; 
cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol',pdsolve([pde, bc,ic], u(x,t))),output='realtime'));
 

\[u \left ( x,t \right ) =\sum _{n=1}^{\infty }-2\,{\frac { \left ( -1+ \left ( -1 \right ) ^{n} \right ) \sin \left ( \pi \,nx \right ) {{\rm e}^{-1/10\,t \left ( {\pi }^{2}{n}^{2}-10 \right ) }}}{\pi \,n}}\]

Hand solution

Solution added 4/3/2019.\begin {align*} u_{t} & =ku_{xx}+ru\qquad t>0,0<x<1\\ u\left ( 0,t\right ) & =0\\ u\left ( 1,t\right ) & =0\\ u\left ( x,0\right ) & =1 \end {align*}

Let \(u=ve^{rt}\). Hence \(u_{t}=v_{t}e^{rt}+vre^{rt}\) and \(u_{xx}=v_{xx}e^{rt}\). Hence the PDE becomes \(v_{t}e^{rt}+vre^{rt}=v_{xx}e^{rt}+rve^{rt}\) which simplifies to\begin {align*} v_{t} & =kv_{xx}\qquad t>0,0<x<1\\ v\left ( 0,t\right ) & =0\\ v\left ( 1,t\right ) & =0 \end {align*}

The above is now in canonical form, it is standard heat PDE with homogeneous B.C. This has the solution\[ v\left ( x,t\right ) =\sum _{n=1}^{\infty }B_{n}e^{-n^{2}\pi ^{2}t}\sin \left ( n\pi x\right ) \] Therefore\begin {align*} u & =ve^{rt}\\ u & =\sum _{n=1}^{\infty }B_{n}e^{-t\left ( n^{2}\pi ^{2}-r\right ) }\sin \left ( n\pi x\right ) \end {align*}

At \(t=0\) the above becomes\[ 1=\sum _{n=1}^{\infty }B_{n}\sin \left ( n\pi x\right ) \] Hence \(B_{n}\) are \(\sin \) Fourier coefficient of \(1\) which is \begin {align*} B_{n} & =2\int _{0}^{1}\sin \left ( n\pi x\right ) dx\\ & =2\left ( -\frac {1}{n\pi }\right ) \left ( \cos n\pi x\right ) _{0}^{1}\\ & =\frac {-2}{n\pi }\left ( \left ( -1\right ) ^{n}-1\right ) \end {align*}

Hence the solution becomes\[ u=\sum _{n=1}^{\infty }\frac {-2}{n\pi }\left ( \left ( -1\right ) ^{n}-1\right ) e^{-t\left ( n^{2}\pi ^{2}-r\right ) }\sin \left ( n\pi x\right ) \] But \(r=\frac {1}{10}\), therefore\[ u\left ( x,t\right ) =-\frac {2}{\pi }\sum _{n=1}^{\infty }\frac {\left ( \left ( -1\right ) ^{n}-1\right ) }{n}e^{-t\left ( n^{2}\pi ^{2}-\frac {1}{10}\right ) }\sin \left ( n\pi x\right ) \]

____________________________________________________________________________________

3.1.1.20 [170] Diffusion Reaction, using logistic form for reaction term

problem number 170

Added December 29, 2018.

Solve for \(u(x,t)\) in \[ u_t = k u_{xx} + r u\left (1- \frac {u}{\alpha } \right ) \]

with \(k=\frac {1}{100},r=\frac {1}{10},\alpha =10\) and \(0<x<1\) and \(t>0\).

With boundary conditions \begin {align*} u(0,t) &= 0\\ u(1,t) &=0 \end {align*}

And initial conditions \(u(x,0)=1\).

Mathematica

ClearAll["Global`*"]; 
k = 1/100; 
 r = 1/10; 
 alpha = 10; 
pde =  D[u[x, t], t] == k*D[u[x, t], {x, 2}] + r*u[x, t]*(1 - u[x, t]/alpha); 
bc  = {u[0, t] == 0, u[1, t] == 0}; 
ic  = u[x, 0] == 1; 
sol =  AbsoluteTiming[TimeConstrained[DSolve[{pde, bc, ic}, u[x, t], {x, t}], 60*10]];
 

Failed

Maple

restart; 
k := 1/100; 
r := 1/10; 
alpha := 10; 
pde := diff(u(x, t), t)=   k*diff(u(x, t),x$2) + r*u(x, t)*(1- u(x,t)/alpha); 
bc  := u(0, t) = 0, u(1, t) = 0; 
ic  := u(x, 0) =1; 
cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol',pdsolve([pde, ic, bc], u(x, t))),output='realtime'));
 

sol=()

____________________________________________________________________________________

3.1.1.21 [171] Diffusion Reaction, using Aleee form for reaction term

problem number 171

Added December 29, 2018.

Solve for \(u(x,t)\) in \[ u_t = k u_{xx} + \alpha u + \beta u ^2 - \gamma u^3 \]

with \(k=\frac {1}{1000},\alpha =\frac {1}{100},\beta =\frac {1}{100}, \gamma =\frac {5}{1000}\) and \(0<x<1\) and \(t>0\).

With boundary conditions \begin {align*} u(0,t) &= 0\\ u(1,t) &=0 \end {align*}

And initial conditions \(u(x,0)=1\).

Mathematica

ClearAll["Global`*"]; 
k = 1/1000; 
 alpha = 1/10; 
 beta = 1/100; 
 gamma = 5/1000; 
pde =  D[u[x, t], t] == k*D[u[x, t], {x, 2}] + alpha*u[x, t] + beta*u[x, t]^2 - gamma*u[x, t]^3; 
bc  = {u[0, t] == 0, u[1, t] == 0}; 
ic  = u[x, 0] == 1; 
sol =  AbsoluteTiming[TimeConstrained[DSolve[{pde, bc, ic}, u[x, t], {x, t}], 60*10]];
 

Failed

Maple

restart; 
k := 1/100; 
alpha:=1/100; 
beta:=1/1000; 
g:=5/1000; 
pde := diff(u(x, t), t)= k*diff(u(x, t),x$2) + 
        alpha*u(x,t)+ beta*u(x,t)^2 - g*u(x,t)^3; 
bc  := u(0, t) = 0, u(1, t) = 0; 
ic  := u(x, 0) =1; 
cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol', pdsolve([pde, ic, bc], u(x, t))),output='realtime'));
 

sol=()

____________________________________________________________________________________

3.1.1.22 [172] Diffusion Reaction. Haberman 2.3.8

problem number 172

This is problem 2.3.8, from Richard Haberman applied partial differential equations, 5th edition.

Consider the heat equation

\[ u_t = k u_{xx} - \alpha u \]

This corresponds to a one-dimentional rod either with heat loss through the lateral sides with outside temperature zero degrees (\(\alpha >0\)) or with insulated sides with a heat sink propertional to the temperature.

Suppose the boundary conditions are \(u(0,t)=0,u(L,t)=0\), solve with the temperature initially \(u\left ( x,0\right ) =f(x)\) if \(\alpha >0\)

Mathematica

ClearAll["Global`*"]; 
pde =  D[u[x, t], t] == k*D[u[x, t], {x, 2}] - alpha*u[x, t]; 
bc  = {u[0, t] == 0, u[L, t] == 0}; 
ic  = u[x, 0] == f[x]; 
sol =  AbsoluteTiming[TimeConstrained[DSolve[{pde, bc, ic}, u[x, t], {x, t}, Assumptions -> {L > 0, alpha > 0}], 60*10]];
 

Failed

Maple

restart; 
interface(showassumed=0); 
pde := diff(u(x,t),t)=k*diff(u(x,t),x$2)-alpha*u(x,t); 
bc  := u(0,t)=0,u(L,t)=0; 
ic  := u(x,0)=f(x); 
cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol',pdsolve([pde,bc,ic],u(x,t)) assuming L>0,alpha>0),output='realtime'));
 

\[u \left ( x,t \right ) =\sum _{n=1}^{\infty } \left ( 2\,{\frac {1}{L}\sin \left ( {\frac {\pi \,nx}{L}} \right ) {{\rm e}^{-{\frac {t \left ( {\pi }^{2}k{n}^{2}+{L}^{2}\alpha \right ) }{{L}^{2}}}}}\int _{0}^{L}\!f \left ( x \right ) \sin \left ( {\frac {\pi \,nx}{L}} \right ) \,{\rm d}x} \right ) \]

Hand solution

\begin {align*} \frac {\partial u}{\partial t} & =k\frac {\partial ^{2}u}{\partial x^{2}}-\alpha u\\ \frac {\partial u}{\partial t}+\alpha u & =k\frac {\partial ^{2}u}{\partial x^{2}} \end {align*}

Assuming \(u\left ( x,t\right ) =X\left ( x\right ) T\left ( t\right ) \) and substituting in the above gives\[ XT^{\prime }+\alpha XT=kTX^{\prime \prime }\] Dividing by \(kXT\neq 0\)\[ \frac {T^{\prime }}{kT}+\frac {\alpha }{k}=\frac {X^{\prime \prime }}{X}\] Since each side depends on different independent variable and both are equal, they must be both equal to same constant, say \(-\lambda \). Where \(\lambda \) is assumed real. \[ \frac {1}{k}\frac {T^{\prime }}{T}+\frac {\alpha }{k}=\frac {X^{\prime \prime }}{X}=-\lambda \] The two ODE’s are\begin {align*} \frac {1}{k}\frac {T^{\prime }}{T}+\frac {\alpha }{k} & =-\lambda \\ \frac {X^{\prime \prime }}{X} & =-\lambda \end {align*}

Or\begin {align*} T^{\prime }+\left ( \alpha +\lambda k\right ) T & =0\\ X^{\prime \prime }+\lambda X & =0 \end {align*}

The solution to the space ODE is the familiar (where \(\lambda >0\) is only possible case, As found in Haberman problem 2.3.3, part d. Since it has the same B.C.) \[ X_{n}=B_{n}\sin \left ( \frac {n\pi }{L}x\right ) \qquad n=1,2,3,\cdots \] Where \(\lambda _{n}=\left ( \frac {n\pi }{L}\right ) ^{2}\). The time ODE is now solved.\[ \frac {dT_{n}}{dt}+\left ( \alpha +\lambda _{n}k\right ) T_{n}=0 \] This has the solution\begin {align*} T_{n}\left ( t\right ) & =e^{-\left ( \alpha +\lambda _{n}k\right ) t}\\ & =e^{-\alpha t}e^{-\left ( \frac {n\pi }{L}\right ) ^{2}kt} \end {align*}

For the same eigenvalues. Notice that no need to add a constant here, since it will be absorbed in the \(B_{n}\) when combined in the following step below. Therefore the solution to the PDE is\[ u_{n}\left ( x,t\right ) =T_{n}\left ( t\right ) X_{n}\left ( x\right ) \] But for linear system sum of eigenfunctions is also a solution. Hence\begin {align*} u\left ( x,t\right ) & =\sum _{n=1}^{\infty }u_{n}\left ( x,t\right ) \\ & =\sum _{n=1}^{\infty }B_{n}\sin \left ( \frac {n\pi }{L}x\right ) e^{-\alpha t}e^{-\left ( \frac {n\pi }{L}\right ) ^{2}kt}\\ & =e^{-\alpha t}\sum _{n=1}^{\infty }B_{n}\sin \left ( \frac {n\pi }{L}x\right ) e^{-\left ( \frac {n\pi }{L}\right ) ^{2}kt} \end {align*}

Where \(e^{-\alpha t}\) was moved outside since it does not depend on \(n\). From initial condition\[ u\left ( x,0\right ) =f\left ( x\right ) =\sum _{n=1}^{\infty }B_{n}\sin \left ( \frac {n\pi }{L}x\right ) \] Applying orthogonality of \(\sin \) as before to find \(B_{n}\) results in\[ B_{n}=\frac {2}{L}\int _{0}^{L}\sin \left ( \frac {n\pi }{L}x\right ) f\left ( x\right ) dx \] Hence the solution becomes\begin {align*} u\left ( x,t\right ) & =\frac {2}{L}e^{-\alpha t}\left ( \sum _{n=1}^{\infty }\left ( \int _{0}^{L}\sin \left ( \frac {n\pi }{L}x\right ) f\left ( x\right ) dx\right ) \sin \left ( \frac {n\pi }{L}x\right ) e^{-\left ( \frac {n\pi }{L}\right ) ^{2}kt}\right ) \\ & =\frac {2}{L}\sum _{n=1}^{\infty }\left ( \int _{0}^{L}\sin \left ( \frac {n\pi }{L}x\right ) f\left ( x\right ) dx\right ) \sin \left ( \frac {n\pi }{L}x\right ) e^{-t\left ( \frac {n^{2}\pi ^{2}k+\alpha L^{2}}{L^{2}}\right ) } \end {align*}

Hence it is clear that in the limit as \(t\) becomes large \(u\left ( x,t\right ) \rightarrow 0\) since \(\alpha >0\) and\[ \lim _{t\rightarrow \infty }u\left ( x,t\right ) =0 \]

____________________________________________________________________________________

3.1.1.23 [173] Diffusion Reaction

problem number 173

Solve the heat equation

\[ u_t = u_{xx} - u(x,t) \]

For \(0<x<L\) and \(t>0\). The boundary conditions are \begin {align*} u(0,t) &= 0 \\ u(L,t) &= 0 \end {align*}

Initial condition is \(u(x,0)=f(x)\)

Mathematica

ClearAll["Global`*"]; 
pde =  D[u[x, t], t] + u[x, t] == D[u[x, t], {x, 2}]; 
ic  = u[x, 0] == f[x]; 
bc  = {u[0, t] == 0, u[L, t] == 0}; 
sol =  AbsoluteTiming[TimeConstrained[DSolve[{pde, ic, bc}, u[x, t], x, t], 60*10]];
 

Failed

Maple

restart; 
interface(showassumed=0); 
pde := diff(u(x,t),t)+u(x,t)=diff(u(x,t),x$2); 
ic  := u(x,0)=f(x); 
bc  := u(0,t)=0,u(L,t)=0; 
cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol',pdsolve([pde,ic,bc],u(x,t)) assuming L>0),output='realtime'));
 

\[u \left ( x,t \right ) =\sum _{n=1}^{\infty } \left ( 2\,{\frac {1}{L}\sin \left ( {\frac {\pi \,nx}{L}} \right ) {{\rm e}^{-{\frac {t \left ( {\pi }^{2}{n}^{2}+{L}^{2} \right ) }{{L}^{2}}}}}\int _{0}^{L}\!f \left ( x \right ) \sin \left ( {\frac {\pi \,nx}{L}} \right ) \,{\rm d}x} \right ) \]

Hand solution

\begin {align*} u_{t} & =u_{xx}-u\\ u\left ( 0,t\right ) & =0\\ u\left ( L,t\right ) & =0\\ u\left ( x,0\right ) & =f\left ( x\right ) \end {align*}

Let \(u\left ( x,t\right ) =v\left ( x,t\right ) e^{-t}\) , hence \(u_{t}=v_{t}e^{-t}-ve^{-t}\) and \(u_{xx}=v_{xx}e^{-t}\). Therefore the above PDE becomes\begin {align*} v_{t}e^{-t}-ve^{-t} & =v_{xx}e^{-t}-ve^{-t}\\ v_{t} & =v_{xx} \end {align*}

With boundary conditions\begin {align*} v\left ( 0,t\right ) & =0\\ v\left ( L,t\right ) & =0 \end {align*}

The solution to this PDE is known, since it has homogenouse BC and it is in standard form. The solution is\[ v\left ( x,t\right ) =\sum _{n=1}^{\infty }B_{n}e^{-\left ( \frac {n\pi }{L}\right ) ^{2}t}\sin \left ( \frac {n\pi }{L}x\right ) \] Hence \begin {align} u\left ( x,t\right ) & =e^{-t}\sum _{n=1}^{\infty }B_{n}e^{-\left ( \frac {n^{2}\pi ^{2}}{L^{2}}\right ) t}\sin \left ( \frac {n\pi }{L}x\right ) \nonumber \\ & =\sum _{n=1}^{\infty }B_{n}e^{-\left ( \frac {n^{2}\pi ^{2}}{L^{2}}\right ) t-t}\sin \left ( \frac {n\pi }{L}x\right ) \nonumber \\ & =\sum _{n=1}^{\infty }B_{n}e^{-t\left ( \frac {n^{2}\pi ^{2}}{L^{2}}+1\right ) }\sin \left ( \frac {n\pi }{L}x\right ) \nonumber \\ & =\sum _{n=1}^{\infty }B_{n}e^{-t\left ( \frac {n^{2}\pi ^{2}+L^{2}}{L^{2}}\right ) }\sin \left ( \frac {n\pi }{L}x\right ) \tag {1} \end {align}

Applying initial conditions  \(u\left ( x,0\right ) =f\left ( x\right ) \) gives\[ f\left ( x\right ) =\sum _{n=1}^{\infty }B_{n}\sin \left ( \frac {n\pi }{L}x\right ) \] Hence \(B_{n}\) are the Fourier sine coefficients of \(f\left ( x\right ) \)\[ B_{n}=\frac {2}{L}\int _{0}^{L}f\left ( x\right ) \sin \left ( \frac {n\pi }{L}x\right ) dx \] Therefore the solution in (1) becomes\begin {align*} u\left ( x,t\right ) & =\sum _{n=1}^{\infty }\frac {2}{L}\left ( \int _{0}^{L}f\left ( x\right ) \sin \left ( \frac {n\pi }{L}x\right ) dx\right ) e^{-t\left ( \frac {n^{2}\pi ^{2}+L^{2}}{L^{2}}\right ) }\sin \left ( \frac {n\pi }{L}x\right ) \\ & =\frac {2}{L}\sum _{n=1}^{\infty }\sin \left ( \frac {n\pi }{L}x\right ) e^{-t\left ( \frac {n^{2}\pi ^{2}+L^{2}}{L^{2}}\right ) }\left ( \int _{0}^{L}f\left ( x\right ) \sin \left ( \frac {n\pi }{L}x\right ) dx\right ) \end {align*}

____________________________________________________________________________________

3.1.1.24 [174] Diffusion Reaction

problem number 174

Added Feb 10, 2018.

Solve the heat equation

\[ u_t + u(x,t) = 100 u_{xx} \]

For \(0<x<1\) and \(t>0\). The boundary conditions are \begin {align*} u(0,t) &= 0 \\ u(1,t) &= 0 \end {align*}

Initial condition is \(u(x,0)=\sin (2 \pi x)-\sin (5 \pi x)\)

Mathematica

ClearAll["Global`*"]; 
pde =  D[u[x, t], t] == 100*D[u[x, t], {x, 2}]; 
bc  = {u[0, t] == 0, u[1, t] == 0}; 
ic  = u[x, 0] == Sin[2*Pi*x] - Sin[5*Pi*x]; 
sol =  AbsoluteTiming[TimeConstrained[DSolve[{pde, bc, ic}, u[x, t], {x, t}], 60*10]];
 

\[\left \{\left \{u(x,t)\to e^{-400 \pi ^2 t} \sin (2 \pi x)-e^{-2500 \pi ^2 t} \sin (5 \pi x)\right \}\right \}\]

Maple

restart; 
pde := diff(u(x,t),t)=100*diff(u(x,t),x$2); 
ic  := u(x,0)=sin(2*Pi*x)-sin(5*Pi*x); 
bc  := u(0,t)=0,u(1,t)=0; 
cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol',pdsolve([pde,ic,bc],u(x,t))),output='realtime'));
 

\[u \left ( x,t \right ) =\sin \left ( 2\,\pi \,x \right ) {{\rm e}^{-400\,{\pi }^{2}t}}-\sin \left ( 5\,\pi \,x \right ) {{\rm e}^{-2500\,{\pi }^{2}t}}\]

____________________________________________________________________________________

3.1.1.25 [175] Diffusion Reaction

problem number 175

Added June 23, 2019.

Solve the heat equation

\[ u_t = k u_{xx} - u x \]

For \(0<x<\pi \) and \(t>0\). The boundary conditions are \begin {align*} u(0,t) &= 0 \\ u(\pi ,t) &= 0 \end {align*}

Initial condition \(u(x,0)=\sin (x)\)

Mathematica

ClearAll["Global`*"]; 
pde =  D[u[x, t], t] == k*D[u[x, t], {x, 2}] - u[x,t]*x; 
bc  = {u[0, t] == 0, u[Pi, t] == 0}; 
ic  = u[x, 0] == Sin[x]; 
sol =  AbsoluteTiming[TimeConstrained[DSolve[{pde, bc, ic}, u[x, t], {x, t}, Assumptions -> k > 0], 60*10]];
 

Failed

Maple

restart; 
interface(showassumed=0); 
pde := diff(u(x,t),t)=k*diff(u(x,t),x$2)- u(x,t)*x; 
ic  := u(x,0)=sin(x); 
bc  := u(0,t)=0,u(Pi,t)=0; 
cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol',pdsolve([pde,ic,bc],u(x,t)) assuming k>0),output='realtime'));
 

\[u \left ( x,t \right ) = \left ( \sum _{n=0}^{\infty } \left ( -{(\cosh \left ( \lambda _{{n}}t \right ) +\sinh \left ( \lambda _{{n}}t \right ) ) \left ( \AiryBi \left ( {\frac {\pi +\lambda _{{n}}}{\sqrt [3]{k}}} \right ) \AiryAi \left ( {\frac {x+\lambda _{{n}}}{\sqrt [3]{k}}} \right ) -\AiryAi \left ( {\frac {\pi +\lambda _{{n}}}{\sqrt [3]{k}}} \right ) \AiryBi \left ( {\frac {x+\lambda _{{n}}}{\sqrt [3]{k}}} \right ) \right ) \left ( \AiryAi \left ( {\frac {\pi +\lambda _{{n}}}{\sqrt [3]{k}}} \right ) \int _{0}^{\pi }\!\sin \left ( x \right ) \AiryBi \left ( {\frac {x+\lambda _{{n}}}{\sqrt [3]{k}}} \right ) \,{\rm d}x-\AiryBi \left ( {\frac {\pi +\lambda _{{n}}}{\sqrt [3]{k}}} \right ) \int _{0}^{\pi }\!\sin \left ( x \right ) \AiryAi \left ( {\frac {x+\lambda _{{n}}}{\sqrt [3]{k}}} \right ) \,{\rm d}x \right ) \left ( \int _{0}^{\pi }\! \left ( \AiryBi \left ( {\frac {x+\lambda _{{n}}}{\sqrt [3]{k}}} \right ) \right ) ^{2}\,{\rm d}x \left ( \AiryAi \left ( {\frac {\pi +\lambda _{{n}}}{\sqrt [3]{k}}} \right ) \right ) ^{2}-2\,\AiryBi \left ( {\frac {\pi +\lambda _{{n}}}{\sqrt [3]{k}}} \right ) \int _{0}^{\pi }\!\AiryAi \left ( {\frac {x+\lambda _{{n}}}{\sqrt [3]{k}}} \right ) \AiryBi \left ( {\frac {x+\lambda _{{n}}}{\sqrt [3]{k}}} \right ) \,{\rm d}x\AiryAi \left ( {\frac {\pi +\lambda _{{n}}}{\sqrt [3]{k}}} \right ) + \left ( \AiryBi \left ( {\frac {\pi +\lambda _{{n}}}{\sqrt [3]{k}}} \right ) \right ) ^{2}\int _{0}^{\pi }\! \left ( \AiryAi \left ( {\frac {x+\lambda _{{n}}}{\sqrt [3]{k}}} \right ) \right ) ^{2}\,{\rm d}x \right ) ^{-1}} \right ) , \left \{ {\it And} \left ( \AiryAi \left ( {\frac {\lambda _{{n}}}{\sqrt [3]{k}}} \right ) \AiryBi \left ( {\frac {\pi +\lambda _{{n}}}{\sqrt [3]{k}}} \right ) -\AiryBi \left ( {\frac {\lambda _{{n}}}{\sqrt [3]{k}}} \right ) \AiryAi \left ( {\frac {\pi +\lambda _{{n}}}{\sqrt [3]{k}}} \right ) =0,-\infty \leq \lambda _{{n}} \land \lambda _{{n}}\leq \infty \right ) \right \} \right ) \]

____________________________________________________________________________________

3.1.1.26 [176] Diffusion convection (general case)

problem number 176

Added June 23, 2019.

Solve the heat equation

\[ u_t = k u_{xx} + a u_x \] Where \(a>0\). For \(0<x<L\) and \(t>0\). The boundary conditions are \begin {align*} u(0,t) &= 0 \\ u(L,t) &= 0 \end {align*}

Initial condition \(u(x,0)=f(x)\)

Mathematica

ClearAll["Global`*"]; 
pde =  D[u[x, t], t] == k*D[u[x, t], {x, 2}] + a*D[u[x, t], x]; 
bc  = {u[0, t] == 0, u[L, t] == 0}; 
ic  = u[x, 0] == f[x]; 
sol =  AbsoluteTiming[TimeConstrained[DSolve[{pde, bc, ic}, u[x, t], {x, t}, Assumptions -> {k > 0,a>0,L>0}], 60*10]];
 

Failed

Maple

restart; 
interface(showassumed=0); 
pde := diff(u(x,t),t)=k*diff(u(x,t),x$2)+ a*diff(u(x,t),x); 
ic  := u(x,0)=f(x); 
bc  := u(0,t)=0,u(L,t)=0; 
cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol',pdsolve([pde,ic,bc],u(x,t)) assuming k>0,a>0,L>0),output='realtime'));
 

sol=()

Hand solution

Solve \begin {align*} u_{t} & =ku_{xx}+au_{x}\\ u\left ( 0,t\right ) & =0\\ u\left ( L,0\right ) & =0\\ u\left ( x,0\right ) & =f\left ( x\right ) \end {align*}

Trying separation of variables. Let \(u=XT\), then the PDE becomes\begin {align*} T^{\prime }X & =kX^{\prime \prime }T+aX^{\prime }T\\ \frac {1}{k}\frac {T^{\prime }}{T} & =\frac {X^{\prime \prime }}{X}+\frac {a}{k}\frac {X^{\prime }}{X}=-\lambda \end {align*}

Where \(\lambda \) is separation constant. Hence\[ T^{\prime }+k\lambda T=0 \] Which has solution \(T\left ( t\right ) =e^{-k\lambda t}\) (the constant of integration is not needed, it will be combined with constant coming from the spatial ODE), and the spatial ODE is\begin {align*} \frac {X^{\prime \prime }}{X}+\frac {a}{k}\frac {X^{\prime }}{X} & =-\lambda \\ X^{\prime \prime }+\frac {a}{k}X^{\prime }+\lambda X & =0\\ X\left ( 0\right ) & =0\\ X\left ( L\right ) & =0 \end {align*}

The characteristic equation is \(r^{2}+\frac {a}{k}r+\lambda =0\).

Case \(\lambda =0\) Then \(r^{2}+\frac {a}{k}r=0\) or \(r\left ( r+\frac {a}{k}\right ) =0\). Hence \(r=0\) or \(r=-\frac {a}{k}\). So the solution is\[ X\left ( x\right ) =c_{1}+c_{2}e^{-\frac {a}{k}x}\] At \(X\left ( 0\right ) =0\) the above gives \(0=c_{1}+c_{2}\). Therefore the solution is \(X\left ( x\right ) =c_{1}\left ( 1-e^{\frac {-a}{k}x}\right ) \). At \(X\left ( L\right ) =0\) then \(c_{1}\left ( 1-e^{\frac {a}{k}L}\right ) =0\). This means this for non-trivial solution \(e^{\frac {-a}{k}L}=1\) or \(\frac {-a}{k}L=0\). Hence \(\lambda =0\) is not an eigenvalue.

Case \(\lambda <0\) Then \(r^{2}+\frac {a}{k}r+\lambda =0\) or \(r=\frac {-b}{2}\pm \frac {\sqrt {b^{2}-4ac}}{2a}=\frac {-a}{2k}\pm \frac {\sqrt {\frac {a^{2}}{k^{2}}-4\lambda }}{2}\). Since \(\lambda <0\) then the term under the sqrt root is positive. Hence the solution will have real roots. Not complex conjugate. Hence the solution is pure exponentials.  Let \(\frac {a^{2}}{k^{2}}-4\lambda =\alpha \) and \(\frac {a}{2k}=\beta \) then\begin {align*} r_{1} & =-\beta +\sqrt {\alpha }\\ r_{2} & =-\beta -\sqrt {\alpha } \end {align*}

Then \(X\left ( x\right ) =c_{1}\cosh \left ( \left ( -\beta +\alpha \right ) x\right ) +c_{2}\sinh \left ( \left ( -\beta -\alpha \right ) x\right ) \). At \(X\left ( 0\right ) =0\) this gives \(0=c_{1}\). Hence solution is \(X\left ( x\right ) =c_{2}\sinh \left ( \left ( -\beta -\alpha \right ) x\right ) \). At \(X\left ( L\right ) =0\), this gives\[ 0=c_{2}\sinh \left ( \left ( -\beta -\alpha \right ) L\right ) \] For non-trivial solution, \(\sinh \left ( \left ( -\beta -\alpha \right ) L\right ) =0\). But this is zero only when \(\left ( -\beta -\alpha \right ) L\) or \(\beta =-\alpha \). Or \(\frac {-a}{2k}=-\sqrt {\frac {a^{2}}{k^{2}}-4\lambda }\). Or \(\frac {a^{2}}{4k^{2}}=\frac {a^{2}}{k^{2}}-4\lambda \) or\begin {align*} 4\lambda & =\frac {a^{2}}{k^{2}}-\frac {a^{2}}{4k^{2}}\\ \lambda & =\frac {3}{16}\frac {a^{2}}{k^{2}} \end {align*}

But \(\lambda \) was assumed negative. Hence this is not possible. \(\lambda <0\) is not eigenvalue.

Case \(\lambda >0\) Then \(r^{2}+\frac {a}{k}r+\lambda =0\) or \(r=\frac {-a}{2k}\pm \frac {1}{2}\sqrt {\frac {a^{2}}{k^{2}}-4\lambda }=\frac {-a}{2k}\pm \sqrt {\frac {a^{2}}{4k^{2}}-\lambda }\). Since \(\lambda >0\) then the term under the sqrt root can be negative. Then only when \(\lambda >\frac {a^{2}}{4k^{2}}\) will there be complex roots. Therefore assuming \(\lambda >\frac {a^{2}}{4k^{2}}\), then\begin {align*} r_{1} & =\frac {-a}{2k}+i\sqrt {\lambda -\frac {a^{2}}{4k^{2}}}\\ r_{2} & =\frac {-a}{2k}-i\sqrt {\lambda -\frac {a^{2}}{4k^{2}}} \end {align*}

The solution is\[ X\left ( x\right ) =e^{\frac {-a}{2k}x}\left ( c_{1}\cos \left ( \sqrt {\lambda -\frac {a^{2}}{4k^{2}}}x\right ) +c_{2}\sin \left ( \sqrt {\lambda -\frac {a^{2}}{4k^{2}}}x\right ) \right ) \] At \(X\left ( 0\right ) =0\) this gives \(0=c_{1}\). Hence solution is\[ X\left ( x\right ) =e^{\frac {-a}{2k}x}c_{2}\sin \left ( \sqrt {\lambda -\frac {a^{2}}{4k^{2}}}x\right ) \] At \(X\left ( L\right ) =0\), this gives\[ 0=e^{\frac {-a}{2k}\pi }c_{2}\sin \left ( \sqrt {\lambda -\frac {a^{2}}{4k^{2}}}L\right ) \] For non-trivial solution, \(\sin \left ( \sqrt {\lambda -\frac {a^{2}}{4k^{2}}}L\right ) =0\) or \(\sqrt {\lambda -\frac {a^{2}}{4k^{2}}}L=n\pi \). Hence\begin {align*} \lambda -\frac {a^{2}}{4k^{2}} & =\left ( \frac {n\pi }{L}\right ) ^{2}\qquad n=1,2,3,\cdots \\ \lambda _{n} & =\left ( \frac {n\pi }{L}\right ) ^{2}+\frac {a^{2}}{4k^{2}}\qquad n=1,2,3,\cdots \end {align*}

And the corresponding eigenfunction is \[ X_{n}\left ( x\right ) =e^{\frac {-a}{2k}x}\sin \left ( \frac {n\pi }{L}x\right ) \qquad n=1,2,3,\cdots \] Therefore the solution is\[ u\left ( x,t\right ) =\sum _{n=1}^{\infty }c_{n}e^{-k\lambda _{n}t}e^{\frac {-a}{2k}x}\sin \left ( \frac {n\pi }{L}x\right ) \] \(c_{n}\) is found from initial conditions. At \(t=0\)\begin {align*} f\left ( x\right ) & =\sum _{n=1}^{\infty }c_{n}e^{\frac {-a}{2k}x}\sin \left ( \frac {n\pi }{L}x\right ) \\ e^{\frac {a}{2k}x}f\left ( x\right ) & =\sum _{n=1}^{\infty }c_{n}\sin \left ( \frac {n\pi }{L}x\right ) \end {align*}

Therefore, by orthogonality\begin {align*} \int _{0}^{L}e^{\frac {a}{2k}x}f\left ( x\right ) \sin \left ( \frac {n\pi }{L}x\right ) dx & =c_{n}\int _{0}^{L}\sin ^{2}\left ( \frac {n\pi }{L}x\right ) dx\\ \int _{0}^{L}e^{\frac {a}{2k}x}f\left ( x\right ) \sin \left ( \frac {n\pi }{L}x\right ) dx & =c_{n}\frac {L}{2}\\ c_{n} & =\frac {2}{L}\int _{0}^{L}e^{\frac {a}{2k}x}f\left ( x\right ) \sin \left ( \frac {n\pi }{L}x\right ) dx \end {align*}

Hence the solution becomes\[ u\left ( x,t\right ) =\sum _{n=1}^{\infty }\left ( \frac {2}{L}\int _{0}^{L}e^{\frac {a}{2k}x}f\left ( x\right ) \sin \left ( \frac {n\pi }{L}x\right ) dx\right ) e^{-k\lambda _{n}t}e^{\frac {-a}{2k}x}\sin \left ( \frac {n\pi }{L}x\right ) \] Where \(\lambda _{n}=\left ( \frac {n\pi }{L}\right ) ^{2}+\frac {a^{2}}{4k^{2}}\qquad n=1,2,3,\cdots \)\[ u\left ( x,t\right ) =\sum _{n=1}^{\infty }\left ( \frac {2}{L}\int _{0}^{L}e^{\frac {a}{2k}x}f\left ( x\right ) \sin \left ( \frac {n\pi }{L}x\right ) dx\right ) e^{-k\left ( \frac {n^{2}\pi ^{2}}{L^{2}}+\frac {a^{2}}{4k^{2}}\right ) t}e^{\frac {-a}{2k}x}\sin \left ( \frac {n\pi }{L}x\right ) \]

____________________________________________________________________________________

3.1.1.27 [177] Diffusion convection (special case)

problem number 177

Added June 23, 2019.

Solve the heat equation

\[ u_t = k u_{xx} + a u_x \] Where \(a>0\). For \(0<x<L\) and \(t>0\). The boundary conditions are \begin {align*} u(0,t) &= 0 \\ u(L,t) &= 0 \end {align*}

Initial condition \(u(x,0)=f(x)\) using the following values \begin {align*} f(x)&=\sin (x)\\ k&=1\\ a&=5\\ L&=\pi \end {align*}

Mathematica

ClearAll["Global`*"]; 
f=Sin[x]; 
L=Pi; 
k=1; 
a=5; 
pde =  D[u[x, t], t] == k*D[u[x, t], {x, 2}] + a*D[u[x, t], x]; 
bc  = {u[0, t] == 0, u[L, t] == 0}; 
ic  = u[x, 0] == f; 
sol =  AbsoluteTiming[TimeConstrained[DSolve[{pde, bc, ic}, u[x, t], {x, t}], 60*10]];
 

Failed

Maple

restart; 
f:=sin(x); 
L:=Pi; 
k:=1; 
a:=5; 
pde := diff(u(x,t),t)=k*diff(u(x,t),x$2)+ a*diff(u(x,t),x); 
ic  := u(x,0)=f; 
bc  := u(0,t)=0,u(L,t)=0; 
cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol',pdsolve([pde,ic,bc],u(x,t)) ),output='realtime'));
 

time expired

Hand solution

Solve \begin {align*} u_{t} & =ku_{xx}+au_{x}\\ u\left ( 0,t\right ) & =0\\ u\left ( L,0\right ) & =0\\ u\left ( x,0\right ) & =f\left ( x\right ) \end {align*}

With \(a=5,k=1,L=\pi ,f\left ( x\right ) =\sin \left ( x\right ) \). The above problem was solved in 3.1.1.26 on page 506 and the solution is\[ u\left ( x,t\right ) =\sum _{n=1}^{\infty }\left ( \frac {2}{L}\int _{0}^{L}e^{\frac {a}{2k}x}f\left ( x\right ) \sin \left ( \frac {n\pi }{L}x\right ) dx\right ) e^{-k\lambda _{n}t}e^{\frac {-a}{2k}x}\sin \left ( \frac {n\pi }{L}x\right ) \] Where \(\lambda _{n}=\left ( \frac {n\pi }{L}\right ) ^{2}+\frac {a^{2}}{4k^{2}}\qquad n=1,2,3,\cdots \)\[ u\left ( x,t\right ) =\sum _{n=1}^{\infty }\left ( \frac {2}{L}\int _{0}^{L}e^{\frac {a}{2k}x}f\left ( x\right ) \sin \left ( \frac {n\pi }{L}x\right ) dx\right ) e^{-k\left ( \frac {n^{2}\pi ^{2}}{L^{2}}+\frac {a^{2}}{4k^{2}}\right ) t}e^{\frac {-a}{2k}x}\sin \left ( \frac {n\pi }{L}x\right ) \] Substituting for \(f\left ( x\right ) =\sin \left ( x\right ) \) the above becomes\[ u\left ( x,t\right ) =\sum _{n=1}^{\infty }\left ( \frac {2}{L}\int _{0}^{L}e^{\frac {a}{2k}x}\sin \left ( x\right ) \sin \left ( \frac {n\pi }{L}x\right ) dx\right ) e^{-k\left ( \frac {n^{2}\pi ^{2}}{L^{2}}+\frac {a^{2}}{4k^{2}}\right ) t}e^{\frac {-a}{2k}x}\sin \left ( \frac {n\pi }{L}x\right ) \] But \[ \int _{0}^{\pi }e^{\frac {a}{2k}x}\sin \left ( x\right ) \sin \left ( nx\right ) dx=\frac {-16nak^{3}\left ( 1+\left ( -1\right ) ^{n}e^{\frac {\pi a}{2k}}\right ) }{a^{4}+16k^{4}\left ( n^{2}-1\right ) ^{2}+8a^{2}k^{2}\left ( 1+n^{2}\right ) }\] Hence the solution becomes\[ u\left ( x,t\right ) =\frac {-32ak^{3}}{L}\sum _{n=1}^{\infty }\left ( \frac {n\left ( 1+\left ( -1\right ) ^{n}e^{\frac {\pi a}{2k}}\right ) }{a^{4}+16k^{4}\left ( n^{2}-1\right ) ^{2}+8a^{2}k^{2}\left ( 1+n^{2}\right ) }\right ) e^{-k\left ( \frac {n^{2}\pi ^{2}}{L^{2}}+\frac {a^{2}}{4k^{2}}\right ) t}e^{\frac {-a}{2k}x}\sin \left ( \frac {n\pi }{L}x\right ) \] But \(L=\pi \), hence\[ u\left ( x,t\right ) =\frac {-32ak^{3}}{\pi }\sum _{n=1}^{\infty }\left ( \frac {n\left ( 1+\left ( -1\right ) ^{n}e^{\frac {\pi a}{2k}}\right ) }{a^{4}+16k^{4}\left ( n^{2}-1\right ) ^{2}+8a^{2}k^{2}\left ( 1+n^{2}\right ) }\right ) e^{-k\left ( n^{2}+\frac {a^{2}}{4k^{2}}\right ) t}e^{\frac {-a}{2k}x}\sin \left ( nx\right ) \] And \(a=5\)\[ u\left ( x,t\right ) =\frac {-160k^{3}}{\pi }\sum _{n=1}^{\infty }\left ( \frac {n\left ( 1+\left ( -1\right ) ^{n}e^{\frac {5\pi }{2k}}\right ) }{625+16k^{4}\left ( n^{2}-1\right ) ^{2}+200k^{2}\left ( 1+n^{2}\right ) }\right ) e^{-k\left ( n^{2}+\frac {25}{5k^{2}}\right ) t}e^{\frac {-5}{2k}x}\sin \left ( nx\right ) \] And \(k=1\)

\[ u\left ( x,t\right ) =\frac {-160}{\pi }\sum _{n=1}^{\infty }\left ( \frac {n\left ( 1+\left ( -1\right ) ^{n}e^{\frac {5\pi }{2}}\right ) }{625+16\left ( n^{2}-1\right ) ^{2}+200\left ( 1+n^{2}\right ) }\right ) e^{-\left ( n^{2}+\frac {25}{4}\right ) t}e^{\frac {-5}{2}x}\sin \left ( nx\right ) \]

Animation is below

Source code used for the above

The following animations for \(a=1,a=7\). Showing the effect of increasing the convection factor \(a\) on the solution.

\(a=1\)

\(a=7\)

____________________________________________________________________________________

3.1.1.28 [178] Haberman 2.4.2 (general case)

problem number 178

This is problem 2.4.2 from Richard Haberman applied partial differential equations, 5th edition.

Solve the heat equation

\[ u_t = k u_{xx} \]

The boundary conditions are \(u_x(0,t)=0\), \(u(L,t)=0\) with the temperature initially \(u(x,0)=f(x)\)

Mathematica

ClearAll["Global`*"]; 
pde =  D[u[x, t], t] == k*D[u[x, t], {x, 2}]; 
bc  = {Derivative[1, 0][u][0, t] == 0, u[L, t] == 0}; 
ic  = u[x, 0] == f[x]; 
sol =  AbsoluteTiming[TimeConstrained[DSolve[{pde, bc, ic}, u[x, t], {x, t}, Assumptions -> {L > 0 && k > 0}], 60*10]]; 
sol =  sol /. {K[1] -> n, K[2] -> x};
 

\[\left \{\left \{u(x,t)\to \frac {2 \sum _{n=0}^{\infty }e^{-\frac {k (2 \pi n+\pi )^2 t}{4 L^2}} \cos \left (\frac {(2 n+1) \pi x}{2 L}\right ) \int _0^L \cos \left (\frac {(2 n+1) \pi x}{2 L}\right ) f(x) \, dx}{L}\right \}\right \}\]

Maple

restart; 
pde := diff(u(x,t),t)=k*diff(u(x,t),x$2); 
bc:=D[1](u)(0,t)=0,u(L,t)=0; 
ic  := u(x,0)=f(x); 
cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol',pdsolve([pde,bc,ic],u(x,t)) assuming L>0,k>0),output='realtime'));
 

\[u \left ( x,t \right ) =\sum _{n=0}^{\infty } \left ( 2\,{\frac {1}{L}\cos \left ( 1/2\,{\frac { \left ( 1+2\,n \right ) \pi \,x}{L}} \right ) {{\rm e}^{-1/4\,{\frac {k{\pi }^{2} \left ( 1+2\,n \right ) ^{2}t}{{L}^{2}}}}}\int _{0}^{L}\!f \left ( x \right ) \cos \left ( 1/2\,{\frac { \left ( 1+2\,n \right ) \pi \,x}{L}} \right ) \,{\rm d}x} \right ) \]

Hand solution

Solve

\[ \frac {\partial u}{\partial t}=\kappa \frac {\partial ^{2}u}{\partial x^{2}}\] Let \(u\left ( x,t\right ) =T\left ( t\right ) X\left ( x\right ) \), then the PDE becomes\[ \frac {1}{\kappa }T^{\prime }X=X^{\prime \prime }T \] Dividing by \(XT\)\[ \frac {1}{\kappa }\frac {T^{\prime }}{T}=\frac {X^{\prime \prime }}{X}\] Since each side depends on different independent variable and both are equal, they must be both equal to same constant, say \(-\lambda \). Where \(\lambda \) is real. \[ \frac {1}{\kappa }\frac {T^{\prime }}{T}=\frac {X^{\prime \prime }}{X}=-\lambda \] The two ODE’s are\begin {align} T^{\prime }+k\lambda T & =0\tag {1}\\ X^{\prime \prime }+\lambda X & =0\tag {2} \end {align}

Per problem statement, \(\lambda \geq 0\), so only two cases needs to be examined.

Case \(\lambda =0\)

The space equation becomes \(X^{\prime \prime }=0\) with the solution \[ X=Ax+b \] Hence left B.C. implies \(X^{\prime }\left ( 0\right ) =0\) or \(A=0\). Therefore the solution becomes \(X=b\). The right B.C. implies \(X\left ( L\right ) =0\) or \(b=0\). Therefore this leads to \(X=0\) as the only solution. This results in trivial solution. Therefore \(\lambda =0\) is not an eigenvalue.

Case \(\lambda >0\)

Starting with the space ODE, the solution is\begin {align*} X\left ( x\right ) & =A\cos \left ( \sqrt {\lambda }x\right ) +B\sin \left ( \sqrt {\lambda }x\right ) \\ X^{\prime }\left ( x\right ) & =-A\sqrt {\lambda }\sin \left ( \sqrt {\lambda }x\right ) +B\sqrt {\lambda }\cos \left ( \sqrt {\lambda }x\right ) \end {align*}

Left B.C. gives\begin {align*} 0 & =X^{\prime }\left ( 0\right ) \\ & =B\sqrt {\lambda } \end {align*}

Hence \(B=0\) since it is assumed \(\lambda \neq 0\) and \(\lambda >0\). Solution becomes\[ X\left ( x\right ) =A\cos \left ( \sqrt {\lambda }x\right ) \] Applying right B.C. gives\begin {align*} 0 & =X\left ( L\right ) \\ & =A\cos \left ( \sqrt {\lambda }L\right ) \end {align*}

\(A=0\) leads to trivial solution. Therefore \(\cos \left ( \sqrt {\lambda }L\right ) =0\) or\begin {align*} \sqrt {\lambda } & =\frac {n\pi }{2L}\qquad n=1,3,5,\cdots \\ & =\frac {\left ( 2n-1\right ) \pi }{2L}\qquad n=1,2,3\cdots \end {align*}

Hence\begin {align*} \lambda _{n} & =\left ( \frac {n\pi }{2L}\right ) ^{2}\qquad n=1,3,5,\cdots \\ & =\frac {\left ( 2n-1\right ) ^{2}\pi ^{2}}{4L^{2}}\qquad n=1,2,3\cdots \end {align*}

Therefore\[ X_{n}\left ( x\right ) =A_{n}\cos \left ( \frac {n\pi }{2L}x\right ) \qquad n=1,3,5,\cdots \] And the corresponding time solution\[ T_{n}=e^{-k\left ( \frac {n\pi }{2L}\right ) ^{2}t}\qquad n=1,3,5,\cdots \] Hence\begin {align*} u_{n}\left ( x,t\right ) & =X_{n}T_{n}\\ u\left ( x,t\right ) & =\sum _{n=1,3,5,\cdots }^{\infty }A_{n}\cos \left ( \frac {n\pi }{2L}x\right ) e^{-k\left ( \frac {n\pi }{2L}\right ) ^{2}t}\\ & =\sum _{n=1}^{\infty }A_{n}\cos \left ( \frac {\left ( 2n-1\right ) \pi }{2L}x\right ) e^{-k\left ( \frac {\left ( 2n-1\right ) \pi }{2L}\right ) ^{2}t} \end {align*}

From initial conditions\[ f\left ( x\right ) =\sum _{n=1,3,5,\cdots }^{\infty }A_{n}\cos \left ( \frac {n\pi }{2L}x\right ) \] Multiplying both sides by \(\cos \left ( \frac {m\pi }{2L}x\right ) \) and integrating\[ \int _{0}^{L}f\left ( x\right ) \cos \left ( \frac {m\pi }{2L}x\right ) dx=\int \left ( \sum _{n=1,3,5,\cdots }^{\infty }A_{n}\cos \left ( \frac {m\pi }{2L}x\right ) \cos \left ( \frac {n\pi }{2L}x\right ) \right ) dx \] Interchanging order of summation and integration and applying orthogonality results in\begin {align*} \int _{0}^{L}f\left ( x\right ) \cos \left ( \frac {m\pi }{2L}x\right ) dx & =A_{m}\frac {L}{2}\\ A_{n} & =\frac {2}{L}\int _{0}^{L}f\left ( x\right ) \cos \left ( \frac {n\pi }{2L}x\right ) dx \end {align*}

Therefore the solution is\begin {align*} u\left ( x,t\right ) & =\frac {2}{L}\sum _{n=1,3,5,\cdots }^{\infty }\left [ \int _{0}^{L}f\left ( x\right ) \cos \left ( \frac {n\pi }{2L}x\right ) dx\right ] \cos \left ( \frac {n\pi }{2L}x\right ) e^{-k\left ( \frac {n\pi }{2L}\right ) ^{2}t}\\ & =\frac {2}{L}\sum _{n=0}^{\infty }\left ( \int _{0}^{L}f\left ( x\right ) \cos \left ( \frac {\left ( 2n+1\right ) \pi }{2L}x\right ) dx\right ) \cos \left ( \frac {\left ( 2n+1\right ) \pi }{2L}x\right ) e^{-k\left ( \frac {\left ( 2n+1\right ) \pi }{2L}\right ) ^{2}t} \end {align*}

____________________________________________________________________________________

3.1.1.29 [179] Left end zero, right end insulated, no source

problem number 179

Added January 13, 2020.

Problem 4.1.4, Introduction to Partial Differential Equations by Peter Olver ISBN 9783319020983.

Solve the heat equation

\[ u_t = k u_{xx} \]

The boundary conditions are \(u_x(0,t)=0\), \(u_x(L,t)=0\) with the temperature initially \(u(x,0)=f(x)\)

Mathematica

ClearAll["Global`*"]; 
pde =  D[u[x, t], t] == k*D[u[x, t], {x, 2}]; 
bc  = {u[0, t] == 0, Derivative[1, 0][u][L, t] == 0}; 
ic  = u[x, 0] == f[x]; 
sol =  AbsoluteTiming[TimeConstrained[DSolve[{pde, bc, ic}, u[x, t], {x, t}, Assumptions -> {L > 0 && k > 0}], 60*10]]; 
sol =  sol /. {K[1] -> n, K[2] -> x};
 

\[\left \{\left \{u(x,t)\to \frac {2 \sum _{n=1}^{\infty }e^{-\frac {k (1-2 n)^2 \pi ^2 t}{4 L^2}} \left (\int _0^L f(x) \sin \left (\frac {(2 n-1) \pi x}{2 L}\right ) \, dx\right ) \sin \left (\frac {(2 n-1) \pi x}{2 L}\right )}{L}\right \}\right \}\]

Maple

restart; 
pde := diff(u(x,t),t)=k*diff(u(x,t),x$2); 
bc:=u(0,t)=0,D[1](u)(L,t)=0; 
ic  := u(x,0)=f(x); 
cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol',pdsolve([pde,bc,ic],u(x,t)) assuming L>0,k>0),output='realtime'));
 

\[u \left ( x,t \right ) =\sum _{n=0}^{\infty } \left ( 2\,{\frac {1}{L}\sin \left ( 1/2\,{\frac { \left ( 1+2\,n \right ) \pi \,x}{L}} \right ) {{\rm e}^{-1/4\,{\frac {k{\pi }^{2} \left ( 1+2\,n \right ) ^{2}t}{{L}^{2}}}}}\int _{0}^{L}\!f \left ( x \right ) \sin \left ( 1/2\,{\frac { \left ( 1+2\,n \right ) \pi \,x}{L}} \right ) \,{\rm d}x} \right ) \]

Hand solution

The problem to solve is to solve for \(u\left ( x,t\right ) \) in\[ u_{t}=ku_{xx}\qquad 0<x<L,t>0 \] With boundary conditions\begin {align*} u\left ( 0,t\right ) & =0\\ u_{x}\left ( L,t\right ) & =0 \end {align*}

And initial conditions\[ u\left ( x,0\right ) =f\left ( x\right ) \] Let \(u\left ( x,t\right ) =T\left ( t\right ) X\left ( x\right ) \), then the PDE becomes\[ T^{\prime }X=kX^{\prime \prime }T \] Dividing by \(XT\)\[ \frac {1}{k}\frac {T^{\prime }}{T}=\frac {X^{\prime \prime }}{X}\] Since each side depends on different independent variable and both are equal, they must be both equal to same constant, say \(-\lambda \). Where \(\lambda \) is real. \[ \frac {1}{k}\frac {T^{\prime }}{T}=\frac {X^{\prime \prime }}{X}=-\lambda \] The two ODE’s are\begin {equation} T^{\prime }+\lambda kT=0\tag {1} \end {equation} And the eigenvalue ODE\begin {align} X^{\prime \prime }+\lambda X & =0\tag {2}\\ X\left ( 0\right ) & =0\nonumber \\ X^{\prime }\left ( L\right ) & =0\nonumber \end {align}

Now we solve (2) to find the eigenvalues and eigenfunctions.

Case \(\lambda <0\)

Let \(-\lambda =\omega ^{2}\). Hence the ODE is \(X^{\prime \prime }-\omega ^{2}X=0\) and the solution becomes\[ X\left ( x\right ) =C_{1}\cosh \left ( \omega x\right ) +C_{2}\sinh \left ( \omega x\right ) \] At \(x=0\) the above gives\[ 0=C_{1}\] Hence the solution now becomes\[ X\left ( x\right ) =C_{2}\sinh \left ( \omega x\right ) \] Taking derivative gives\[ X^{\prime }\left ( x\right ) =\omega C_{2}\sinh \left ( \omega x\right ) \] At \(x=L\)\[ 0=\omega C_{2}\cosh \left ( \omega L\right ) \] But \(\cosh \left ( \omega L\right ) \) is never zero. Therefore \(C_{2}=0\) which leads to trivial solution. Therefore \(\lambda <0\) is not eigenvalue.

Case \(\lambda =0\)

The space equation becomes \(X^{\prime \prime }=0\) with the solution \[ X=Ax+B \] At \(x=0\) the above gives \(0=B\). Therefore the solution is \(X=Ax\). Taking derivative gives \(X^{\prime }=A\). At \(x=L\) this gives \(0=A\). Which leads to trivial solutions. Therefore \(\lambda =0\) is not an eigenvalue.

Case \(\lambda >0\)

Starting with the space ODE, the solution is\[ X\left ( x\right ) =A\cos \left ( \sqrt {\lambda }x\right ) +B\sin \left ( \sqrt {\lambda }x\right ) \] Left B.C. gives\[ 0=A \] The solution becomes\[ X\left ( x\right ) =B\sin \left ( \sqrt {\lambda }x\right ) \] Taking derivative gives\[ X^{\prime }\left ( x\right ) =\sqrt {\lambda }B\cos \left ( \sqrt {\lambda }x\right ) \] Applying right B.C. gives\[ 0=\sqrt {\lambda }B\cos \left ( \sqrt {\lambda }L\right ) \] For non trivial solution we want \(\cos \left ( \sqrt {\lambda }L\right ) =0\) or\[ \sqrt {\lambda }=\frac {n\pi }{2L}\qquad n=1,3,5,\cdots \] Hence the eigenvalues are \[ \lambda _{n}=\left ( \frac {n\pi }{2L}\right ) ^{2}\qquad n=1,3,5,\cdots \] Therefore the eigenfunctions are \[ X_{n}\left ( x\right ) =\sin \left ( \frac {n\pi }{2L}x\right ) \qquad n=1,3,5,\cdots \] Now that we found the eigenvalues, we can solve the time ODE (1).\begin {align*} T_{n}^{\prime }+k\lambda _{n}T & =0\\ T_{n} & =B_{n}e^{-k\lambda _{n}t}\\ & =B_{n}e^{-k\left ( \frac {n\pi }{2L}\right ) ^{2}t} \end {align*}

Hence the fundamental solution is \begin {align} u_{n}\left ( x,t\right ) & =X_{n}T_{n}\nonumber \\ u\left ( x,t\right ) & =\sum _{n=1,3,5,\cdots }^{\infty }B_{n}\sin \left ( \frac {n\pi }{2L}x\right ) e^{-k\left ( \frac {n\pi }{2L}\right ) ^{2}t}\tag {3} \end {align}

From initial conditions\[ f\left ( x\right ) =\sum _{n=1,3,5,\cdots }^{\infty }B_{n}\sin \left ( \frac {n\pi }{2L}x\right ) \] Multiplying both sides by \(\sin \left ( \frac {m\pi }{2L}x\right ) \) and integrating\[ \int _{0}^{L}f\left ( x\right ) \sin \left ( \frac {m\pi }{2L}x\right ) dx=\int _{0}^{L}\left ( \sum _{n=1,3,5,\cdots }^{\infty }B_{n}\sin \left ( \frac {m\pi }{2L}xx\right ) \sin \left ( \frac {n\pi }{2L}x\right ) \right ) dx \] Interchanging order of summation and integration and applying orthogonality between \(\cos \) functions results in\begin {align*} \int _{0}^{L}f\left ( x\right ) \sin \left ( \frac {m\pi }{2L}x\right ) dx & =\int _{0}^{L}B_{m}\sin ^{2}\left ( \frac {m\pi }{2L}x\right ) dx\\ & =B_{m}\frac {L}{2} \end {align*}

Therefore \[ B_{n}=\frac {2}{L}\int _{0}^{L}f\left ( x\right ) \sin \left ( \frac {n\pi }{2L}x\right ) dx \] Therefore the solution is (3) becomes\begin {align*} u\left ( x,t\right ) & =\frac {2}{L}\sum _{n=1,3,5,\cdots }^{\infty }\left ( \int _{0}^{L}f\left ( x\right ) \sin \left ( \frac {n\pi }{2L}x\right ) dx\right ) \sin \left ( \frac {n\pi }{2L}x\right ) e^{-k\left ( \frac {n\pi }{2L}\right ) ^{2}t}\\ & =\frac {2}{L}\sum _{n=0}^{\infty }\left ( \int _{0}^{L}f\left ( x\right ) \sin \left ( \frac {\left ( 2n+1\right ) \pi }{2L}x\right ) dx\right ) \sin \left ( \frac {\left ( 2n+1\right ) \pi }{2L}x\right ) e^{-\left ( \frac {\left ( 2n+1\right ) \pi }{2L}\right ) ^{2}t} \end {align*}

____________________________________________________________________________________

3.1.1.30 [180] One end insulated

problem number 180

Added June 9, 2019

Solve the heat equation for \(u(x,t)\) \[ u_t = k u_{xx} \]

For \(0<x<L\) and \(t>0\). The boundary conditions are \begin {align*} u_x(0,t) &= 0 \\ u(L,t) &= T_0 \\ \end {align*}

Where \(T_0>0\) and initial condition is \(u(x,0)=0\)

Mathematica

ClearAll["Global`*"]; 
pde =  D[u[x, t], t] == k*D[u[x, t], {x, 2}]; 
bc  = {Derivative[1,0][u][0, t] == 0, u[1, t] == T0}; 
ic  = u[x, 0] == 0; 
sol =  AbsoluteTiming[TimeConstrained[DSolve[{pde, ic, bc}, u[x, t], {x, t},Assumptions->{T0>0,k>0,L>0}], 60*10]]; 
 sol= sol/.{K[1]->n};
 

\[\left \{\left \{u(x,t)\to 2 \sum _{n=0}^{\infty }-\frac {2 e^{-\frac {1}{4} k (2 \pi n+\pi )^2 t} \text {T0} \cos (n \pi ) \cos \left (\frac {1}{2} (2 n+1) \pi x\right )}{2 \pi n+\pi }+\text {T0}\right \}\right \}\]

Maple

restart; 
pde := diff(u(x,t),t)= k*diff(u(x,t),x$2); 
ic  := u(x,0)=0; 
bc  := D[1](u)(0,t) =0,u(L,t)=T0; 
cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol', pdsolve([pde,ic,bc],u(x,t)) assuming T0>0,k>0,L>0),output='realtime'));
 

\[u \left ( x,t \right ) =\sum _{n=0}^{\infty }-4\,{\frac { \left ( -1 \right ) ^{n}{\it T0}}{ \left ( 1+2\,n \right ) \pi }\cos \left ( 1/2\,{\frac { \left ( 1+2\,n \right ) \pi \,x}{L}} \right ) {{\rm e}^{-1/4\,{\frac {{\pi }^{2} \left ( 1+2\,n \right ) ^{2}kt}{{L}^{2}}}}}}+{\it T0}\]

____________________________________________________________________________________

3.1.1.31 [181] Haberman 2.3.7 (general case)

problem number 181

This is problem 2.3.7, from Richard Haberman applied partial differential equations, 5th edition.

Consider the heat equation

\[ u_t = k u_{xx} \]

Subject to boundary conditions \(u_x(0,t)=0\) , \(u_x(L,t)=0\) with initial conditions \(u(x,0) =f(x)\)

Mathematica

ClearAll["Global`*"]; 
pde =  D[u[x, t], t] == k*D[u[x, t], {x, 2}]; 
bc  = {Derivative[1, 0][u][0, t] == 0, Derivative[1, 0][u][L, t] == 0}; 
ic  = u[x, 0] == f[x]; 
sol =  AbsoluteTiming[TimeConstrained[DSolve[{pde, bc, ic}, u[x, t], {x, t}, Assumptions -> {L > 0, k > 0, t > 0}], 60*10]]; 
sol =  sol /. {K[1] -> n, K[2] -> x};
 

\[\left \{\left \{u(x,t)\to \frac {2 \sum _{n=1}^{\infty }e^{-\frac {k n^2 \pi ^2 t}{L^2}} \cos \left (\frac {n \pi x}{L}\right ) \int _0^L \cos \left (\frac {n \pi x}{L}\right ) f(x) \, dx+\int _0^L f(x) \, dx}{L}\right \}\right \}\]

Maple

restart; 
interface(showassumed=0); 
assume(L>0); 
pde := diff(u(x,t),t)=k*diff(u(x,t),x$2); 
bc:=D[1](u)(0,t)=0,D[1](u)(L,t)=0; 
ic  := u(x,0)=f(x); 
cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol',pdsolve([pde,bc,ic],u(x,t))),output='realtime'));
 

\[u \left ( x,t \right ) ={\frac {1}{L} \left ( \sum _{n=1}^{\infty } \left ( 2\,{\frac {1}{L}\cos \left ( {\frac {n\pi \,x}{L}} \right ) {{\rm e}^{-{\frac {{\pi }^{2}{n}^{2}kt}{{L}^{2}}}}}\int _{0}^{L}\!\cos \left ( {\frac {n\pi \,x}{L}} \right ) f \left ( x \right ) \,{\rm d}x} \right ) L+\int _{0}^{L}\!f \left ( x \right ) \,{\rm d}x \right ) }\]

Hand solution

\begin {align*} \frac {\partial u}{\partial t} & =k\frac {\partial ^{2}u}{\partial x^{2}}\\ u_{x}\left ( 0,t\right ) & =0\\ u_{x}\left ( L,t\right ) & =0\\ u\left ( x,0\right ) & =f\left ( x\right ) \end {align*}

Let \(u\left ( x,t\right ) =T\left ( t\right ) X\left ( x\right ) \), then the PDE becomes\[ \frac {1}{k}T^{\prime }X=X^{\prime \prime }T \] Dividing by \(XT\neq 0\)\[ \frac {1}{k}\frac {T^{\prime }}{T}=\frac {X^{\prime \prime }}{X}\] Since each side depends on different independent variable and both are equal, they must be both equal to same constant, say \(-\lambda \). Where \(\lambda \) is assumed real. \[ \frac {1}{k}\frac {T^{\prime }}{T}=\frac {X^{\prime \prime }}{X}=-\lambda \] The two ODE’s generated are\begin {align} T^{\prime }+k\lambda T & =0\tag {1}\\ X^{\prime \prime }+\lambda X & =0\tag {2} \end {align}

Starting with the space ODE equation (2), with corresponding boundary conditions \(\frac {dX}{dx}\left ( 0\right ) =0,\frac {dX}{dx}\left ( L\right ) =0\). Assuming the solution is \(X\left ( x\right ) =e^{rx}\), Then the characteristic equation is\begin {align*} r^{2}+\lambda & =0\\ r^{2} & =-\lambda \\ r & =\pm \sqrt {-\lambda } \end {align*}

The following cases are considered.

case \(\lambda <0\) In this case, \(-\lambda \) and also \(\sqrt {-\lambda }\) are positive. Hence the roots \(\pm \sqrt {-\lambda }\) are both real. Let \[ \sqrt {-\lambda }=s \] Where \(s>0\). This gives the solution\begin {align*} X\left ( x\right ) & =A\cosh \left ( sx\right ) +B\sinh \left ( sx\right ) \\ \frac {dX}{dx} & =A\sinh \left ( sx\right ) +B\cosh \left ( sx\right ) \end {align*}

Applying the left B.C. gives\begin {align*} 0 & =\frac {dX}{dx}\left ( 0\right ) \\ & =B\cosh \left ( 0\right ) \\ & =B \end {align*}

The solution becomes \(X\left ( x\right ) =A\cosh \left ( sx\right ) \) and hence\(\frac {dX}{dx}=A\sinh \left ( sx\right ) \). Applying the right B.C. gives\begin {align*} 0 & =\frac {dX}{dx}\left ( L\right ) \\ & =A\sinh \left ( sL\right ) \end {align*}

\(A=0\) result in trivial solution. Therefore assuming \(\sinh \left ( sL\right ) =0\) implies \(sL=0\) which is not valid since \(s>0\) and \(L\neq 0\). Hence only trivial solution results from this case. \(\lambda <0\) is not an eigenvalue.

case \(\lambda =0\)

The ODE becomes\[ \frac {d^{2}X}{dx^{2}}=0 \] The solution is\begin {align*} X\left ( x\right ) & =c_{1}x+c_{2}\\ \frac {dX}{dx} & =c_{1} \end {align*}

Applying left boundary conditions gives\begin {align*} 0 & =\frac {dX}{dx}\left ( 0\right ) \\ & =c_{1} \end {align*}

Hence the solution becomes \(X\left ( x\right ) =c_{2}\). Therefore \(\frac {dX}{dx}=0\). Applying the right B.C. provides no information.

Therefore this case leads to the solution \(X\left ( x\right ) =c_{2}\). Associated with this one eigenvalue, the time equation becomes \(\frac {dT_{0}}{dt}=0\) hence \(T_{0}\) is constant, say \(\alpha \). Hence the solution \(u_{0}\left ( x,t\right ) \) associated with this \(\lambda =0\) is\begin {align*} u_{0}\left ( x,t\right ) & =X_{0}T_{0}\\ & =c_{2}\alpha \\ & =A_{0} \end {align*}

where constant \(c_{2}\alpha \) was renamed to \(A_{0}\) to indicate it is associated with \(\lambda =0\).  \(\lambda =0\) is an eigenvalue.

case \(\lambda >0\)

Hence \(-\lambda \) is negative, and the roots are both complex. \[ r=\pm i\sqrt {\lambda }\] The solution is\begin {align*} X\left ( x\right ) & =A\cos \left ( \sqrt {\lambda }x\right ) +B\sin \left ( \sqrt {\lambda }x\right ) \\ \frac {dX}{dx} & =-A\sqrt {\lambda }\sin \left ( \sqrt {\lambda }x\right ) +B\sqrt {\lambda }\cos \left ( \sqrt {\lambda }x\right ) \end {align*}

Applying the left B.C. gives\begin {align*} 0 & =\frac {dX}{dx}\left ( 0\right ) \\ & =B\sqrt {\lambda }\cos \left ( 0\right ) \\ & =B\sqrt {\lambda } \end {align*}

Therefore \(B=0\) as \(\lambda >0\). The solution becomes \(X\left ( x\right ) =A\cos \left ( \sqrt {\lambda }x\right ) \) and \(\frac {dX}{dx}=-A\sqrt {\lambda }\sin \left ( \sqrt {\lambda }x\right ) \). Applying the right B.C. gives\begin {align*} 0 & =\frac {dX}{dx}\left ( L\right ) \\ & =-A\sqrt {\lambda }\sin \left ( \sqrt {\lambda }L\right ) \end {align*}

\(A=0\) gives a trivial solution. Selecting \(\sin \left ( \sqrt {\lambda }L\right ) =0\) gives\[ \sqrt {\lambda }L=n\pi \qquad n=1,2,3,\cdots \] Or\[ \lambda _{n}=\left ( \frac {n\pi }{L}\right ) ^{2}\qquad n=1,2,3,\cdots \] Therefore the space solution is\[ X_{n}\left ( x\right ) =A_{n}\cos \left ( \frac {n\pi }{L}x\right ) \qquad n=1,2,3,\cdots \] The time solution is found by solving \[ \frac {dT_{n}}{dt}+k\lambda _{n}T_{n}=0 \] This has the solution\begin {align*} T_{n}\left ( t\right ) & =e^{-k\lambda _{n}t}\\ & =e^{-k\left ( \frac {n\pi }{L}\right ) ^{2}t}\qquad n=1,2,3,\cdots \end {align*}

For the same set of eigenvalues. Notice that no need to add a constant here, since it will be absorbed in the \(A_{n}\) when combined in the following step below. Since for \(\lambda =0\) the time solution was found to be constant, and for \(\lambda >0\) the time solution is \(e^{-k\left ( \frac {n\pi }{L}\right ) ^{2}t}\), then no time solution will grow with time. Time solutions always decay with time as the exponent \(-k\left ( \frac {n\pi }{L}\right ) ^{2}t\) is negative quantity. The solution to the PDE for \(\lambda >0\) is \[ u_{n}\left ( x,t\right ) =T_{n}\left ( t\right ) X_{n}\left ( x\right ) \qquad n=0,1,2,3,\cdots \] But for linear system sum of eigenfunctions is also a solution. Hence\begin {align*} u\left ( x,t\right ) & =u_{\lambda =0}\left ( x,t\right ) +\sum _{n=1}^{\infty }u_{n}\left ( x,t\right ) \\ & =A_{0}+\sum _{n=1}^{\infty }A_{n}\cos \left ( \frac {n\pi }{L}x\right ) e^{-k\left ( \frac {n\pi }{L}\right ) ^{2}t} \end {align*}

From the solution found above, setting \(t=0\) gives\[ f\left ( x\right ) =A_{0}+\sum _{n=1}^{\infty }A_{n}\cos \left ( \frac {n\pi }{L}x\right ) \] Multiplying both sides with \(\cos \left ( \frac {m\pi }{L}x\right ) \) where in this problem \(m=0,1,2,\cdots \) (since there was an eigenvalue associated with \(\lambda =0\)), and integrating over the domain gives\begin {align*} \int _{0}^{L}f\left ( x\right ) \cos \left ( \frac {m\pi }{L}x\right ) dx & =\int _{0}^{L}\cos \left ( \frac {m\pi }{L}x\right ) \left ( A_{0}+\sum _{n=1}^{\infty }A_{n}\cos \left ( \frac {n\pi }{L}x\right ) \right ) dx\\ & =\int _{0}^{L}A_{0}\cos \left ( \frac {m\pi }{L}x\right ) dx+\int \cos \left ( \frac {m\pi }{L}x\right ) \sum _{n=1}^{\infty }A_{n}\cos \left ( \frac {n\pi }{L}x\right ) dx\\ & =\int _{0}^{L}A_{0}\cos \left ( \frac {m\pi }{L}x\right ) dx+\int _{0}^{L}\sum _{n=1}^{\infty }A_{n}\cos \left ( \frac {m\pi }{L}x\right ) \cos \left ( \frac {n\pi }{L}x\right ) dx \end {align*}

Interchanging the order of summation and integration\begin {equation} \int _{0}^{L}f\left ( x\right ) \cos \left ( \frac {m\pi }{L}x\right ) dx=\int _{0}^{L}A_{0}\cos \left ( \frac {m\pi }{L}x\right ) dx+\sum _{n=1}^{\infty }A_{n}\int _{0}^{L}\cos \left ( \frac {m\pi }{L}x\right ) \cos \left ( \frac {n\pi }{L}x\right ) dx\tag {1} \end {equation} case \(m=0\)

When \(m=0\) then \(\cos \left ( \frac {m\pi }{L}x\right ) =1\) and the above simplifies to\[ \int _{0}^{L}f\left ( x\right ) dx=\int _{0}^{L}A_{0}dx+\sum _{n=1}^{\infty }A_{n}\int _{0}^{L}\cos \left ( \frac {n\pi }{L}x\right ) dx \] But \(\int _{0}^{L}\cos \left ( \frac {n\pi }{L}x\right ) dx=0\) and the above becomes\begin {align*} \int _{0}^{L}f\left ( x\right ) dx & =\int _{0}^{L}A_{0}dx\\ & =A_{0}L \end {align*}

Therefore\[ A_{0}=\frac {1}{L}\int _{0}^{L}f\left ( x\right ) dx \] case \(m>0\)

From (1), one term survives in the integration when only \(n=m\), hence\[ \int _{0}^{L}f\left ( x\right ) \cos \left ( \frac {m\pi }{L}x\right ) dx=A_{0}\int _{0}^{L}\cos \left ( \frac {m\pi }{L}x\right ) dx+A_{m}\int _{0}^{L}\cos ^{2}\left ( \frac {m\pi }{L}x\right ) dx \] But \(\int _{0}^{L}\cos \left ( \frac {m\pi }{L}x\right ) dx=0\) and the above becomes\[ \int _{0}^{L}f\left ( x\right ) \cos \left ( \frac {m\pi }{L}x\right ) dx=A_{m}\frac {L}{2}\] Therefore\[ A_{n}=\frac {2}{L}\int _{0}^{L}f\left ( x\right ) \cos \left ( \frac {n\pi }{L}x\right ) dx \] For \(n=1,2,3,\cdots \)

Therefore the solution is\begin {align*} u\left ( x,t\right ) & =A_{0}+\sum _{n=1}^{\infty }A_{n}\cos \left ( \frac {n\pi }{L}x\right ) e^{-k\left ( \frac {n\pi }{L}\right ) ^{2}t}\\ & =\frac {1}{L}\int _{0}^{L}f\left ( x\right ) dx+\frac {2}{L}\sum _{n=1}^{\infty }\left ( \int _{0}^{L}f\left ( x\right ) \cos \left ( \frac {n\pi }{L}x\right ) dx\right ) \cos \left ( \frac {n\pi }{L}x\right ) e^{-k\left ( \frac {n\pi }{L}\right ) ^{2}t} \end {align*}

In the limit as \(t\rightarrow \infty \) the term \(e^{-k\left ( \frac {n\pi }{L}\right ) ^{2}t}\rightarrow 0\). What is left is \(A_{0}\). But \(A_{0}=\frac {1}{L}\int _{0}^{L}f\left ( x\right ) dx\) from above. This quantity is the average of the initial temperature.

____________________________________________________________________________________

3.1.1.32 [182] specific case

problem number 182

Added June 21, 2019

Solve

\[ u_t = k u_{xx} \] Subject to boundary conditions \(u_x(0,t)=0\) , \(u_x(L,t)=0\) with initial conditions \(u(x,0)=f(x)\) using the following values \begin {align*} L&=5\\ k&=\frac {1}{100}\\ f(x)&=x \end {align*}

Mathematica

ClearAll["Global`*"]; 
k=1/100; 
L=5; 
f=x; 
pde =  D[u[x, t], t] == k*D[u[x, t], {x, 2}]; 
bc  = {Derivative[1, 0][u][0, t] == 0, Derivative[1, 0][u][L, t] == 0}; 
ic  = u[x, 0] == f; 
sol =  AbsoluteTiming[TimeConstrained[DSolve[{pde, bc, ic}, u[x, t], {x, t}], 60*10]]; 
sol =  sol /. {K[1] -> n, K[2] -> x};
 

\[\left \{\left \{u(x,t)\to \frac {2}{5} \sum _{n=1}^{\infty }\frac {25 \left (-1+(-1)^n\right ) e^{-\frac {n^2 \pi ^2 t}{2500}} \cos \left (\frac {n \pi x}{5}\right )}{n^2 \pi ^2}+\frac {5}{2}\right \}\right \}\]

Maple

restart; 
L:=5; 
k:=1/100; 
f:=x; 
pde := diff(u(x,t),t)=k*diff(u(x,t),x$2); 
bc:=D[1](u)(0,t)=0,D[1](u)(L,t)=0; 
ic  := u(x,0)=f; 
cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol',pdsolve([pde,bc,ic],u(x,t))),output='realtime'));
 

\[u \left ( x,t \right ) =5/2+\sum _{n=1}^{\infty }10\,{\frac { \left ( \left ( -1 \right ) ^{n}-1 \right ) \cos \left ( 1/5\,n\pi \,x \right ) }{{\pi }^{2}{n}^{2}}{{\rm e}^{-{\frac {{\pi }^{2}{n}^{2}t}{2500}}}}}\]

Hand solution

The general solution for this type of PDE is given in problem 3.1.1.31 on page 530 as\begin {equation} u\left ( x,t\right ) =A_{0}+\sum _{n=1}^{\infty }A_{n}\cos \left ( \frac {n\pi }{L}x\right ) e^{-k\left ( \frac {n\pi }{L}\right ) ^{2}t}\tag {1} \end {equation} In this problem \(u\left ( x,0\right ) =\) \(f\left ( x\right ) =x,L=5,k=\frac {1}{100}\). Hence the above becomes\begin {equation} u\left ( x,t\right ) =A_{0}+\sum _{n=1}^{\infty }A_{n}\cos \left ( \frac {n\pi }{5}x\right ) e^{-\left ( \frac {1}{100}\left ( \frac {n\pi }{5}\right ) ^{2}t\right ) }\tag {2} \end {equation} At \(t=0\) the above becomes\[ x=A_{0}+\sum _{n=1}^{\infty }A_{n}\cos \left ( \frac {n\pi }{5}x\right ) \] For \(n=0\) orthogonality gives\begin {align*} \int _{0}^{5}xdx & =\int _{0}^{5}A_{0}dx\\ \frac {25}{2} & =5A_{0}\\ A_{0} & =\frac {5}{2} \end {align*}

For \(n>0\)\begin {align*} \int _{0}^{5}x\cos \left ( \frac {n\pi }{5}x\right ) dx & =\int _{0}^{5}A_{n}\cos ^{2}\left ( \frac {n\pi }{5}x\right ) dx\\ \frac {25}{n^{2}\pi ^{2}}\left ( -1+\left ( -1\right ) ^{n}\right ) & =\frac {5}{2}A_{n}\\ A_{n} & =\frac {10}{n^{2}\pi ^{2}}\left ( -1+\left ( -1\right ) ^{n}\right ) \end {align*}

Hence the solution (2) becomes\[ u\left ( x,t\right ) =\frac {5}{2}+\frac {10}{\pi ^{2}}\sum _{n=1}^{\infty }\frac {1}{n^{2}}\left ( -1+\left ( -1\right ) ^{n}\right ) \cos \left ( \frac {n\pi }{5}x\right ) e^{-\frac {n^{2}\pi ^{2}}{2500}t}\] The following is an animation of the solution

Source code used for the above

____________________________________________________________________________________

3.1.1.33 [183] Haberman 2.4.1 (a)

problem number 183

This is problem 2.4.1 part(a) from Richard Haberman applied partial differential equations, 5th edition.

Consider the heat equation

\[ u_t = k u_{xx} \]

The boundary conditions are \(u_x(0,t)=0\) , \(u_x(L,t)=0\). Initial conditions

\(u(x,0) =\left \{ \begin {array} [c]{ccc}0 & & x< \frac {L}{2}\\ 1 & & x> \frac {L}{2} \end {array} \right . \)

Mathematica

ClearAll["Global`*"]; 
pde =  D[u[x, t], t] == k*D[u[x, t], {x, 2}]; 
bc  = {Derivative[1, 0][u][0, t] == 0, Derivative[1, 0][u][L, t] == 0}; 
ic  = u[x, 0] == Piecewise[{{0, x < L/2}, {1, x > L/2}}]; 
sol =  AbsoluteTiming[TimeConstrained[DSolve[{pde, bc, ic}, u[x, t], {x, t}, Assumptions -> {L > 0 && k > 0}], 60*10]]; 
sol =  sol /. {K[1] -> n};
 

\[\left \{\left \{u(x,t)\to \frac {2 \sum _{n=1}^{\infty }-\frac {e^{-\frac {k n^2 \pi ^2 t}{L^2}} L \cos \left (\frac {n \pi x}{L}\right ) \sin \left (\frac {n \pi }{2}\right )}{n \pi }}{L}+\frac {1}{2}\right \}\right \}\]

Maple

restart; 
pde := diff(u(x,t),t)=k*diff(u(x,t),x$2); 
bc:=D[1](u)(0,t)=0,D[1](u)(L,t)=0; 
ic  := u(x,0)=piecewise(0<x and x<=L/2,0,L/2<x and x<L,1); 
cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol',pdsolve([pde,bc,ic],u(x,t)) assuming k>0,L>0),output='realtime'));
 

\[u \left ( x,t \right ) =1/2+\sum _{n=1}^{\infty }-2\,{\frac {\sin \left ( 1/2\,n\pi \right ) }{n\pi }\cos \left ( {\frac {n\pi \,x}{L}} \right ) {{\rm e}^{-{\frac {{\pi }^{2}{n}^{2}kt}{{L}^{2}}}}}}\]

____________________________________________________________________________________

3.1.1.34 [184] Both ends insulated, no source

problem number 184

Added January 13, 2020

This is problem 4.1.7 Introduction to Partial Differential Equations by Peter Olver ISBN 9783319020983.

Solve

\[ u_t = k u_{xx} \]

The boundary conditions are \(u_x(0,t)=0\) , \(u_x(L,t)=0\). Initial conditions

\(u(x,0) =\left \{ \begin {array} [c]{ccc}x & & 0<x< \frac {L}{2}\\ 1-x & & \frac {L}{2}<x<L \end {array} \right . Use \)L=1\(. \)

Mathematica

ClearAll["Global`*"]; 
L=1; 
pde =  D[u[x, t], t] == k*D[u[x, t], {x, 2}]; 
bc  = {Derivative[1, 0][u][0, t] == 0, Derivative[1, 0][u][L, t] == 0}; 
ic  = u[x, 0] == Piecewise[{{x, 0<x < L/2}, {1-x, L/2<=x<L}}]; 
sol =  AbsoluteTiming[TimeConstrained[DSolve[{pde, bc, ic}, u[x, t], {x, t}, Assumptions -> k > 0], 60*10]]; 
sol =  sol /. K[1] -> n;
 

\[\left \{\left \{u(x,t)\to 2 \sum _{n=1}^{\infty }\frac {4 e^{-k n^2 \pi ^2 t} \cos \left (\frac {n \pi }{2}\right ) \cos (n \pi x) \sin ^2\left (\frac {n \pi }{4}\right )}{n^2 \pi ^2}+\frac {1}{4}\right \}\right \}\]

Maple

restart; 
L:=1; 
pde := diff(u(x,t),t)=k*diff(u(x,t),x$2); 
bc:=D[1](u)(0,t)=0,D[1](u)(L,t)=0; 
ic  := u(x,0)=piecewise(0<x and x<=L/2,x,L/2<x and x<L,1-x); 
cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol',pdsolve([pde,bc,ic],u(x,t)) assuming k>0),output='realtime'));
 

\[u \left ( x,t \right ) =1/4+\sum _{n=1}^{\infty }-2\,{\frac {\cos \left ( n\pi \,x \right ) {{\rm e}^{-k{\pi }^{2}{n}^{2}t}} \left ( -2\,\cos \left ( 1/2\,\pi \,n \right ) +1+ \left ( -1 \right ) ^{n} \right ) }{{\pi }^{2}{n}^{2}}}\]

Hand solution

Let \(u\left ( x,t\right ) =T\left ( t\right ) X\left ( x\right ) \), then the PDE becomes\[ \frac {1}{k}T^{\prime }X=X^{\prime \prime }T \] Dividing by \(XT\neq 0\)\[ \frac {1}{k}\frac {T^{\prime }}{T}=\frac {X^{\prime \prime }}{X}\] Since each side depends on different independent variable and both are equal, they must be both equal to same constant, say \(-\lambda \). Where \(\lambda \) is assumed real. \[ \frac {1}{k}\frac {T^{\prime }}{T}=\frac {X^{\prime \prime }}{X}=-\lambda \] The two ODE’s generated are\begin {equation} T^{\prime }+k\lambda T=0\tag {1} \end {equation} And the eigenvalue ODE\begin {align} X^{\prime \prime }+\lambda X & =0\tag {2}\\ X^{\prime }\left ( 0\right ) & =0\nonumber \\ X^{\prime }\left ( L\right ) & =0\nonumber \end {align}

Starting with the eigenvalue ODE equation (2). The following cases are considered.

case \(\lambda <0\)

In this case, \(-\lambda \) is positive. Let \(-\lambda =\omega ^{2}\). Hence the ODE is \(X^{\prime \prime }-\omega ^{2}X=0\) and the solution becomes\[ X\left ( x\right ) =C_{1}\cosh \left ( \omega x\right ) +C_{2}\sinh \left ( \omega x\right ) \] Therefore\[ X^{\prime }=C_{1}\sinh \left ( \omega x\right ) +C_{2}\cosh \left ( \omega x\right ) \] Applying the left B.C. gives\[ 0=C_{2}\] Therefore the solution becomes \(X\left ( x\right ) =C_{1}\cosh \left ( \omega x\right ) \) and \(X^{\prime }\left ( x\right ) =C_{1}\sinh \left ( \omega x\right ) \).  Applying the right B.C. gives\[ 0=C_{1}\sinh \left ( \omega L\right ) \] For non-trivial solution we want \(\sinh \left ( \omega L\right ) =0\). But this is not possible since \(\sinh \) is zero when its argument is zero, which is not the case here. Hence only trivial solution results from this case. \(\lambda <0\) is not an eigenvalue.

case \(\lambda =0\)

The solution is\begin {align*} X\left ( x\right ) & =c_{1}x+c_{2}\\ X^{\prime }\left ( x\right ) & =c_{1} \end {align*}

Applying left boundary conditions gives\[ 0=c_{1}\] Hence the solution becomes \(X\left ( x\right ) =c_{2}\). Therefore \(\frac {dX}{dx}=0\). Applying the right B.C. provides no information. Any \(c_{2}\) will work. Therefore this case leads to the solution \(X\left ( x\right ) =c_{2}\). Associated with this one eigenvalue, the time equation becomes \(T_{0}^{\prime }\left ( t\right ) =0\) hence \(T_{0}\left ( t\right ) \) is a constant. Hence the solution \(u_{0}\left ( x,t\right ) \) associated with this \(\lambda =0\) is\begin {align*} u_{0}\left ( x,t\right ) & =X_{0}T_{0}\\ & =A_{0} \end {align*}

where constant \(c_{2}T_{0}\) was renamed to \(\frac {A_{0}}{2}\) to indicate it is associated with \(\lambda =0\).  \(\lambda =0\) is an eigenvalue with eigenfunction constant \(\frac {A_{0}}{2}\).

case \(\lambda >0\)

The solution is\begin {align*} X\left ( x\right ) & =c_{1}\cos \left ( \sqrt {\lambda }x\right ) +c_{2}\sin \left ( \sqrt {\lambda }x\right ) \\ X^{\prime }\left ( x\right ) & =-c_{1}\sqrt {\lambda }\sin \left ( \sqrt {\lambda }x\right ) +c_{2}\sqrt {\lambda }\cos \left ( \sqrt {\lambda }x\right ) \end {align*}

Applying the left B.C. gives\[ 0=c_{2}\sqrt {\lambda }\] Therefore \(c_{2}=0\) as \(\lambda >0\). The solution becomes \[ X\left ( x\right ) =c_{1}\cos \left ( \sqrt {\lambda }x\right ) \] And \(X^{\prime }\left ( x\right ) =-c_{1}\sqrt {\lambda }\sin \left ( \sqrt {\lambda }x\right ) \). Applying the right B.C. gives\[ 0=-c_{1}\sqrt {\lambda }\sin \left ( \sqrt {\lambda }L\right ) \] \(c_{1}=0\) gives a trivial solution. Selecting \(\sin \left ( \sqrt {\lambda }L\right ) =0\) gives\[ \sqrt {\lambda }L=n\pi \qquad n=1,2,3,\cdots \] Or\[ \lambda _{n}=\left ( \frac {n\pi }{L}\right ) ^{2}\qquad n=1,2,3,\cdots \] Therefore the eigenfunctions are\[ X_{n}\left ( x\right ) =\cos \left ( \frac {n\pi }{L}x\right ) \qquad n=1,2,3,\cdots \] The time solution is found by solving \[ T_{n}^{\prime }\left ( t\right ) +k\lambda _{n}T_{n}\left ( t\right ) =0 \] This has the solution\begin {align*} T_{n}\left ( t\right ) & =A_{n}e^{-k\lambda _{n}t}\\ & =A_{n}e^{-k\left ( \frac {n\pi }{L}\right ) ^{2}t}\qquad n=1,2,3,\cdots \end {align*}

The solution to the PDE is \[ u_{n}\left ( x,t\right ) =T_{n}\left ( t\right ) X_{n}\left ( x\right ) \qquad n=0,1,2,3,\cdots \] But for linear system sum of eigenfunctions is also a solution. Hence\begin {align} u\left ( x,t\right ) & =u_{0}\left ( x,t\right ) +\sum _{n=1}^{\infty }u_{n}\left ( x,t\right ) \nonumber \\ & =\frac {A_{0}}{2}+\sum _{n=1}^{\infty }A_{n}\cos \left ( \frac {n\pi }{L}x\right ) e^{-k\left ( \frac {n\pi }{L}\right ) ^{2}t}\tag {1} \end {align}

From the solution found above, setting \(t=0\) gives\[ f\left ( x\right ) =\frac {A_{0}}{2}+\sum _{n=1}^{\infty }A_{n}\cos \left ( \frac {n\pi }{L}x\right ) \] Hence \(A_{0},A_{n}\) are the Fourier \(\cos \) coefficients for the function \(f\left ( x\right ) \). Doing an even extension of \(f\left ( x\right ) \) from \(\left [ -L,L\right ] \), then \(\frac {A_{0}}{2}\) is the average of the function \(f\left ( x\right ) \) over \(\left [ -L,L\right ] \). But this average is seen as \(\frac {2\left ( \frac {1}{2}\times \frac {1}{2}\right ) }{2}=\frac {1}{4}\). The term \(\frac {1}{2}\times \frac {1}{2}\) is the area of \(f\left ( x\right ) \) from \(\left [ 0,L\right ] \).\[ \frac {A_{0}}{2}=\frac {1}{4}\] For \(A_{n}\)\[ A_{n}=\frac {1}{L}\int _{-L}^{L}f\left ( x\right ) \cos \left ( \frac {n\pi }{L}x\right ) dx \] Replacing \(L=1\) and using the definition of \(f\left ( x\right ) \) given above gives\[ A_{n}=\int _{-1}^{1}f\left ( x\right ) \cos \left ( \frac {n\pi }{L}x\right ) dx \] But \(f\left ( x\right ) \) is even (after even extending) and \(\cos \) is even, hence the above becomes\begin {align} A_{n} & =2\int _{0}^{1}f\left ( x\right ) \cos \left ( n\pi x\right ) dx\nonumber \\ & =2\left ( \int _{0}^{\frac {1}{2}}x\cos \left ( n\pi x\right ) dx+\int _{\frac {1}{2}}^{1}\left ( 1-x\right ) \cos \left ( n\pi x\right ) dx\right ) \nonumber \\ & =2\left ( \int _{0}^{\frac {1}{2}}x\cos \left ( n\pi x\right ) dx+\int _{\frac {1}{2}}^{1}\cos \left ( n\pi x\right ) dx-\int _{\frac {1}{2}}^{1}x\cos \left ( n\pi x\right ) dx\right ) \tag {2} \end {align}

But \begin {align} \int _{a}^{b}x\cos \left ( n\pi x\right ) dx & =\frac {1}{n\pi }\left [ x\sin \left ( n\pi x\right ) \right ] _{a}^{b}-\frac {1}{n\pi }\int _{a}^{b}\sin \left ( n\pi x\right ) dx\nonumber \\ & =\frac {1}{n\pi }\left [ x\sin \left ( n\pi x\right ) \right ] _{a}^{b}+\frac {1}{n^{2}\pi ^{2}}\left [ \cos \left ( n\pi x\right ) \right ] _{a}^{b}\tag {3} \end {align}

When \(a=0,b=\frac {1}{2}\) the above gives\begin {align} \int _{0}^{\frac {1}{2}}x\cos \left ( n\pi x\right ) dx & =\frac {1}{n\pi }\left [ x\sin \left ( n\pi x\right ) \right ] _{0}^{\frac {1}{2}}+\frac {1}{n^{2}\pi ^{2}}\left [ \cos \left ( n\pi x\right ) \right ] _{0}^{\frac {1}{2}}\nonumber \\ & =\frac {1}{n\pi }\left ( \frac {1}{2}\sin \left ( \frac {n\pi }{2}\right ) \right ) +\frac {1}{n^{2}\pi ^{2}}\left ( \cos \left ( \frac {n\pi }{2}\right ) -1\right ) \nonumber \\ & =\frac {1}{2n\pi }\sin \left ( \frac {n\pi }{2}\right ) +\frac {1}{n^{2}\pi ^{2}}\left ( \cos \left ( \frac {n\pi }{2}\right ) -1\right ) \nonumber \\ & =\frac {1}{2n\pi }\sin \left ( \frac {n\pi }{2}\right ) +\frac {1}{n^{2}\pi ^{2}}\cos \left ( \frac {n\pi }{2}\right ) -\frac {1}{n^{2}\pi ^{2}}\tag {4} \end {align}

And when \(a=\frac {1}{2},b=1\) (3) gives\begin {align} \int _{\frac {1}{2}}^{1}x\cos \left ( n\pi x\right ) dx & =\frac {1}{n\pi }\left [ x\sin \left ( n\pi x\right ) \right ] _{\frac {1}{2}}^{1}+\frac {1}{n^{2}\pi ^{2}}\left [ \cos \left ( n\pi x\right ) \right ] _{\frac {1}{2}}^{1}\nonumber \\ & =\frac {1}{n\pi }\left [ \sin \left ( n\pi \right ) -\frac {1}{2}\sin \left ( \frac {n\pi }{2}\right ) \right ] +\frac {1}{n^{2}\pi ^{2}}\left [ \cos \left ( n\pi \right ) -\cos \left ( \frac {n\pi }{2}\right ) \right ] \nonumber \\ & =-\frac {1}{2n\pi }\sin \left ( \frac {n\pi }{2}\right ) +\frac {1}{n^{2}\pi ^{2}}\cos \left ( n\pi \right ) -\frac {1}{n^{2}\pi ^{2}}\cos \left ( \frac {n\pi }{2}\right ) \tag {5} \end {align}

Substituting (4,5) into (2) gives\begin {align*} \frac {A_{n}}{2} & =\frac {1}{2n\pi }\sin \left ( \frac {n\pi }{2}\right ) +\frac {1}{n^{2}\pi ^{2}}\cos \left ( \frac {n\pi }{2}\right ) -\frac {1}{n^{2}\pi ^{2}}\\ & +\int _{\frac {1}{2}}^{1}\cos \left ( n\pi x\right ) dx\\ & -\left ( -\frac {1}{2n\pi }\sin \left ( \frac {n\pi }{2}\right ) +\frac {1}{n^{2}\pi ^{2}}\cos \left ( n\pi \right ) -\frac {1}{n^{2}\pi ^{2}}\cos \left ( \frac {n\pi }{2}\right ) \right ) \end {align*}

Or\begin {align*} \frac {A_{n}}{2} & =\frac {1}{2n\pi }\sin \left ( \frac {n\pi }{2}\right ) +\frac {1}{n^{2}\pi ^{2}}\cos \left ( \frac {n\pi }{2}\right ) -\frac {1}{n^{2}\pi ^{2}}\\ & +\frac {1}{n\pi }\overset {0}{\overbrace {\sin \left ( n\pi \right ) }}-\frac {1}{n\pi }\sin \left ( \frac {n\pi }{2}\right ) \\ & +\frac {1}{2n\pi }\sin \left ( \frac {n\pi }{2}\right ) -\frac {1}{n^{2}\pi ^{2}}\cos \left ( n\pi \right ) +\frac {1}{n^{2}\pi ^{2}}\cos \left ( \frac {n\pi }{2}\right ) \end {align*}

Or\begin {align*} \frac {A_{n}}{2} & =\left ( \frac {1}{n\pi }\sin \left ( \frac {n\pi }{2}\right ) +\frac {2}{n^{2}\pi ^{2}}\cos \left ( \frac {n\pi }{2}\right ) -\frac {1}{n^{2}\pi ^{2}}\right ) -\frac {1}{n\pi }\sin \left ( \frac {n\pi }{2}\right ) -\frac {1}{n^{2}\pi ^{2}}\cos \left ( n\pi \right ) \\ & =\frac {2\cos \left ( \frac {n\pi }{2}\right ) -1-\left ( -1\right ) ^{n}}{n^{2}\pi ^{2}} \end {align*}

Therefore the solution (1) becomes, after replacing \(L=1\) \begin {equation} u\left ( x,t\right ) =\frac {1}{4}+2\sum _{n=1}^{\infty }\frac {2\cos \left ( \frac {n\pi }{2}\right ) -1-\left ( -1\right ) ^{n}}{n^{2}\pi ^{2}}\cos \left ( n\pi x\right ) e^{-kn^{2}\pi ^{2}t}\nonumber \end {equation}

____________________________________________________________________________________

3.1.1.35 [185] Haberman 2.4.1 (b) (special case)

problem number 185

This is problem 2.4.1 part(b) from Richard Haberman applied partial differential equations, 5th edition.

Solve the heat equation

\[ u_t= k u_{xx} \]

The boundary conditions are \(u_x(0,t)=0\), \(u_x(L,t)=0\) with the temperature initially \(u(x,0)=6+ 4 \cos \left ( \frac {3 \pi x}{L} \right )\)

Mathematica

ClearAll["Global`*"]; 
NumericQ[L] =. ; 
pde =  D[u[x, t], t] == k*D[u[x, t], {x, 2}]; 
bc  = {Derivative[1, 0][u][0, t] == 0, Derivative[1, 0][u][L, t] == 0}; 
ic  = u[x, 0] == 6 + 4*Cos[(3*Pi*x)/L]; 
NumericQ[L] = True; 
sol =  AbsoluteTiming[TimeConstrained[DSolve[{pde, bc, ic}, u[x, t], {x, t}], 60*10]]; 
sol =  sol /. {K[1] -> n}; 
 NumericQ[L] =. ;
 

\[\left \{\left \{u(x,t)\to 4 e^{-\frac {9 \pi ^2 k t}{L^2}} \cos \left (\frac {3 \pi x}{L}\right )+6\right \}\right \}\]

Maple

restart; 
interface(showassumed=0); 
assume(L>0 and k>0); 
pde := diff(u(x,t),t)=k*diff(u(x,t),x$2); 
bc:=D[1](u)(0,t)=0,D[1](u)(L,t)=0; 
ic  := u(x,0)=6+4*cos(3*Pi*x/L); 
cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol',pdsolve([pde,bc,ic],u(x,t))),output='realtime'));
 

\[u \left ( x,t \right ) =6+4\,\cos \left ( 3\,{\frac {\pi \,x}{L}} \right ) {{\rm e}^{-9\,{\frac {{\pi }^{2}k\,t}{{L}^{2}}}}}\]

Hand solution

The general solution for this type of PDE is given in problem 3.1.1.31 on page 530 as\begin {equation} u\left ( x,t\right ) =A_{0}+\sum _{n=1}^{\infty }A_{n}\cos \left ( \frac {n\pi }{L}x\right ) e^{-k\left ( \frac {n\pi }{L}\right ) ^{2}t}\tag {1} \end {equation} In this example \(u\left ( x,0\right ) =\) \(f\left ( x\right ) =6+4\cos \frac {3\pi x}{L}\). Hence at \(t=0\) the above becomes\begin {align*} f\left ( x\right ) & =A_{0}+\sum _{n=1}^{\infty }A_{n}\cos \left ( \frac {n\pi }{L}x\right ) \\ 6+4\cos \frac {3\pi x}{L} & =A_{0}+\sum _{n=1}^{\infty }A_{n}\cos \left ( \frac {n\pi }{L}x\right ) \end {align*}

Comparing terms shows that\begin {align*} A_{0} & =6\\ A_{3} & =4 \end {align*}

And all other \(A_{n}=0\). Hence the solution (1) is\[ u\left ( x,t\right ) =6+4\cos \left ( \frac {3\pi }{L}x\right ) e^{-k\left ( \frac {3\pi }{L}\right ) ^{2}t}\]

____________________________________________________________________________________

3.1.1.36 [186] Haberman 2.4.1 (c) (special case)

problem number 186

This is problem 2.4.1 part(c) from Richard Haberman applied partial differential equations, 5th edition.

Solve the heat equation

\[ u_t = k u_{xx} \]

The boundary conditions are \(u_x(0,t)=0\), \(u_x(L,t)=0\) with the temperature initially \(u(x,0)=-2 \sin \frac {\pi x}{L}\)

Mathematica

ClearAll["Global`*"]; 
pde =  D[u[x, t], t] == k*D[u[x, t], {x, 2}]; 
bc  = {Derivative[1, 0][u][0, t] == 0, Derivative[1, 0][u][L, t] == 0}; 
ic  = u[x, 0] == -2*Sin[(Pi*x)/L]; 
sol =  AbsoluteTiming[TimeConstrained[DSolve[{pde, bc, ic}, u[x, t], {x, t}, Assumptions -> {L > 0 && k > 0}], 60*10]]; 
sol =  sol /. K[1] -> n;
 

\[\left \{\left \{u(x,t)\to \frac {2 \sum _{n=1}^{\infty }\frac {2 \left (1+(-1)^n\right ) e^{-\frac {k n^2 \pi ^2 t}{L^2}} L \cos \left (\frac {n \pi x}{L}\right )}{\left (n^2-1\right ) \pi }}{L}-\frac {4}{\pi }\right \}\right \}\]

Maple

restart; 
interface(showassumed=0); 
assume(L>0 and k>0); 
pde := diff(u(x,t),t)=k*diff(u(x,t),x$2); 
bc:=D[1](u)(0,t)=0,D[1](u)(L,t)=0; 
ic  := u(x,0)=-2*sin(Pi*x/L); 
cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol',pdsolve([pde,bc,ic],u(x,t))),output='realtime'));
 

\[u \left ( x,t \right ) ={\frac {1}{\pi } \left ( \sum _{n=2}^{\infty }4\,{\frac { \left ( -1 \right ) ^{n}+1}{\pi \, \left ( {n}^{2}-1 \right ) }\cos \left ( {\frac {n\pi \,x}{L}} \right ) {{\rm e}^{-{\frac {{\pi }^{2}{n}^{2}k\,t}{{L}^{2}}}}}}\pi -4 \right ) }\]

Hand solution

The general solution for this type of PDE is given in problem 3.1.1.31 on page 530 as\begin {equation} u\left ( x,t\right ) =A_{0}+\sum _{n=1}^{\infty }A_{n}\cos \left ( \frac {n\pi }{L}x\right ) e^{-k\left ( \frac {n\pi }{L}\right ) ^{2}t}\tag {1} \end {equation} At \(t=0\) the above becomes\begin {align*} f\left ( x\right ) & =A_{0}+\sum _{n=1}^{\infty }A_{n}\cos \left ( \frac {n\pi }{L}x\right ) \\ -2\sin \frac {\pi x}{L} & =A_{0}+\sum _{n=1}^{\infty }A_{n}\cos \left ( \frac {n\pi }{L}x\right ) \end {align*}

Multiplying both sides by \(\cos \left ( \frac {m\pi }{L}x\right ) \) and integrating gives\begin {align*} -2\int _{0}^{L}\sin \left ( \frac {\pi x}{L}\right ) \cos \left ( \frac {m\pi }{L}x\right ) dx & =\int _{0}^{L}\left ( A_{0}\cos \left ( \frac {m\pi }{L}x\right ) +\cos \left ( \frac {m\pi }{L}x\right ) \sum _{n=1}^{\infty }A_{n}\cos \left ( \frac {n\pi }{L}x\right ) \right ) dx\\ & =\int _{0}^{L}A_{0}\cos \left ( \frac {m\pi }{L}x\right ) dx+\int _{0}^{L}\sum _{n=1}^{\infty }A_{n}\cos \left ( \frac {m\pi }{L}x\right ) \cos \left ( \frac {n\pi }{L}x\right ) dx \end {align*}

Interchanging the order of integration and summation\[ \int _{0}^{L}-2\sin \left ( \frac {\pi x}{L}\right ) \cos \left ( \frac {m\pi }{L}x\right ) dx=\int _{0}^{L}A_{0}\cos \left ( \frac {m\pi }{L}x\right ) dx+\sum _{n=1}^{\infty }A_{n}\int _{0}^{L}\cos \left ( \frac {m\pi }{L}x\right ) \cos \left ( \frac {n\pi }{L}x\right ) dx \] Case \(m=0\)

The above becomes\[ -2\int _{0}^{L}\sin \left ( \frac {\pi x}{L}\right ) dx=\int _{0}^{L}A_{0}dx+\sum _{n=1}^{\infty }A_{n}\int _{0}^{L}\cos \left ( \frac {n\pi }{L}x\right ) dx \] But \(\int _{0}^{L}\cos \left ( \frac {n\pi }{L}x\right ) dx=0\) hence\begin {align*} \int _{0}^{L}-2\sin \left ( \frac {\pi x}{L}\right ) dx & =\int _{0}^{L}A_{0}dx\\ A_{0}L & =-2\int _{0}^{L}\sin \left ( \frac {\pi x}{L}\right ) dx\\ A_{0}L & =-2\left ( -\frac {\cos \left ( \frac {\pi x}{L}\right ) }{\frac {\pi }{L}}\right ) _{0}^{L}\\ & =-\frac {2L}{\pi }\left ( -\cos \left ( \frac {\pi L}{L}\right ) +\cos \left ( \frac {\pi 0}{L}\right ) \right ) \\ & =-\frac {2L}{\pi }\left ( -\left ( -1\right ) +1\right ) \\ & =-\frac {4L}{\pi } \end {align*}

Hence\[ A_{0}=\frac {-4}{\pi }\] Case \(m>0\)

\[ \int _{0}^{L}-2\sin \left ( \frac {\pi x}{L}\right ) \cos \left ( \frac {m\pi }{L}x\right ) dx=\int _{0}^{L}A_{0}\cos \left ( \frac {m\pi }{L}x\right ) dx+\sum _{n=1}^{\infty }A_{n}\int _{0}^{L}\cos \left ( \frac {m\pi }{L}x\right ) \cos \left ( \frac {n\pi }{L}x\right ) dx \] One term survives the summation resulting in\[ \int _{0}^{L}-2\sin \left ( \frac {\pi x}{L}\right ) \cos \left ( \frac {m\pi }{L}x\right ) dx=\frac {-4}{\pi }\int _{0}^{L}\cos \left ( \frac {m\pi }{L}x\right ) dx+A_{m}\int _{0}^{L}\cos ^{2}\left ( \frac {m\pi }{L}x\right ) dx \] But \(\int _{0}^{L}\cos \left ( \frac {m\pi }{L}x\right ) dx=0\) and \(\int _{0}^{L}\cos ^{2}\left ( \frac {m\pi }{L}x\right ) dx=\frac {L}{2}\), therefore\begin {align*} \int _{0}^{L}-2\sin \left ( \frac {\pi x}{L}\right ) \cos \left ( \frac {m\pi }{L}x\right ) dx & =A_{m}\frac {L}{2}\\ A_{n} & =\frac {-4}{L}\int _{0}^{L}\sin \left ( \frac {\pi x}{L}\right ) \cos \left ( \frac {n\pi }{L}x\right ) dx \end {align*}

But\[ \int _{0}^{L}\sin \left ( \frac {\pi x}{L}\right ) \cos \left ( \frac {n\pi }{L}x\right ) dx=\frac {-L\left ( 1+\cos \left ( n\pi \right ) \right ) }{\pi \left ( n^{2}-1\right ) }\] Therefore\begin {align*} A_{n} & =4\frac {\left ( 1+\cos \left ( n\pi \right ) \right ) }{\pi \left ( n^{2}-1\right ) }\\ & =4\frac {\left ( -1\right ) ^{n}+1}{\pi \left ( n^{2}-1\right ) }\qquad n=1,2,3,\cdots \end {align*}

Hence the solution becomes\[ u\left ( x,t\right ) =\frac {-4}{\pi }+\frac {4}{\pi }\sum _{n=1}^{\infty }\frac {\left ( -1\right ) ^{n}+1}{\left ( n^{2}-1\right ) }\cos \left ( \frac {n\pi }{L}x\right ) e^{-k\left ( \frac {n\pi }{L}\right ) ^{2}t}\]

____________________________________________________________________________________

3.1.1.37 [187] Haberman 2.4.1 (d)

problem number 187

This is problem 2.4.1 part(d) from Richard Haberman applied partial differential equations, 5th edition.

Solve the heat equation

\[ \frac { \partial u}{\partial t} = k \frac { \partial ^2 u}{\partial x^2} \]

The boundary conditions are \(\frac {\partial u}{\partial x}(0,t)=0\) and \(\frac {\partial u}{\partial x}(L,t)=0\) with the temperature initially \(u(x,0)=-3 \cos \frac {8 \pi x}{L}\)

Mathematica

ClearAll["Global`*"]; 
NumericQ[L] =. ; 
 
pde =  D[u[x, t], t] == k*D[u[x, t], {x, 2}]; 
bc  = {Derivative[1, 0][u][0, t] == 0, Derivative[1, 0][u][L, t] == 0}; 
ic  = u[x, 0] == -3*Cos[(8*Pi*x)/L]; 
NumericQ[L] = True; 
sol =  AbsoluteTiming[TimeConstrained[DSolve[{pde, bc, ic}, u[x, t], {x, t}], 60*10]]; 
sol =  sol /. {K[1] -> n}; 
 NumericQ[L] =. ;
 

\[\left \{\left \{u(x,t)\to -3 e^{-\frac {64 \pi ^2 k t}{L^2}} \cos \left (\frac {8 \pi x}{L}\right )\right \}\right \}\]

Maple

restart; 
interface(showassumed=0); 
pde := diff(u(x,t),t)=k*diff(u(x,t),x$2); 
bc:=D[1](u)(0,t)=0,D[1](u)(L,t)=0; 
assume(L>0 and k>0); 
ic  := u(x,0)=-3*cos(8*Pi*x/L); 
cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol',pdsolve([pde,bc,ic],u(x,t))),output='realtime'));
 

\[u \left ( x,t \right ) =-3\,\cos \left ( 8\,{\frac {\pi \,x}{L}} \right ) {{\rm e}^{-64\,{\frac {{\pi }^{2}k\,t}{{L}^{2}}}}}\]

____________________________________________________________________________________

3.1.1.38 [188] both ends insulated

problem number 188

Added December 20, 2018.

Taken from https://www.mapleprimes.com/posts/209970-Exact-Solutions-For-PDE-And-Boundary--Initial-Conditions-2018

Solve the heat equation for \(u(x,t)\)

\[ u_t= 13 u_{xx} \]

For \(0<x<1\) and \(t>0\). The boundary conditions are \begin {align*} \frac {\partial u}{\partial x}(0,t) &= 0\\ \frac {\partial u}{\partial x}(1,t) &= 1 \end {align*}

Initial condition is \(u(x,0)=\frac {1}{2} x^2+x\)

Mathematica

ClearAll["Global`*"]; 
pde =  D[u[x, t], t] == 13*D[u[x, t], {x, 2}]; 
bc  = {Derivative[1, 0][u][0, t] == 0, Derivative[1, 0][u][1, t] == 1}; 
ic  = u[x, 0] == (1*x^2)/2 + x; 
sol =  AbsoluteTiming[TimeConstrained[DSolve[{pde, ic, bc}, u[x, t], x, t], 60*10]];
 

Failed

Maple

restart; 
pde := diff(u(x, t), t) = 13*(diff(u(x, t), x$2)); 
bc  := eval( diff(u(x,t),x),x=0)=0 , eval( diff(u(x,t),x),x=1)=1; 
ic  := u(x,0)=1/2*x^2+x; 
cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol', pdsolve([pde, bc,ic],u(x,t))),output='realtime'));
 

\[u \left ( x,t \right ) =1/2+\sum _{n=1}^{\infty }2\,{\frac {\cos \left ( n\pi \,x \right ) {{\rm e}^{-13\,{\pi }^{2}{n}^{2}t}} \left ( \left ( -1 \right ) ^{n}-1 \right ) }{{\pi }^{2}{n}^{2}}}+13\,t+1/2\,{x}^{2}\]

____________________________________________________________________________________

3.1.1.39 [189] convection heat loss

problem number 189

This problem is taken from Maple primes post

Left end insulated, right end has convection heat loss https://www.mapleprimes.com/posts/209681-Solving-PDEs-With-Initial-And-Boundary

Solve the heat equation

\[ u_t = k u_{xx} \]

The boundary conditions are, on the left end \(\frac {\partial u}{\partial x}(0,t)=0\) and on the right end \(\frac {\partial u}{\partial x}(1,t)=-u(1,t)\) with the temperature initially \(u(x,0)=1-\frac {1}{4} x^3\)

Mathematica

ClearAll["Global`*"]; 
pde =  D[u[x, t], t] == k*D[u[x, t], {x, 2}]; 
ic  = u[x, 0] == 1 - (1*x^3)/4; 
bc  = {Derivative[1, 0][u][0, t] == 0, Derivative[1, 0][u][1, t] == -u[1, t]}; 
sol =  AbsoluteTiming[TimeConstrained[DSolve[{pde, bc, ic}, u[x, t], {x, t}, Assumptions -> {k > 0, t > 0}], 60*10]];
 

Failed

Maple

restart; 
pde := diff(u(x,t), t) = k*(diff(u(x,t), x, x)); 
ic  := u(x,0) = 1-(1/4)*x^3; 
bc  := eval(diff(u(x,t), x), x = 0) = 0, eval(diff(u(x,t), x), x = 1)+u(1,t) = 0; 
cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol',pdsolve([pde,bc,ic],u(x,t)) assuming t>0,k>0),output='realtime'));
 

\[u \left ( x,t \right ) = \left ( \sum _{n=0}^{\infty }3\,{\frac {{{\rm e}^{-{\lambda _{{n}}}^{2}kt}} \left ( {\lambda _{{n}}}^{3}\sin \left ( \lambda _{{n}} \right ) -{\lambda _{{n}}}^{2}\cos \left ( \lambda _{{n}} \right ) +2\,\lambda _{{n}}\sin \left ( \lambda _{{n}} \right ) +2\,\cos \left ( \lambda _{{n}} \right ) -2 \right ) \cos \left ( \lambda _{{n}}x \right ) }{{\lambda _{{n}}}^{3} \left ( \sin \left ( 2\,\lambda _{{n}} \right ) +2\,\lambda _{{n}} \right ) }}, \left \{ {\it And} \left ( \tan \left ( \lambda _{{n}} \right ) \lambda _{{n}}-1=0,0<\lambda _{{n}} \right ) \right \} \right ) \]

____________________________________________________________________________________

3.1.1.40 [190] Pinchover and Rubinstein 6.25

problem number 190

Added July 2, 2018. Taken from Maple 2018.1 document, originally exercise 6.25 from Pinchover and Rubinstein.

Solve the heat equation

\[ u_t = k u_{xx} + \cos (w t) \]

For \(0<x<L\) and \(t>0\). The boundary conditions are \begin {align*} \frac {\partial u}{\partial x}(0,t) &= 0 \\ \frac {\partial u}{\partial x}(L,t) &= 0 \\ \end {align*}

Initial condition is \(u(x,0)=x\).

Mathematica

ClearAll["Global`*"]; 
pde =  D[u[x, t], t] == k*D[u[x, t], {x, 2}] + Cos[w*t]; 
bc  = {Derivative[1, 0][u][0, t] == 0, Derivative[1, 0][u][L, t] == 0}; 
ic  = u[x, 0] == x; 
sol =  AbsoluteTiming[TimeConstrained[DSolve[{pde, ic, bc}, u[x, t], x, t, Assumptions -> {L > 0, t > 0, k > 0}], 60*10]];
 

Failed

Maple

restart; 
interface(showassumed=0); 
pde := diff(u(x, t), t) = k*(diff(u(x, t), x, x))+cos(w*t); 
bc  := (D[1](u))(L, t) = 0, (D[1](u))(0, t) = 0; 
ic  := u(x, 0) = x; 
cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol', pdsolve([pde,ic,bc],u(x,t)) assuming L>0),output='realtime'));
 

\[u \left ( x,t \right ) =1/2\,{\frac {1}{w} \left ( Lw+2\,\sum _{n=1}^{\infty }2\,{\frac {L \left ( \left ( -1 \right ) ^{n}-1 \right ) }{{\pi }^{2}{n}^{2}}\cos \left ( {\frac {n\pi \,x}{L}} \right ) {{\rm e}^{-{\frac {{\pi }^{2}{n}^{2}kt}{{L}^{2}}}}}}w+2\,\sin \left ( wt \right ) \right ) }\]

____________________________________________________________________________________

3.1.1.41 [191] external source

problem number 191

Added March 18, 2018.

Solve the heat equation

\[ \frac { \partial u}{\partial t}= k \frac { \partial ^2 u}{\partial x^2} + \left ( e^{-c t} \sin \left ( \frac {2 \pi x}{L} \right ) \right ) \]

For \(0<x<L\) and \(t>0\). The boundary conditions are \begin {align*} \frac {\partial u}{\partial x}(0,t) &= 0 \\ \frac {\partial u}{\partial x}(L,t) &= 0 \\ \end {align*}

Initial condition is \(u(x,0)=f(x)\).

Mathematica

ClearAll["Global`*"]; 
pde =  D[u[x, t], t] == k*D[u[x, t], {x, 2}] + Exp[-(c*t)]*Sin[(2*Pi*x)/L]; 
bc  = {Derivative[1, 0][u][0, t] == 0, Derivative[1, 0][u][L, t] == 0}; 
ic  = u[x, 0] == f[x]; 
sol =  AbsoluteTiming[TimeConstrained[DSolve[{pde, ic, bc}, u[x, t], x, t, Assumptions -> {L > 0, k > 0, t > 0}], 60*10]];
 

Failed

Maple

restart; 
interface(showassumed=0); 
pde :=  diff(u(x,t),t)=k*diff(u(x,t),x$2)+(exp(-c*t)*sin(2*Pi*x/L)); 
ic  :=  u(x,0)=f(x); 
bc  :=  D[1](u)(0,t)=0, D[1](u)(L,t)=0; 
cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol', pdsolve([pde,ic,bc],u(x,t)) assuming L>0,t>0,k>0),output='realtime'));
 

\[u \left ( x,t \right ) =1/3\,{\frac {1}{L\pi \, \left ( {L}^{2}c-k{\pi }^{2} \right ) } \left ( L\sum _{n=3}^{\infty }12\,{\frac {{L}^{2} \left ( \left ( -1 \right ) ^{n}-1 \right ) \left ( {L}^{2}c-k{\pi }^{2} \right ) }{ \left ( -{\pi }^{2}{n}^{2}k+{L}^{2}c \right ) \left ( {n}^{2}-4 \right ) }\cos \left ( {\frac {n\pi \,x}{L}} \right ) \left ( {{\rm e}^{-{\frac {{\pi }^{2}{n}^{2}kt}{{L}^{2}}}}}-{{\rm e}^{-tc}} \right ) }+ \left ( 3\,{L}^{3}\pi \,c-3\,L{\pi }^{3}k \right ) \sum _{n=1}^{\infty } \left ( 2\,{\frac {1}{L}\cos \left ( {\frac {n\pi \,x}{L}} \right ) {{\rm e}^{-{\frac {{\pi }^{2}{n}^{2}kt}{{L}^{2}}}}}\int _{0}^{L}\!\cos \left ( {\frac {n\pi \,x}{L}} \right ) f \left ( x \right ) \,{\rm d}x} \right ) +8\,{L}^{3}\cos \left ( {\frac {\pi \,x}{L}} \right ) {{\rm e}^{-{\frac {k{\pi }^{2}t}{{L}^{2}}}}}-8\,{L}^{3}\cos \left ( {\frac {\pi \,x}{L}} \right ) {{\rm e}^{-tc}}+3\,\pi \,\int _{0}^{L}\!f \left ( x \right ) \,{\rm d}x \left ( {L}^{2}c-k{\pi }^{2} \right ) \right ) }\]

____________________________________________________________________________________

3.1.1.42 [192] Diffusion Reaction (general case)

problem number 192

Added June 9, 2019

Consider the heat equation \[ u_t = k u_{xx} - \beta u \] Suppose the boundary conditions are \(u_x(0,t)=0,u_x(\pi ,t)=0\), solve with the temperature initially \(u\left ( x,0\right ) =x\)

Mathematica

ClearAll["Global`*"]; 
pde =  D[u[x, t], t] == k*D[u[x, t], {x, 2}] - beta*u[x, t]; 
bc  = {Derivative[1,0][u][0, t] == 0, Derivative[1,0][u][Pi, t] == 0}; 
ic  = u[x, 0] == x; 
sol =  AbsoluteTiming[TimeConstrained[DSolve[{pde, bc, ic}, u[x, t], {x, t}, Assumptions -> {beta > 0,k>0}], 60*10]];
 

Failed

Maple

restart; 
interface(showassumed=0); 
pde := diff(u(x,t),t)=k*diff(u(x,t),x$2)-beta*u(x,t); 
bc:=eval(diff(u(x,t),x),x=0)=0,eval(diff(u(x,t),x),x=Pi)=0; 
ic  := u(x,0)=x; 
cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol',pdsolve([pde,bc,ic],u(x,t)) assuming beta>0),output='realtime'));
 

\[u \left ( x,t \right ) =1/2\,\pi \,{{\rm e}^{-\beta \,t}}+\sum _{n=1}^{\infty }2\,{\frac {\cos \left ( nx \right ) {{\rm e}^{-t \left ( k{n}^{2}+\beta \right ) }} \left ( \left ( -1 \right ) ^{n}-1 \right ) }{\pi \,{n}^{2}}}\]

Hand solution

Solve

\[ \frac {\partial u}{\partial t}=k\frac {\partial ^{2}u}{\partial x^{2}}-\beta u\qquad 0<x<\pi ,t>0 \] with, \(k>0,\beta >0\) \begin {align*} \frac {\partial u\left ( 0,t\right ) }{\partial x} & =0\\ \frac {\partial u\left ( \pi ,t\right ) }{\partial x} & =0 \end {align*}

And initial conditions \[ u\left ( x,0\right ) =x \] Solution

Let \(u=X\left ( x\right ) T\left ( t\right ) \). Substituting into the PDE gives\[ T^{\prime }X=kX^{\prime \prime }T-\beta XT \] Dividing by \(XT\neq 0\) gives\begin {align*} \frac {T^{\prime }}{T} & =\frac {kX^{\prime \prime }}{X}-\beta \\ \frac {T^{\prime }}{T}+\beta & =\frac {kX^{\prime \prime }}{X}\\ \frac {T^{\prime }}{kT}+\frac {\beta }{k} & =\frac {X^{\prime \prime }}{X} \end {align*}

Since each sides depends on different variable and both are equal, they must be equal to same constant, say \(-\lambda \)\[ \frac {T^{\prime }}{\alpha T}+\frac {\beta }{\alpha }=\frac {X^{\prime \prime }}{X}=-\lambda \] This gives two ODE’s to solve\begin {align} X^{\prime \prime }+\lambda X & =0\tag {1}\\ X^{\prime }\left ( 0\right ) & =0\nonumber \\ X^{\prime }\left ( \pi \right ) & =0\nonumber \end {align}

And\begin {align} \frac {T^{\prime }}{kT}+\frac {\beta }{k} & =-\lambda \tag {2}\\ T^{\prime }+\beta T & =-\lambda kT\nonumber \\ T^{\prime }+T\left ( \lambda k+\beta \right ) & =0\nonumber \end {align}

Starting with (1).  

Assuming \(\lambda <0\), the solution is \begin {align*} X\left ( x\right ) & =A\cosh \left ( \sqrt {-\lambda }x\right ) +B\sinh \left ( \sqrt {-\lambda }x\right ) \\ X^{\prime } & =\sqrt {-\lambda }A\sinh \left ( \sqrt {-\lambda }x\right ) +\sqrt {-\lambda }B\cosh \left ( \sqrt {-\lambda }x\right ) \end {align*}

Applying first B.C. gives \(0=\sqrt {-\lambda }B\), hence \(B=0\). Therefore the solution becomes \(X\left ( x\right ) =A\cosh \left ( \sqrt {-\lambda }x\right ) \) and \(X^{\prime }=\sqrt {-\lambda }A\sinh \left ( \sqrt {-\lambda }x\right ) \). Applying second B.C. gives \[ 0=\sqrt {-\lambda }A\sinh \left ( \sqrt {-\lambda }\pi \right ) \] But \(\sinh \left ( \sqrt {-\lambda }\pi \right ) =0\) only when its argument is zero, which is not the case here. This means \(A=0\), leading to trivial solution. Therefore \(\lambda <0\) is not eigenvalue.

Assuming \(\lambda =0\). The solution is \(X=Ax+B\). Hence \(X^{\prime }=A\). Applying first B.C. Gives \(A=0\). Hence solution is \(X=B\). Second boundary condition gives no additional information. Therefore  \(X=1\) (constant) is the eigenfunction associated with \(\lambda =0\).

Assuming \(\lambda >0\). The solution is\begin {align*} X & =A\cos \left ( \sqrt {\lambda }x\right ) +B\sin \left ( \sqrt {\lambda }x\right ) \\ X^{\prime } & =-\sqrt {\lambda }A\sin \left ( \sqrt {\lambda }x\right ) +\sqrt {\lambda }B\cos \left ( \sqrt {\lambda }x\right ) \end {align*}

Applying first B.C. gives \(0=\sqrt {\lambda }B\), hence \(B=0\). and the solution becomes \(X=A\cos \left ( \sqrt {\lambda }x\right ) ,X^{\prime }=-\sqrt {\lambda }A\sin \left ( \sqrt {\lambda }x\right ) \). Applying second B.C. gives\[ 0=-\sqrt {\lambda }A\sin \left ( \sqrt {\lambda }\pi \right ) \] Therefore \begin {align*} \sin \left ( \sqrt {\lambda }\pi \right ) & =0\\ \sqrt {\lambda }\pi & =n\pi \qquad n=1,2,3,\cdots \\ \lambda & =n^{2}\qquad n=1,2,3,\cdots \end {align*}

Therefore the space solution is\begin {equation} X\left ( x\right ) =A_{0}+\sum _{n=1}^{\infty }A_{n}\cos \left ( nx\right ) \tag {3} \end {equation} Now the time ODE (2) is solved.\[ T^{\prime }+T\left ( \lambda k+\beta \right ) =0 \] Integrating factor is \(e^{\int \lambda k+\beta dt}=e^{\left ( \lambda k+\beta \right ) t}\). Hence   \(\frac {d}{dt}\left ( Te^{\left ( \lambda k+\beta \right ) t}\right ) =0\) or \(Te^{\left ( \lambda k+\beta \right ) t}=c\) where \(c\) is constant. Therefore\[ T\left ( t\right ) =ce^{-\left ( \lambda k+\beta \right ) t}\] For \(\lambda =0\), the solution is \[ T_{0}\left ( t\right ) =c_{0}e^{-\beta t}\] and for \(\lambda >0\), the solution is \[ T_{n}\left ( t\right ) =c_{n}e^{-\left ( n^{2}k+\beta \right ) t}\] Hence the time domain solution is\begin {equation} T\left ( t\right ) =c_{0}e^{-\beta t}+\sum _{n=1}^{\infty }c_{n}e^{-\left ( n^{2}k+\beta \right ) t}\tag {4} \end {equation} Combining (3,4) the solution is\begin {align} u_{n} & =X_{n}T_{n}\nonumber \\ u\left ( x,t\right ) & =\sum _{n=0}^{\infty }X_{n}T_{n}\nonumber \\ & =c_{0}e^{-\beta t}+\sum _{n=1}^{\infty }b_{n}\cos \left ( nx\right ) e^{-\left ( n^{2}k+\beta \right ) t}\tag {5} \end {align}

where both constants from space and time eigenfunctions are combined into one constant \(b_{n}\) above in the sum. Now initial conditions are used to find coefficients. At \(t=0\)\begin {align*} u\left ( x,0\right ) & =c_{0}+\sum _{n=1}^{\infty }b_{n}\cos \left ( nx\right ) \\ x & =c_{0}+\sum _{n=1}^{\infty }b_{n}\cos \left ( nx\right ) \end {align*}

Multiplying both sides by \(\cos \left ( mx\right ) \) and integrating gives\[ \int _{0}^{\pi }x\cos mxdx=\int _{0}^{\pi }\left ( c_{0}\cos mx+\sum _{n=1}^{\infty }b_{n}\cos mx\cos \left ( nx\right ) \right ) dx \] For \(m=0\), all terms in the sum in RHS vanish, and only \(c_{0}\) left\begin {align*} \int _{0}^{\pi }xdx & =\int _{0}^{\pi }c_{0}dx\\ & =c_{0}\pi \end {align*}

Hence\begin {align} c_{0} & =\frac {1}{\pi }\int _{0}^{\pi }xdx\tag {6}\\ & =\frac {1}{\pi }\frac {\pi ^{2}}{2}\nonumber \\ & =\frac {\pi }{2}\nonumber \end {align}

For \(n>0\)\begin {align*} \int _{0}^{\pi }x\cos mxdx & =\int _{0}^{\pi }\sum _{n=1}^{\infty }b_{n}\cos mx\cos \left ( nx\right ) dx\\ & =\sum _{n=1}^{\infty }b_{n}\int _{0}^{\pi }\cos mx\cos \left ( nx\right ) dx \end {align*}

All terms in the sum vanish except for \(n=m\). The above becomes\begin {align} \int _{0}^{\pi }x\cos mxdx & =b_{n}\frac {\pi }{2}\nonumber \\ b_{n} & =\frac {2}{\pi }\int _{0}^{\pi }x\cos mxdx\tag {7} \end {align}

Using integration by part, \(\int _{0}^{\pi }x\cos nxdx\), let \(u=x,dv=\cos nx,\rightarrow du=1,v=\frac {\sin nx}{n}\), therefore\begin {align*} \int _{0}^{\pi }x\cos nxdx & =\left ( x\frac {\sin nx}{n}\right ) _{0}^{\pi }-\frac {1}{n}\int _{0}^{\pi }\sin nxdx\\ & =\frac {1}{n}\left ( \pi \sin n\pi -0\right ) +\frac {1}{n}\left ( \frac {\cos nx}{n}\right ) _{0}^{\pi }\\ & =0+\frac {1}{n^{2}}\left ( \cos nx\right ) _{0}^{\pi }\\ & =\frac {1}{n^{2}}\left ( \cos n\pi -1\right ) \end {align*}

Hence \begin {align*} b_{n} & =\frac {2}{\pi }\int _{0}^{\pi }x\cos mxdx\\ & =\frac {2}{\pi }\frac {\left ( -1^{n}-1\right ) }{n^{2}} \end {align*}

Therefore the final solution is, from (5), by combing all above results, becomes\begin {align*} u\left ( x,t\right ) & =c_{0}e^{-\beta t}+\sum _{n=1}^{\infty }b_{n}\cos \left ( nx\right ) e^{-\left ( n^{2}k+\beta \right ) t}\\ & =\frac {\pi }{2}e^{-\beta t}+\frac {2}{\pi }\sum _{n=1}^{\infty }\frac {\left ( -1^{n}-1\right ) }{n^{2}}\cos \left ( nx\right ) e^{-\left ( n^{2}k+\beta \right ) t} \end {align*}

This is animation of the solution for \(k=1,\beta =2\) for \(2\) seconds. (Animation will only show in the HTML version)

Source code used for the above

____________________________________________________________________________________

3.1.1.43 [193] Pinchover and Rubinstein 6.23

problem number 193

Added July 2, 2018.

4th example from Maple document for new improvements in Maple 2018.1, originally taken from Pinchover and Rubinstein’s exercise 6.23 .

Solve the heat equation on bar

\[ u_t= u_{xx} + g(x,t) \]

Where \(g(x,t) = e^{3 t} \cos (17 \pi x)\) for \(0<x<1\) and \(t>0\). The boundary conditions are \begin {align*} \frac {\partial u}{\partial x}(0,t) &=0 \\ \frac {\partial u}{\partial x}(1,t) &=0 \end {align*}

Initial condition is \(u(x,0) =f(x)\) where \(f(x) = 3 \cos (42 \pi x)\).

Mathematica

ClearAll["Global`*"]; 
f[x] := 3*Cos[42*Pi*x]; 
 g[x, t] := Exp[3*t]*Cos[17*x*Pi]; 
pde =  D[u[x, t], t] == D[u[x, t], {x, 2}] + g[x, t]; 
bc  = {Derivative[1, 0][u][0, t] == 0, Derivative[1, 0][u][1, t] == 0}; 
ic  = u[x, 0] == f[x]; 
sol =  AbsoluteTiming[TimeConstrained[DSolve[{pde, bc, ic}, u[x, t], {x, t}], 60*10]];
 

\[\left \{\left \{u(x,t)\to \frac {\left (e^{3 t}-e^{-289 \pi ^2 t}\right ) \cos (17 \pi x)}{3+289 \pi ^2}+3 e^{-1764 \pi ^2 t} \cos (42 \pi x)\right \}\right \}\]

Maple

restart; 
f := x->3*cos(42*x*Pi); 
g :=(x,t)->exp(3*t)*cos(17*x*Pi); 
pde := diff(u(x, t), t)= (diff(u(x, t), x, x)) + g(x, t); 
bc  := (D[1](u))(0, t) = 0, (D[1](u))(1, t) = 0; 
ic  := u(x, 0) = f(x); 
cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol', simplify(pdsolve([pde, ic, bc],u(x,t)))),output='realtime'));
 

\[u \left ( x,t \right ) ={\frac { \left ( 867\,{\pi }^{2}+9 \right ) \cos \left ( 42\,\pi \,x \right ) {{\rm e}^{-1764\,{\pi }^{2}t}}+\cos \left ( 17\,\pi \,x \right ) \left ( -{{\rm e}^{-289\,{\pi }^{2}t}}+{{\rm e}^{3\,t}} \right ) }{289\,{\pi }^{2}+3}}\]

____________________________________________________________________________________

3.1.1.44 [194] Pinchover and Rubinstein 6.21

problem number 194

added July 2, 2018.

Taken from Maple document for new improvements in Maple 2018.1, originally taken from Pinchover and Rubinstein’s exercise 6.21

Solve the heat equation on bar

\[ u_t = u_{xx} + g(x,t) \]

Where \(g(x,t) = t \cos (2001 x)\) for \(0<x<\pi \) and \(t>0\). The boundary conditions are \begin {align*} \frac {\partial u}{\partial x}(0,t) &=0 \\ \frac {\partial u}{\partial x}(1,t) &=0 \end {align*}

Initial condition is \(u(x,0) =f(x)\) where \(f(x) = \pi \cos (2 x)\).

Mathematica

ClearAll["Global`*"]; 
pde =  D[u[x, t], t] == D[u[x, t], {x, 2}] + t*Cos[2001*x]; 
bc  = {Derivative[1, 0][u][0, t] == 0, Derivative[1, 0][u][Pi, t] == 0}; 
ic  = u[x, 0] == Pi*Cos[2*x]; 
sol =  AbsoluteTiming[TimeConstrained[DSolve[{pde, bc, ic}, u[x, t], {x, t}], 60*10]];
 

\[\left \{\left \{u(x,t)\to \pi e^{-4 t} \cos (2 x)+\frac {\left (4004001 t+e^{-4004001 t}-1\right ) \cos (2001 x)}{16032024008001}\right \}\right \}\]

Maple

restart; 
pde := diff(u(x, t), t)= (diff(u(x, t), x, x)) + t*cos(2001*x); 
bc  := (D[1](u))(0, t) = 0, (D[1](u))(Pi, t) = 0; 
ic  := u(x, 0) = Pi*cos(2*x); 
cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol', pdsolve([pde, ic, bc],u(x,t))),output='realtime'));
 

\[u \left ( x,t \right ) ={\frac { \left ( 4004001\,t+{{\rm e}^{-4004001\,t}}-1 \right ) \cos \left ( 2001\,x \right ) }{16032024008001}}+\cos \left ( 2\,x \right ) {{\rm e}^{-4\,t}}\pi \]

____________________________________________________________________________________

3.1.1.45 [195] Diffusion Reaction. Euler-Cauchy Sturm-Liouville

problem number 195

Added April 20, 2019.

Solve the parabolic pde for \(u(x,t)\) \[ u_t = x^2 u_{xx} + x u_x \] For \(1<x<b\) and \(t>0\). The boundary conditions are \begin {align*} u_x(1,t) &= 0\\ h u(b,t) + u_x(b,t) &= 0 \end {align*}

Where \(h>0\). Initial condition is \(u(x,0)=\ln x\)

Mathematica

ClearAll["Global`*"]; 
pde = D[u[x, t], t] == x^2*D[u[x, t], {x, 2}] + x*D[u[x, t], x]; 
ic  = u[x, 0] == Log[x]; 
bc  = {Derivative[1, 0][u][1, t] == 0, h*u[b, t] + Derivative[1, 0][u][b, t] == 0}; 
sol = AbsoluteTiming[TimeConstrained[DSolve[{pde, ic, bc}, u[x, t], {x, t}, Assumptions -> {b > 1, t > 0, h > 0}], 60*10]];
 

Failed

Maple

restart; 
pde := diff(u(x,t),t)=x^2*diff(u(x,t),x$2)+x*diff(u(x,t),x); 
bc:=eval( diff(u(x,t),x),x=1)=0,h*u(b,t)+eval( diff(u(x,t),x),x=b)=0; 
ic  := u(x,0)=ln(x); 
cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol', pdsolve({pde, ic, bc}, u(x, t))),output='realtime'));
 

time expired

Hand solution

Solve\begin {equation} u_{t}=x^{2}u_{xx}+xu_{x}\tag {1} \end {equation} With \(1<x\,<b,t>0\). BC\begin {align*} u_{x}\left ( 1,t\right ) & =0\\ hu\left ( b,t\right ) +u_{x}\left ( b,t\right ) & =0 \end {align*}

Where \(h>0\). And initial conditions\[ u\left ( x,0\right ) =\ln x \] Let \(u=X\left ( x\right ) T\left ( x\right ) \). Substituting into (1) gives \begin {align*} T^{\prime }X & =x^{2}X^{\prime \prime }T+xX^{\prime }T\\ \frac {T^{\prime }}{T} & =x^{2}\frac {X^{\prime \prime }}{X}+x\frac {X^{\prime }}{X}=-\lambda \end {align*}

Where \(\lambda \) is the separation constant. From the boundary conditions, we know that \(\lambda \) will be only positive. So we do not need to check for possibility of negative of zero eigenvalue. Letting \(\lambda =\alpha ^{2}\), then the above reduces to\begin {align} x^{2}X^{\prime \prime }+xX^{\prime }+\alpha ^{2}X & =0\tag {2}\\ T^{\prime }+\alpha ^{2}T & =0\tag {3} \end {align}

Equation (2) is Euler ODE. Assuming \(X=x^{r}\), then \(X^{\prime }=rx^{r-1},X^{\prime \prime }=r\left ( r-1\right ) x^{r-2}\). Substituting back into (2) gives the characteristic equation\begin {align*} r\left ( r-1\right ) x^{r}+rx^{r}+\alpha ^{2}x^{r} & =0\\ r^{2}+\alpha ^{2} & =0\\ r & =\pm i\alpha \end {align*}

Hence the solution to (2) is\begin {align*} X\left ( x\right ) & =Ax^{i\alpha }+Bx^{-i\alpha }\\ & =Ae^{\ln x^{i\alpha }}+Be^{\ln x^{-i\alpha }}\\ & =Ae^{i\alpha \ln x}+Be^{-i\alpha \ln x} \end {align*}

Which using Euler relation can be written as (using new constants, but the name of the constants kept the same for simplicity)\[ X\left ( x\right ) =A\cos \left ( \alpha \ln x\right ) +B\sin \left ( \alpha \ln x\right ) \] Applying first BC. \(X^{\prime }\left ( 1,t\right ) =0\) gives\begin {align*} X^{\prime }\left ( x\right ) & =-\frac {\alpha }{x}A\sin \left ( \alpha \ln x\right ) +B\frac {\alpha }{x}\cos \left ( \alpha \ln x\right ) \\ 0 & =-\alpha A\sin \left ( \alpha \ln 1\right ) +B\alpha \cos \left ( \alpha \ln 1\right ) \\ & =B\alpha \end {align*}

Since \(\alpha >0\) then \(B=0\). Hence the solution becomes \[ X\left ( x\right ) =A\cos \left ( \alpha \ln x\right ) \] Applying second BC. \(hX\left ( b\right ) +X^{\prime }\left ( b\right ) =0\) gives\begin {align} hA\cos \left ( \alpha \ln b\right ) -A\frac {\alpha }{b}\sin \left ( \alpha \ln b\right ) & =0\nonumber \\ h-\frac {\alpha }{b}\tan \left ( \alpha \ln b\right ) & =0\nonumber \\ \tan \left ( \alpha \ln b\right ) & =\frac {hb}{\alpha }\tag {4} \end {align}

There is no analytical solution to the above. The eigenvalues \(\alpha _{n}\) are the solutions to the above nonlinear equation. Therefore the eigenfunctions are \[ X_{n}\left ( x\right ) =\cos \left ( \alpha _{n}\ln x\right ) \] With eigenvalues \(\alpha _{n}>0\) given by solutions to (4). The solution to the time ODE is\begin {align*} T_{n}^{\prime }+\alpha _{n}^{2}T_{n} & =0\\ T_{n}\left ( t\right ) & =T_{n}\left ( 0\right ) e^{-\alpha _{n}^{2}t} \end {align*}

Hence the solution to (1) is\begin {equation} u\left ( x,t\right ) =\sum _{n=1}^{\infty }T_{n}\left ( 0\right ) e^{-\alpha _{n}^{2}t}\cos \left ( \alpha _{n}\ln x\right ) \tag {5} \end {equation} At \(t=0\)\[ \ln x=\sum _{n=1}^{\infty }T_{n}\left ( 0\right ) \cos \left ( \alpha _{n}\ln x\right ) \] Applying orthogonality gives\begin {align*} \int _{1}^{b}\ln x\cos \left ( \alpha _{n}\ln x\right ) dx & =T_{n}\left ( 0\right ) \int _{1}^{b}\cos ^{2}\left ( \alpha _{n}\ln x\right ) dx\\ T_{n}\left ( 0\right ) & =\frac {\int _{1}^{b}\ln x\cos \left ( \alpha _{n}\ln x\right ) dx}{\int _{1}^{b}\cos ^{2}\left ( \alpha _{n}\ln x\right ) dx} \end {align*}

Hence the solution (5) becomes\[ u\left ( x,t\right ) =\sum _{n=1}^{\infty }\left ( \frac {\int _{1}^{b}\ln x\cos \left ( \alpha _{n}\ln x\right ) dx}{\int _{1}^{b}\cos ^{2}\left ( \alpha _{n}\ln x\right ) dx}\right ) e^{-\alpha _{n}^{2}t}\cos \left ( \alpha _{n}\ln x\right ) \]

____________________________________________________________________________________

3.1.1.46 [196] convection heat loss

problem number 196

Added April 28, 2019

Problem 4, section 74, Fourier series and Boundary value problem, 8th edition by Brown and Churchill.

Solve the heat equation

\[ u_t = k u_{xx} \]

For \(0<x<1,t>0\). The boundary conditions are, on the left end \(u(0,t)=0\) and on the right end \(u_x(1,t)=-h u(1,t)\) with \(h>0\). Initial conditions \(u(x,0)=f(x)\)

Mathematica

ClearAll["Global`*"]; 
pde = D[u[x, t], t] == k*D[u[x, t], {x, 2}]; 
ic  = u[x, 0] == f[x]; 
bc  = {u[0, t] == 0, Derivative[1, 0][u][1, t] == -h u[1, t]}; 
sol = AbsoluteTiming[TimeConstrained[DSolve[{pde, bc, ic}, u[x, t], {x, t}, Assumptions -> {k > 0, t > 0, h > 0}], 60*10]];
 

Failed

Maple

restart; 
pde := diff(u(x,t), t) = k*(diff(u(x,t), x, x)); 
ic  := u(x,0) = f(x); 
bc  := u(0,t)=0, eval(diff(u(x,t), x), x = 1)=-h*u(1,t); 
cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol',pdsolve([pde,bc,ic],u(x,t)) assuming k>0,h>0,t>0),output='realtime'));
 

\[u \left ( x,t \right ) = \left ( \sum _{n=0}^{\infty } \left ( 2\,{h{\it signum} \left ( \sin \left ( \lambda _{{n}} \right ) \right ) {\it signum} \left ( \cos \left ( \lambda _{{n}} \right ) \right ) \sin \left ( \lambda _{{n}} \right ) \sin \left ( {\frac {h\sin \left ( \lambda _{{n}} \right ) x}{\cos \left ( \lambda _{{n}} \right ) }} \right ) {{\rm e}^{-{\frac { \left ( \sin \left ( \lambda _{{n}} \right ) \right ) ^{2}{h}^{2}kt}{ \left ( \cos \left ( \lambda _{{n}} \right ) \right ) ^{2}}}}}\int _{0}^{1}\!f \left ( x \right ) \sin \left ( {\frac {h\sin \left ( \lambda _{{n}} \right ) x}{\cos \left ( \lambda _{{n}} \right ) }} \right ) \,{\rm d}x \left ( h{\it signum} \left ( \sin \left ( \lambda _{{n}} \right ) \right ) {\it signum} \left ( \cos \left ( \lambda _{{n}} \right ) \right ) \sin \left ( \lambda _{{n}} \right ) -\cos \left ( {\frac {h{\it signum} \left ( \sin \left ( \lambda _{{n}} \right ) \right ) \sin \left ( \lambda _{{n}} \right ) }{ \left | \cos \left ( \lambda _{{n}} \right ) \right | }} \right ) \sin \left ( {\frac {h{\it signum} \left ( \sin \left ( \lambda _{{n}} \right ) \right ) \sin \left ( \lambda _{{n}} \right ) }{ \left | \cos \left ( \lambda _{{n}} \right ) \right | }} \right ) \cos \left ( \lambda _{{n}} \right ) \right ) ^{-1}} \right ) , \left \{ {\it And} \left ( \lambda _{{n}}-h\sqrt { \left ( \tan \left ( \lambda _{{n}} \right ) \right ) ^{2}}=0,-\infty \leq \lambda _{{n}} \land \lambda _{{n}}\leq \infty \right ) \right \} \right ) \]

Hand solution

To solve the PDE, we first check the boundary conditions by writing them as\begin {align*} a_{1}u\left ( 0,t\right ) +a_{2}u_{x}\left ( 0,t\right ) & =0\\ b_{1}u\left ( 1,t\right ) +b_{2}u_{x}\left ( 1,t\right ) & =0 \end {align*}

Then \(a_{1}=0,a_{2}=0\). Hence \(a_{1}a_{2}=0\). And \(b_{1}=1,b_{2}=h\). Then since it is assumed that \(h>0\), then \(b_{1}b_{2}\geq 0\). And since \(q\left ( x\right ) =0\) from the PDE itself, then we know that eigenvalues must be \(\lambda \geq 0\).

Let \(u=X\left ( x\right ) T\left ( t\right ) \) then the PDE becomes\begin {align*} T^{\prime }X & =X^{\prime \prime }T\\ \frac {T^{\prime }}{T} & =\frac {X^{\prime \prime }}{X}=-\lambda \end {align*}

Hence the Sturm Liouville problem is \begin {align*} X^{\prime \prime }+\lambda X & =0\\ X\left ( 0\right ) & =0\\ X^{\prime }\left ( 1\right ) +hX\left ( 1\right ) & =0 \end {align*}

Where \(p\left ( x\right ) =1\).

Case \(\lambda =0\)

Solution is \[ X\left ( x\right ) =Ax+B \] At \(x=0\)\[ 0=B \] Hence solution becomes\[ X\left ( x\right ) =Ax \] At \(x=1\) the second boundary conditions gives\begin {align*} A+hA & =0\\ A\left ( 1+h\right ) & =0 \end {align*}

For non trivial solution \(1+h=0\) or \(h=-1\). But we assumed that \(h>0\). Therefore \(\lambda =0\) is not eigenvalue.

Case \(\lambda >0\)

Let \(\lambda =\alpha ^{2},\alpha >0\). Hence solution is \[ X\left ( x\right ) =A\cos \left ( \alpha x\right ) +B\sin \left ( \alpha x\right ) \] At \(X\left ( 0\right ) =0\)\[ 0=A \] The solution becomes\[ X\left ( x\right ) =B\sin \left ( \alpha x\right ) \] At \(x=1\) the second boundary conditions gives\begin {align*} B\alpha \cos \left ( \alpha \right ) +hB\sin \left ( \alpha \right ) & =0\\ \alpha \cos \left ( \alpha \right ) +h\sin \left ( \alpha \right ) & =0\\ \tan \left ( \alpha \right ) & =-\frac {\alpha }{h} \end {align*}

Therefore the eigenvalues are given by solution to \[ \tan \left ( \alpha _{n}\right ) =-\frac {\alpha _{n}}{h}\qquad n=1,2,3,\cdots \] And eigenfunctions are\[ X_{n}\left ( x\right ) =\sin \left ( \alpha _{n}x\right ) \] The normalized eigenfunctions are\[ \phi _{n}\left ( x\right ) =\frac {X_{n}\left ( x\right ) }{\left \Vert X_{n}\left ( x\right ) \right \Vert }\] But \begin {align*} \left \Vert X_{n}\left ( x\right ) \right \Vert ^{2} & =\int _{0}^{1}p\left ( x\right ) X_{n}^{2}\left ( x\right ) dx\\ & =\int _{0}^{1}\sin ^{2}\left ( \alpha _{n}x\right ) dx\\ & =\frac {1}{2}\int _{0}^{1}1-\cos \left ( 2\alpha _{n}x\right ) dx\\ & =\frac {1}{2}\left ( 1-\left [ \frac {\sin \left ( 2\alpha _{n}x\right ) }{2\alpha _{n}}\right ] _{0}^{1}\right ) \\ & =\frac {1}{2}\left ( 1-\frac {1}{2\alpha _{n}}\left [ \sin \left ( 2\alpha _{n}x\right ) \right ] _{0}^{1}\right ) \\ & =\frac {1}{2}\left ( 1-\frac {\sin \left ( 2\alpha _{n}\right ) }{2\alpha _{n}}\right ) \\ & =\frac {1}{2}-\frac {\sin \left ( 2\alpha _{n}\right ) }{4\alpha _{n}} \end {align*}

But \(\sin \left ( 2\alpha _{n}\right ) =2\sin \alpha _{n}\cos \alpha _{n}\) and \(\alpha _{n}=-h\frac {\sin \left ( \alpha _{n}\right ) }{\cos \left ( \alpha _{n}\right ) }\), therefore the above becomes\begin {align*} \left \Vert X_{n}\left ( x\right ) \right \Vert ^{2} & =\frac {1}{2}+\frac {2\sin \alpha _{n}\cos \alpha _{n}}{4h\frac {\sin \left ( \alpha _{n}\right ) }{\cos \left ( \alpha _{n}\right ) }}\\ & =\frac {1}{2}+\frac {\cos ^{2}\alpha _{n}}{2h}\\ & =\frac {h+\cos ^{2}\alpha _{n}}{2h} \end {align*}

Hence\begin {align*} \phi _{n}\left ( x\right ) & =\frac {X_{n}\left ( x\right ) }{\sqrt {\frac {h+\cos ^{2}\alpha _{n}}{2h}}}\\ & =\sqrt {\frac {2h}{h+\cos ^{2}\alpha _{n}}}\sin \left ( \alpha _{n}x\right ) \end {align*}

Now we use generalized Fourier series to find the solution. Let\begin {equation} u\left ( x,t\right ) =\sum _{n=1}^{\infty }B_{n}\left ( t\right ) \phi _{n}\left ( x\right ) \tag {1} \end {equation} Substituting this back into the PDE gives\[ \sum _{n=1}^{\infty }B_{n}^{\prime }\left ( t\right ) \phi _{n}\left ( x\right ) =k\sum _{n=1}^{\infty }B_{n}\left ( t\right ) \phi _{n}^{\prime \prime }\left ( x\right ) \] But \(\phi _{n}^{\prime \prime }\left ( x\right ) =-\lambda _{n}\phi _{n}\left ( x\right ) =-\alpha _{n}^{2}\phi _{n}\left ( x\right ) \). The above becomes\begin {align*} \sum _{n=1}^{\infty }B_{n}^{\prime }\left ( t\right ) \phi _{n}\left ( x\right ) & =-k\sum _{n=1}^{\infty }B_{n}\left ( t\right ) \alpha _{n}^{2}\phi _{n}\left ( x\right ) \\ B_{n}^{\prime }\left ( t\right ) +k\alpha _{n}^{2}B_{n}\left ( t\right ) & =0 \end {align*}

The solution is \[ B_{n}\left ( t\right ) =B_{n}\left ( 0\right ) e^{-k\alpha _{n}^{2}t}\] Hence (1) becomes\[ u\left ( x,t\right ) =\sum _{n=1}^{\infty }B_{n}\left ( 0\right ) e^{-k\alpha _{n}^{2}t}\phi _{n}\left ( x\right ) \] At \(t=0\) the above becomes\[ f\left ( x\right ) =\sum _{n=1}^{\infty }B_{n}\left ( 0\right ) \phi _{n}\left ( x\right ) \] Therefore\begin {align*} B_{n}\left ( 0\right ) & =\left \langle f\left ( x\right ) ,\phi _{n}\left ( x\right ) \right \rangle \\ & =\int _{0}^{1}p\left ( x\right ) f\left ( x\right ) \phi _{n}\left ( x\right ) dx\\ & =\sqrt {\frac {2h}{h+\cos ^{2}\alpha _{n}}}\int _{0}^{1}f\left ( x\right ) \sin \left ( \alpha _{n}x\right ) dx \end {align*}

Therefore \begin {align*} B_{n}\left ( t\right ) & =B_{n}\left ( 0\right ) e^{-k\alpha _{n}^{2}t}\\ & =\left ( \sqrt {\frac {2h}{h+\cos ^{2}\alpha _{n}}}\int _{0}^{1}f\left ( x\right ) \sin \left ( \alpha _{n}x\right ) dx\right ) e^{-k\alpha _{n}^{2}t} \end {align*}

and solution (1) becomes\begin {align*} u\left ( x,t\right ) & =\sum _{n=1}^{\infty }\sqrt {\frac {2h}{h+\cos ^{2}\alpha _{n}}}\left ( \int _{0}^{1}f\left ( x\right ) \sin \left ( \alpha _{n}x\right ) dx\right ) e^{-k\alpha _{n}^{2}t}\sqrt {\frac {2h}{h+\cos ^{2}\alpha _{n}}}\sin \left ( \alpha _{n}x\right ) \\ & =\frac {2h}{h+\cos ^{2}\alpha _{n}}\sum _{n=1}^{\infty }\left ( \int _{0}^{1}f\left ( x\right ) \sin \left ( \alpha _{n}x\right ) dx\right ) e^{-k\alpha _{n}^{2}t}\sin \left ( \alpha _{n}x\right ) \end {align*}

____________________________________________________________________________________

3.1.1.47 [197] Mixed BC

problem number 197

Solve the heat equation

\[ \frac { \partial u}{\partial t} = k \frac { \partial ^2 u}{\partial x^2} \]

For \(0<x<L\) and \(t>0\). The boundary conditions are \begin {align*} \frac { \partial u}{\partial x}(0,t) +u(0,t) &=0 \\ \frac { \partial u}{\partial x}(L,t) +u(L,t) &=0 \end {align*}

And initial condition \(u(x,0)=f(x)\)

Mathematica

ClearAll["Global`*"]; 
pde =  D[u[x, t], t] == k*D[u[x, t], {x, 2}]; 
bc  = {Derivative[1, 0][u][0, t] + u[0, t] == 0, Derivative[1, 0][u][L, t] + u[L, t] == 0}; 
ic  = u[x, 0] == f[x]; 
sol =  AbsoluteTiming[TimeConstrained[DSolve[{pde, bc, ic}, u[x, t], {x, t}, Assumptions -> {k > 0, x > 0, x < L}], 60*10]];
 

Failed

Maple

restart; 
interface(showassumed=0); 
pde := diff(u(x,t),t)=k*diff(u(x,t),x$2); 
ic  := u(x,0)=f(x); 
bc:=D[1](u)(0,t)+u(0,t)=0,D[1](u)(L,t)+u(L,t)=0; 
cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol',pdsolve([pde,ic,bc],u(x,t)) assuming k>0,x>0,x<L),output='realtime'));
 

\[u \left ( x,t \right ) =\sum _{n=1}^{\infty } \left ( 2\,{\frac {1}{L \left ( {\pi }^{2}{n}^{2}+{L}^{2} \right ) } \left ( -\pi \,n\cos \left ( {\frac {\pi \,nx}{L}} \right ) +\sin \left ( {\frac {\pi \,nx}{L}} \right ) L \right ) {{\rm e}^{-{\frac {{\pi }^{2}{n}^{2}kt}{{L}^{2}}}}}\int _{0}^{L}\!f \left ( x \right ) \left ( -\pi \,n\cos \left ( {\frac {\pi \,nx}{L}} \right ) +\sin \left ( {\frac {\pi \,nx}{L}} \right ) L \right ) \,{\rm d}x} \right ) \]

____________________________________________________________________________________

3.1.1.48 [198] Haberman 8.2.1 (f)

problem number 198

added March 18, 2018.

This is problem 8.2.1, part(f) from Richard Haberman applied partial differential equations 5th edition.

Solve the heat equation

\[ \frac { \partial u}{\partial t}= k \frac { \partial ^2 u}{\partial x^2} + \sin \left ( \frac {2 \pi x}{L} \right ) \]

For \(0<x<L\) and \(t>0\). The boundary conditions are \begin {align*} \frac {\partial u}{\partial x}(0,t) &= 0 \\ \frac {\partial u}{\partial x}(L,t) &= 0 \\ \end {align*}

Initial condition is \(u(x,0)=f(x)\).

Mathematica

ClearAll["Global`*"]; 
pde =  D[u[x, t], t] == k*D[u[x, t], {x, 2}] + Sin[(2*Pi*x)/L]; 
bc  = {Derivative[1, 0][u][0, t] == 0, Derivative[1, 0][u][L, t] == 0}; 
ic  = u[x, 0] == f[x]; 
sol =  AbsoluteTiming[TimeConstrained[DSolve[{pde, ic, bc}, u[x, t], x, t, Assumptions -> {L > 0, k > 0, t > 0}], 60*10]];
 

Failed

Maple

restart; 
interface(showassumed=0); 
pde :=  diff(u(x,t),t)=k*diff(u(x,t),x$2)+sin(2*Pi*x/L); 
ic  :=  u(x,0)=f(x); 
bc  :=  D[1](u)(0,t)=0, D[1](u)(L,t)=0; 
cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol', pdsolve([pde,ic,bc],u(x,t)) assuming L>0,t>0,k>0),output='realtime'));
 

\[u \left ( x,t \right ) =1/4\,{\frac {1}{{\pi }^{2}kL} \left ( 4\,\sum _{n=1}^{\infty } \left ( -1/2\,{\frac {1}{{\pi }^{2}kL}\cos \left ( {\frac {\pi \,nx}{L}} \right ) {{\rm e}^{-{\frac {{\pi }^{2}{n}^{2}kt}{{L}^{2}}}}}\int _{0}^{L}\!\cos \left ( {\frac {\pi \,nx}{L}} \right ) \left ( -4\,{\pi }^{2}f \left ( x \right ) k+4\,{\it \_C2}\,{\pi }^{2}k+{L}^{2}\sin \left ( 2\,{\frac {\pi \,x}{L}} \right ) -2\,Lx\pi \right ) \,{\rm d}x} \right ) {\pi }^{2}kL+4\,{\it \_C2}\,{\pi }^{2}kL+{L}^{3}\sin \left ( 2\,{\frac {\pi \,x}{L}} \right ) -2\,{L}^{2}x\pi -\int _{0}^{L}\!-4\,{\pi }^{2}f \left ( x \right ) k+4\,{\it \_C2}\,{\pi }^{2}k+{L}^{2}\sin \left ( 2\,{\frac {\pi \,x}{L}} \right ) -2\,Lx\pi \,{\rm d}x \right ) }\]

____________________________________________________________________________________