4.1.3 Finite domain (bar), right end homogeneous, left end not

4.1.3.1 [208] left end BC depends on time (general case)
4.1.3.2 [209] left end BC depends on time (special case)
4.1.3.3 [210] left end BC depends on time (special case)
4.1.3.4 [211] Haberman 8.3.6 (special case)
4.1.3.5 [212] BC depends on time (special case)

4.1.3.1 [208] left end BC depends on time (general case)

problem number 208

Added June 21, 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) &= A(t) \\ u(L,t) &= 0 \\ \end {align*}

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] == A[t], u[L, t] == 0}; 
ic  = u[x, 0] == 0; 
sol =  AbsoluteTiming[TimeConstrained[DSolve[{pde, ic, bc}, u[x, t], {x, t},Assumptions->{k>0,L>0}], 60*10]];
 

\[\left \{\left \{u(x,t)\to \underset {K[1]=1}{\overset {\infty }{\sum }}\frac {\sqrt {2} \cos \left (\frac {\pi x (2 K[1]-1)}{2 L}\right ) \left (\frac {4 \sqrt {2} e^{-\frac {k \pi ^2 t (1-2 K[1])^2}{4 L^2}} A(0) L^{3/2}}{\pi ^2 (1-2 K[1])^2}+\int _0^t \frac {4 \sqrt {2} \exp \left (-\frac {k \pi ^2 (1-2 K[1])^2 (t-K[2])}{4 L^2}\right ) L^{3/2} A'(K[2])}{\pi ^2 (1-2 K[1])^2} \, dK[2]\right )}{\sqrt {L}}+A(t) (x-L)\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) =A(t),u(L,t)=0; 
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 ) = \left (-L +x \right ) A \left (t \right )+\int _{0}^{t}\left (\moverset {\infty }{\munderset {n =0}{\sum }}\frac {8 L \cos \left (\frac {\left (2 n +1\right ) \pi x}{2 L}\right ) \left (\frac {d}{d \tau }A \left (\tau \right )\right ) {\mathrm e}^{-\frac {\left (t -\tau \right ) \left (n +\frac {1}{2}\right )^{2} \pi ^{2} k}{L^{2}}}}{\left (2 n +1\right )^{2} \pi ^{2}}\right )d \tau +8 \left (\moverset {\infty }{\munderset {n =0}{\sum }}\frac {A \left (0\right ) L \cos \left (\frac {\left (2 n +1\right ) \pi x}{2 L}\right ) {\mathrm e}^{-\frac {\pi ^{2} \left (2 n +1\right )^{2} k t}{4 L^{2}}}}{\left (2 n +1\right )^{2} \pi ^{2}}\right )\]

Hand solution

This 1D heat PDE has left one end with boundary condition that is time dependent.\begin {align*} u_{t} & =ku_{xx}\qquad 0<x<L,t>0\\ u_{x}\left ( 0,t\right ) & =A\left ( t\right ) \\ u\left ( L,t\right ) & =0\\ u\left ( x,0\right ) & =0 \end {align*}

Solution

Since the boundary condition is not homogeneous, we need to first find a reference function \(r\left ( x,t\right ) \). Let\[ r\left ( x,t\right ) =A\left ( t\right ) \left ( x-L\right ) \] This function only needs to satisfy the nonhomogeneous boundary conditions given. i.e. \(\frac {\partial r}{\partial x}\left ( 0,t\right ) =A\left ( t\right ) ,r\left ( L,t\right ) =0\). Now we can write\begin {equation} u\left ( x,t\right ) =v\left ( x,t\right ) +r\left ( x,t\right ) \tag {1} \end {equation} Since \(r\left ( x,t\right ) \) satisfies the nonhomogeneous B.C’s, then \(v\left ( x,t\right ) \) satisfies the homogeneous boundary conditions. Substituting the above back into the original PDE gives\begin {align} v_{t}+r_{t} & =k\left ( v_{xx}+r_{xx}\right ) \nonumber \\ v_{t}+A^{\prime }\left ( t\right ) \left ( x-L\right ) & =kv_{xx}\nonumber \\ v_{t} & =kv_{xx}+A^{\prime }\left ( t\right ) \left ( L-x\right ) \nonumber \\ & =kv_{xx}+Q\left ( x,t\right ) \tag {2} \end {align}

The PDE \(v_{t}=kv_{xx}+Q\left ( x,t\right ) \) has now homogeneous B.C. \(v_{x}\left ( 0,t\right ) =0,v\left ( L,0\right ) =0\). Where \(Q\left ( x,t\right ) =A^{\prime }\left ( t\right ) \left ( L-x\right ) \). The method of eigenfunction expansion is now used to solve (2). Let \[ v\left ( x,t\right ) =\sum _{n=1}^{\infty }a_{n}\left ( t\right ) \Phi _{n}\left ( x\right ) \] Substituting this back into (2) gives\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 ) \Phi _{n}^{\prime \prime }\left ( x\right ) +Q\left ( x,t\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 ) \end {align*}

Where \(Q\left ( x,t\right ) =\sum _{n=1}^{\infty }q_{n}\left ( t\right ) \Phi _{n}\left ( x\right ) \). Now, since \(\Phi _{n}^{\prime \prime }\left ( x\right ) =-\lambda _{n}\Phi _{n}\left ( x\right ) \) then the above reduces 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 {3} \end {align}

The eigenfunctions \(\Phi _{n}\left ( x\right ) \) come from solving the eigenvalue problem in \(v_{t}=kv_{xx}\) with homogeneous boundary conditions \(v_{x}\left ( 0,t\right ) =0,v\left ( L,t\right ) =0\). This was solved before in problem 4.1.1.28 on page 527. The eigenfunctions were found to be \(\Phi _{n}\left ( x\right ) =\cos \left ( \sqrt {\lambda _{n}}x\right ) ,n=1,3,5,\cdots \) with eigenvalues \(\lambda _{n}=\left ( \frac {n\pi }{2L}\right ) ^{2},n=1,3,5,\cdots \). Before solving the ODE (3), we need to first find \(q_{n}\left ( t\right ) \). Orthogonality is now used to find \(q_{n}\left ( t\right ) \)\begin {align*} Q\left ( x,t\right ) & =\sum _{n=1,3,5,\cdots }^{\infty }q_{n}\left ( t\right ) \cos \left ( \sqrt {\lambda _{n}}x\right ) \\ A^{\prime }\left ( t\right ) \left ( L-x\right ) & =\sum _{n=1,3,5,\cdots }^{\infty }q_{n}\left ( t\right ) \cos \left ( \sqrt {\lambda _{n}}x\right ) \\ \int _{0}^{L}A^{\prime }\left ( t\right ) \left ( L-x\right ) \cos \left ( \sqrt {\lambda _{n}}x\right ) dx & =\frac {L}{2}q_{n}\left ( t\right ) \\ q_{n}\left ( t\right ) & =\frac {2A^{\prime }\left ( t\right ) }{L}\int _{0}^{L}\left ( L-x\right ) \cos \left ( \frac {n\pi }{2L}x\right ) dx\\ & =-\frac {2A^{\prime }\left ( t\right ) }{L}\left ( \frac {4L^{2}\left ( \cos \left ( \frac {n\pi }{2}\right ) -1\right ) }{\pi ^{2}n^{2}}\right ) \qquad n=1,3,5,\cdots \end {align*}

But \(\cos \left ( \frac {n\pi }{2}\right ) -1=-1\) for \(n=1,3,5,\cdots \). Hence the above becomes\begin {align*} q_{n}\left ( t\right ) & =\frac {2A^{\prime }\left ( t\right ) }{L}\left ( \frac {4L^{2}}{\pi ^{2}n^{2}}\right ) \qquad n=1,3,5,\cdots \\ & =\frac {8A^{\prime }\left ( t\right ) L}{\pi ^{2}n^{2}} \end {align*}

Hence (3) becomes\begin {align*} a_{n}^{\prime }\left ( t\right ) +k\lambda _{n}a_{n}\left ( t\right ) & =q_{n}\left ( t\right ) \qquad n=1,2,3,\cdots \\ a_{n}^{\prime }\left ( t\right ) +k\left ( \frac {n\pi }{2L}\right ) ^{2}a_{n}\left ( t\right ) & =\frac {8A^{\prime }\left ( t\right ) L}{\pi ^{2}n^{2}}\\ a_{n}^{\prime }\left ( t\right ) +k\lambda _{n}a_{n}\left ( t\right ) & =\frac {8A^{\prime }\left ( t\right ) L}{\pi ^{2}n^{2}} \end {align*}

Integrating factor is \(e^{k\lambda _{n}t}\). Hence the above becomes\[ \frac {d}{dt}\left ( a\left ( t\right ) e^{k\lambda _{n}t}\right ) =\frac {8A^{\prime }\left ( t\right ) L}{\pi ^{2}n^{2}}e^{k\lambda _{n}t}\] Integrating gives\begin {align*} a_{n}\left ( t\right ) e^{k\lambda _{n}t} & =\int _{0}^{t}\frac {8A^{\prime }\left ( \tau \right ) L}{\pi ^{2}n^{2}}e^{k\lambda _{n}\tau }d\tau +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 {8A^{\prime }\left ( \tau \right ) L}{\pi ^{2}n^{2}}e^{k\lambda _{n}\tau }d\tau \end {align*}

Hence\begin {align*} v\left ( x,t\right ) & =\sum _{n=1}^{\infty }a_{n}\left ( t\right ) \Phi _{n}\left ( x\right ) \\ & =\sum _{n=1,3,5,\cdots }^{\infty }\left ( a_{n}\left ( 0\right ) e^{-k\lambda _{n}t}+\frac {8L}{\pi ^{2}n^{2}}e^{-k\lambda _{n}t}\int _{0}^{t}A^{\prime }\left ( \tau \right ) e^{k\lambda _{n}\tau }d\tau \right ) \cos \left ( \sqrt {\lambda _{n}}x\right ) \end {align*}

Since \(u\left ( x,t\right ) =v\left ( x,t\right ) +r\left ( x,t\right ) \) then\begin {equation} u\left ( x,t\right ) =A\left ( t\right ) \left ( x-L\right ) +\sum _{n=1,3,5,\cdots }^{\infty }\left ( a_{n}\left ( 0\right ) e^{-k\lambda _{n}t}+\frac {8L}{\pi ^{2}n^{2}}e^{-k\lambda _{n}t}\int _{0}^{t}A^{\prime }\left ( \tau \right ) e^{k\lambda _{n}\tau }d\tau \right ) \cos \left ( \sqrt {\lambda _{n}}x\right ) \tag {4} \end {equation} At \(t=0,u\left ( x,0\right ) =0\) and the above becomes \begin {align*} 0 & =A\left ( 0\right ) \left ( x-L\right ) +\sum _{n=1,3,5,\cdots }^{\infty }a_{n}\left ( 0\right ) \cos \left ( \sqrt {\lambda _{n}}x\right ) \\ A\left ( 0\right ) \left ( L-x\right ) & =\sum _{n=1,3,5,\cdots }^{\infty }a_{n}\left ( 0\right ) \cos \left ( \sqrt {\lambda _{n}}x\right ) \end {align*}

Applying orthogonality\begin {align*} \int _{0}^{L}\left ( L-x\right ) \cos \left ( \sqrt {\lambda _{n}}x\right ) dx & =a_{n}\left ( 0\right ) \frac {L}{2}\\ a_{n}\left ( 0\right ) & =\frac {2A\left ( 0\right ) }{L}\int _{0}^{L}\left ( L-x\right ) \cos \left ( \sqrt {\lambda _{n}}x\right ) dx\\ & =\frac {2A\left ( 0\right ) }{L}\left ( -\frac {\cos \left ( L\sqrt {\lambda _{n}}\right ) -1}{\lambda _{n}}\right ) \end {align*}

But \(\cos \left ( L\sqrt {\lambda _{n}}\right ) -1=\cos \left ( L\frac {n\pi }{2L}\right ) -1=\) \(\cos \left ( \frac {n\pi }{2}\right ) -1=-1\) for \(n=1,3,5,\cdots \), and the above becomes\[ a_{n}\left ( 0\right ) =\frac {2A\left ( 0\right ) }{L\lambda _{n}}\] Therefore the solution (4) is \[ u\left ( x,t\right ) =A\left ( t\right ) \left ( x-L\right ) +\sum _{n=1,3,5,\cdots }^{\infty }e^{-k\lambda _{n}t}\left ( \frac {2A\left ( 0\right ) }{L\lambda _{n}}+\frac {8L}{\pi ^{2}n^{2}}\int _{0}^{t}A^{\prime }\left ( \tau \right ) e^{k\lambda _{n}\tau }\right ) \cos \left ( \sqrt {\lambda _{n}}x\right ) \] Where \(\lambda _{n}=\left ( \frac {n\pi }{2L}\right ) ^{2}\). Hence\[ u\left ( x,t\right ) =A\left ( t\right ) \left ( x-L\right ) +\sum _{n=1,3,5,\cdots }^{\infty }e^{-k\left ( \frac {n\pi }{2L}\right ) ^{2}t}\left ( \frac {2A\left ( 0\right ) }{L\left ( \frac {n\pi }{2L}\right ) ^{2}}+\frac {8L}{\pi ^{2}n^{2}}\int _{0}^{t}A^{\prime }\left ( \tau \right ) e^{k\left ( \frac {n\pi }{2L}\right ) ^{2}\tau }d\tau \right ) \cos \left ( \frac {n\pi }{2L}x\right ) \]

____________________________________________________________________________________

4.1.3.2 [209] left end BC depends on time (special case)

problem number 209

Added June 22, 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) &= A(t) \\ u(L,t) &= 0 \\ \end {align*}

And initial condition is \(u(x,0)=0\). Using the following values \begin {align*} L&=5\\ k&=\frac {1}{100}\\ A(t)=e^t \end {align*}

Mathematica

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

\[\left \{\left \{u(x,t)\to \underset {K[1]=1}{\overset {\infty }{\sum }}\frac {40 e^{-\frac {\pi ^2 t (1-2 K[1])^2}{10000}} \cos \left (\frac {1}{10} \pi x (2 K[1]-1)\right ) \left (\pi ^2 (1-2 K[1])^2+10000 e^{\frac {\pi ^2 t (1-2 K[1])^2}{10000}+t}\right )}{\left (\pi ^2 (1-2 K[1])^2+10000\right ) (\pi -2 \pi K[1])^2}+e^t (x-5)\right \}\right \}\]

Maple

restart; 
k:=1/100; 
L:=5; 
pde := diff(u(x,t),t)= k*diff(u(x,t),x$2); 
ic  := u(x,0)=0; 
bc  := D[1](u)(0,t) =exp(t),u(L,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 ) = \left (\moverset {\infty }{\munderset {n =0}{\sum }}\frac {10 \left (2500 \,{\mathrm e}^{t}+\left (n +\frac {1}{2}\right )^{2} \pi ^{2} {\mathrm e}^{-\frac {\pi ^{2} \left (2 n +1\right )^{2} t}{10000}}\right ) \cos \left (\frac {\left (2 n +1\right ) \pi x}{10}\right )}{\left (2500+\left (n +\frac {1}{2}\right )^{2} \pi ^{2}\right ) \left (n +\frac {1}{2}\right )^{2} \pi ^{2}}\right )+\left (x -5\right ) {\mathrm e}^{t}\]

Hand solution

This PDE general solution was obtained in problem 4.1.3.1 on page 649 as\[ u\left ( x,t\right ) =A\left ( t\right ) \left ( x-L\right ) +\sum _{n=1,3,5,\cdots }^{\infty }e^{-k\left ( \frac {n\pi }{2L}\right ) ^{2}t}\left ( \frac {2A\left ( 0\right ) }{L\left ( \frac {n\pi }{2L}\right ) ^{2}}+\frac {8L}{\pi ^{2}n^{2}}\int _{0}^{t}A^{\prime }\left ( \tau \right ) e^{k\left ( \frac {n\pi }{2L}\right ) ^{2}\tau }d\tau \right ) \cos \left ( \frac {n\pi }{2L}x\right ) \] When \(A\left ( t\right ) =e^{t}\), the above becomes\[ u\left ( x,t\right ) =e^{t}\left ( x-L\right ) +\sum _{n=1,3,5,\cdots }^{\infty }e^{-k\left ( \frac {n\pi }{2L}\right ) ^{2}t}\left ( \frac {2}{L\left ( \frac {n\pi }{2L}\right ) ^{2}}+\frac {8L}{\pi ^{2}n^{2}}\int _{0}^{t}e\left ( \tau \right ) e^{k\left ( \frac {n\pi }{2L}\right ) ^{2}\tau }d\tau \right ) \cos \left ( \frac {n\pi }{2L}x\right ) \] But \[ \int _{0}^{t}e\left ( \tau \right ) e^{k\left ( \frac {n\pi }{2L}\right ) ^{2}\tau }d\tau =\frac {e^{k\left ( \frac {n\pi }{2L}\right ) ^{2}t+t}-1}{k\left ( \frac {n\pi }{2L}\right ) ^{2}+1}\] And the general solution becomes\begin {align*} u\left ( x,t\right ) & =e^{t}\left ( x-L\right ) +\sum _{n=1,3,5,\cdots }^{\infty }e^{-k\left ( \frac {n\pi }{2L}\right ) ^{2}t}\left ( \frac {2}{L\left ( \frac {n\pi }{2L}\right ) ^{2}}+\frac {8L}{\pi ^{2}n^{2}}\frac {e^{k\left ( \frac {n\pi }{2L}\right ) ^{2}t+t}-1}{k\left ( \frac {n\pi }{2L}\right ) ^{2}+1}\right ) \cos \left ( \frac {n\pi }{2L}x\right ) \\ & =e^{t}\left ( x-L\right ) +\sum _{n=1,3,5,\cdots }^{\infty }\left ( \frac {2e^{-k\left ( \frac {n\pi }{2L}\right ) ^{2}t}}{L\left ( \frac {n\pi }{2L}\right ) ^{2}}+\frac {8L}{\pi ^{2}n^{2}}\frac {e^{t}-e^{-k\left ( \frac {n\pi }{2L}\right ) ^{2}t}}{k\left ( \frac {n\pi }{2L}\right ) ^{2}+1}\right ) \cos \left ( \frac {n\pi }{2L}x\right ) \\ & =e^{t}\left ( x-L\right ) +\sum _{n=1,3,5,\cdots }^{\infty }e^{-k\left ( \frac {n\pi }{2L}\right ) ^{2}t}\left ( \frac {2}{L\left ( \frac {n\pi }{2L}\right ) ^{2}}-\frac {8L}{\left ( k\left ( \frac {n\pi }{2L}\right ) ^{2}+1\right ) \pi ^{2}n^{2}}\right ) +\frac {8Le^{t}}{\left ( k\left ( \frac {n\pi }{2L}\right ) ^{2}+1\right ) \pi ^{2}n^{2}}\cos \left ( \frac {n\pi }{2L}x\right ) \\ & =e^{t}\left ( x-L\right ) +\sum _{n=1,3,5,\cdots }^{\infty }\left ( \frac {8L}{n^{2}\pi ^{2}}-\frac {8L}{\left ( k\left ( \frac {n\pi }{2L}\right ) ^{2}+1\right ) \pi ^{2}n^{2}}\right ) e^{-k\left ( \frac {n\pi }{2L}\right ) ^{2}t}+\frac {8Le^{t}}{\left ( k\left ( \frac {n\pi }{2L}\right ) ^{2}+1\right ) \pi ^{2}n^{2}}\cos \left ( \frac {n\pi }{2L}x\right ) \end {align*}

In this problem \(L=5,k=\frac {1}{100}\), hence the above becomes\[ u\left ( x,t\right ) =e^{t}\left ( x-5\right ) +\sum _{n=1,3,5,\cdots }^{\infty }\left ( \left ( \frac {40}{n^{2}\pi ^{2}}-\frac {40}{\left ( k\left ( \frac {n\pi }{10}\right ) ^{2}+1\right ) \pi ^{2}n^{2}}\right ) e^{-\frac {n^{2}\pi ^{2}}{10000}t}+\frac {40e^{t}}{\left ( k\left ( \frac {n\pi }{10}\right ) ^{2}+1\right ) \pi ^{2}n^{2}}\right ) \cos \left ( \frac {n\pi }{10}x\right ) \] The following is an animation of the solution

Source code used for the above

____________________________________________________________________________________

4.1.3.3 [210] left end BC depends on time (special case)

problem number 210

Added June 22, 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) &= A(t) \\ u(L,t) &= 0 \\ \end {align*}

And initial condition is \(u(x,0)=0\). Using the following values \begin {align*} L&=5\\ k&=\frac {1}{100}\\ A(t)=\sin (t) \end {align*}

Mathematica

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

\[\left \{\left \{u(x,t)\to \underset {K[1]=1}{\overset {\infty }{\sum }}\frac {400000 \cos \left (\frac {1}{10} \pi x (2 K[1]-1)\right ) \left (\pi ^2 \cos (t) (1-2 K[1])^2-e^{-\frac {\pi ^2 t (1-2 K[1])^2}{10000}} \pi ^2 (1-2 K[1])^2+10000 \sin (t)\right )}{\left (\pi ^4 (1-2 K[1])^4+100000000\right ) (\pi -2 \pi K[1])^2}+(x-5) \sin (t)\right \}\right \}\]

Maple

restart; 
k:=1/100; 
L:=5; 
pde := diff(u(x,t),t)= k*diff(u(x,t),x$2); 
ic  := u(x,0)=0; 
bc  := D[1](u)(0,t) =sin(t),u(L,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 ) = 400000 \left (\moverset {\infty }{\munderset {n =0}{\sum }}\frac {\left (\pi ^{2} \left (n +\frac {1}{2}\right )^{2} \cos \left (t \right )-\left (n +\frac {1}{2}\right )^{2} \pi ^{2} {\mathrm e}^{-\frac {\pi ^{2} \left (2 n +1\right )^{2} t}{10000}}+2500 \sin \left (t \right )\right ) \cos \left (\frac {\left (2 n +1\right ) \pi x}{10}\right )}{16 \pi ^{2} \left (6250000+\left (n +\frac {1}{2}\right )^{4} \pi ^{4}\right ) \left (n +\frac {1}{2}\right )^{2}}\right )+\left (x -5\right ) \sin \left (t \right )\]

Hand solution

This PDE general solution was obtained in problem 4.1.3.1 on page 649 as\[ u\left ( x,t\right ) =A\left ( t\right ) \left ( x-L\right ) +\sum _{n=1,3,5,\cdots }^{\infty }e^{-k\lambda _{n}t}\left ( \frac {2A\left ( 0\right ) }{L\lambda _{n}}+\frac {8L}{\pi ^{2}n^{2}}\int _{0}^{t}A^{\prime }\left ( \tau \right ) e^{k\lambda _{n}\tau }d\tau \right ) \cos \left ( \sqrt {\lambda _{n}}x\right ) \] Where \(\lambda _{n}=\left ( \frac {n\pi }{2L}\right ) ^{2},n=1,3,5,\cdots \). When \(A\left ( t\right ) =\sin \left ( t\right ) \), the above becomes\[ u\left ( x,t\right ) =\sin \left ( t\right ) \left ( x-L\right ) +\sum _{n=1,3,5,\cdots }^{\infty }e^{-k\lambda _{n}t}\left ( \frac {8L}{\pi ^{2}n^{2}}\int _{0}^{t}\cos \left ( \tau \right ) e^{k\lambda _{n}\tau }d\tau \right ) \cos \left ( \sqrt {\lambda _{n}}x\right ) \] But \[ \int _{0}^{t}\cos \left ( \tau \right ) e^{k\lambda _{n}\tau }d\tau =\frac {k\lambda _{n}e^{k\lambda _{n}t}\cos \left ( t\right ) +e^{k\lambda _{n}t}\sin \left ( t\right ) -k\lambda _{n}}{k^{2}\lambda _{n}^{2}+1}\] And the general solution becomes\begin {align*} u\left ( x,t\right ) & =\left ( x-L\right ) \sin \left ( t\right ) +\sum _{n=1,3,5,\cdots }^{\infty }e^{-k\lambda _{n}t}\left ( \frac {8L}{\pi ^{2}n^{2}}\left ( \frac {k\lambda _{n}e^{k\lambda _{n}t}\cos \left ( t\right ) +e^{k\lambda _{n}t}\sin \left ( t\right ) -k\lambda _{n}}{k^{2}\lambda _{n}^{2}+1}\right ) \right ) \cos \left ( \sqrt {\lambda _{n}}x\right ) \\ & =\left ( x-L\right ) \sin \left ( t\right ) +\sum _{n=1,3,5,\cdots }^{\infty }\frac {8L}{\pi ^{2}n^{2}}\left ( \frac {k\lambda _{n}\cos \left ( t\right ) +\sin \left ( t\right ) -k\lambda _{n}e^{-k\lambda _{n}t}}{k^{2}\lambda _{n}^{2}+1}\right ) \cos \left ( \sqrt {\lambda _{n}}x\right ) \end {align*}

In this problem \(L=5,k=\frac {1}{100}\), hence the above becomes\[ u\left ( x,t\right ) =\left ( x-5\right ) \sin \left ( t\right ) +\sum _{n=1,3,5,\cdots }^{\infty }\frac {40}{\pi ^{2}n^{2}}\left ( \frac {\frac {1}{100}\left ( \frac {n\pi }{10}\right ) ^{2}\cos \left ( t\right ) +\sin \left ( t\right ) -\frac {1}{100}\left ( \frac {n\pi }{10}\right ) ^{2}e^{-\frac {1}{100}\left ( \frac {n\pi }{10}\right ) ^{2}t}}{\left ( \frac {1}{100}\left ( \frac {n\pi }{10}\right ) ^{2}\right ) ^{2}+1}\right ) \cos \left ( \frac {n\pi }{10}x\right ) \] The following is an animation of the solution

Source code used for the above

____________________________________________________________________________________

4.1.3.4 [211] Haberman 8.3.6 (special case)

problem number 211

Added Nov 25, 2018.

Problem 8.3.6 from Richard Haberman applied partial differential equations book, 5th edition

Solve the heat equation for \(u(x,t)\) \[ u_t = u_{xx} + \sin (5 x) e^{-2 t} \] For \(0<x<\pi \) and \(t>0\). The boundary conditions are \begin {align*} u(0,t) &= 1 \\ 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}] + Sin[5*x]*Exp[-2*t]; 
bc  = {u[0, t] == 1, u[Pi, t] == 0}; 
ic  = u[x, 0] == 0; 
sol =  AbsoluteTiming[TimeConstrained[DSolve[{pde, ic, bc}, u[x, t], x, t], 60*10]];
 

\[\left \{\left \{u(x,t)\to \underset {K[1]=1}{\overset {\infty }{\sum }}\left (\sqrt {\frac {2}{\pi }} \int _0^t e^{-K[1]^2 (t-K[2])} \left (\begin {array}{cc} \{ & \begin {array}{cc} e^{-2 K[2]} \sqrt {\frac {\pi }{2}} & K[1]=5 \\ 0 & \text {True} \\\end {array} \\\end {array}\right ) \, dK[2]-\frac {2 e^{-t K[1]^2}}{\pi K[1]}\right ) \sin (x K[1])-\frac {x}{\pi }+1\right \}\right \}\]

Maple

restart; 
pde := diff(u(x,t),t)= diff(u(x,t),x$2)+ sin(5*x)*exp(-2*t); 
ic  := u(x,0)=0; 
bc  := u(0,t) =1,u(Pi,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 ) = \frac {-23 x -46 \pi \left (\moverset {\infty }{\munderset {n =1}{\sum }}\frac {{\mathrm e}^{-n^{2} t} \sin \left (n x \right )}{\pi n}\right )+\pi \left (-{\mathrm e}^{-25 t}+{\mathrm e}^{-2 t}\right ) \sin \left (5 x \right )+23 \pi }{23 \pi }\]

Hand solution

This problem has nonhomogeneous B.C. and non-homogenous in the PDE itself (source present). First step is to use reference function to remove the nonhomogeneous B.C. then use the method of eigenfunction expansion on the resulting problem. Let \[ r\left ( x\right ) =c_{1}x+c_{2}\] At \(x=0,r\left ( x\right ) =1\), hence \(1=c_{2}\) and at \(x=\pi ,r\left ( x\right ) =0\), hence \(0=c_{1}\pi +1\) or \(c_{1}=-\frac {1}{\pi }\), therefore\[ r\left ( x\right ) =1-\frac {x}{\pi }\] Therefore\[ u\left ( x,t\right ) =v\left ( x,t\right ) +r\left ( x\right ) \] Where \(v\left ( x,t\right ) \) solution for the given PDE but with homogeneous B.C., therefore \begin {align} v_{t} & =v_{xx}+e^{-2t}\sin 5x\tag {1}\\ v\left ( 0,t\right ) & =0\nonumber \\ v\left ( \pi ,t\right ) & =0\nonumber \\ v\left ( x,0\right ) & =f\left ( x\right ) \nonumber \\ & =u\left ( x,0\right ) -r\left ( x\right ) \nonumber \\ & =0-\left ( 1-\frac {x}{\pi }\right ) \nonumber \\ & =\frac {x}{\pi }-1\nonumber \end {align}

We now solve (1). This is a PDE with homogeneous B.C. of the form \(v_{t}=v_{xx}+Q\left ( x,t\right ) \). The general solution to above PDE was solved in 4.1.6.4 on page 806 and the solution is

\begin {equation} v\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 ) \tag {2} \end {equation}

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

Replacing \(L=\pi ,f\left ( x\right ) =\frac {x}{\pi }-1,Q\left ( x,t\right ) =e^{-2t}\sin \left ( 5x\right ) \) into (3,2) gives

\begin {align} \Phi _{n}\left ( x\right ) & =\sin \left ( nx\right ) \tag {3A}\\ \lambda _{n} & =n^{2}\qquad n=1,2,3,\cdots \nonumber \end {align}

And

\begin {equation} v\left ( x,t\right ) =\sum _{n=1}^{\infty }e^{-kn^{2}t}\sin \left ( nx\right ) \left ( \frac {2}{\pi }\int _{0}^{\pi }\left ( \frac {s}{\pi }-1\right ) \sin \left ( ns\right ) ds\right ) +\sum _{n=1}^{\infty }e^{-kn^{2}t}\sin \left ( nx\right ) \left ( \int _{0}^{t}\frac {2}{\pi }e^{kn^{2}\tau }e^{-2\tau }\left ( \int _{0}^{\pi }\sin \left ( 5s\right ) \sin \left ( ns\right ) ds\right ) d\tau \right ) \tag {2A} \end {equation}

But \(\int _{0}^{\pi }\left ( \frac {s}{\pi }-1\right ) \sin \left ( ns\right ) ds=\frac {-1}{n}\) since \(n\) is integer. And \(\int _{0}^{\pi }\sin 5s\sin \left ( ns\right ) ds=0\) when \(n\neq 5\) and for \(n=5\) it becomes \(\frac {\pi }{2}\). Using these values in the above gives

\begin {align} v\left ( x,t\right ) & =\sum _{n=1}^{\infty }e^{-kn^{2}t}\sin \left ( nx\right ) \left ( \frac {-2}{\pi n}\right ) +e^{-k\left ( 5\right ) ^{2}t}\sin \left ( 5x\right ) \left ( \int _{0}^{t}\frac {2}{\pi }e^{k\left ( 5\right ) ^{2}\tau }e^{-2\tau }\left ( \frac {\pi }{2}\right ) d\tau \right ) \tag {2C}\\ & =-\frac {2}{\pi }\sum _{n=1}^{\infty }e^{-kn^{2}t}\frac {\sin \left ( nx\right ) }{n}+e^{-25kt}\sin \left ( 5x\right ) \left ( \int _{0}^{t}e^{25k\tau }e^{-2\tau }d\tau \right ) \end {align}

But \(\int _{0}^{t}e^{25k\tau }e^{-2\tau }d\tau =\frac {-1+e^{25kt-2t}}{25k-2}\) and the above becomes

\begin {align*} v\left ( x,t\right ) & =-\frac {2}{\pi }\sum _{n=1}^{\infty }e^{-kn^{2}t}\frac {\sin \left ( nx\right ) }{n}+e^{-25kt}\sin \left ( 5x\right ) \left ( \frac {-1+e^{25kt-2t}}{25k-2}\right ) \\ & =-\frac {2}{\pi }\sum _{n=1}^{\infty }\frac {1}{n}e^{-kn^{2}t}\sin \left ( nx\right ) +\sin \left ( 5x\right ) \left ( \frac {-e^{-25kt}+e^{-2t}}{25k-2}\right ) \end {align*}

Since \(u\left ( x,t\right ) =v\left ( x,t\right ) +r\left ( x\right ) \) then the final solution is

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

Animation is below using \(k=1\), the solution becomes

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

Source code used for the above

____________________________________________________________________________________

4.1.3.5 [212] BC depends on time (special case)

problem number 212

added March 8, 2018. Exam problem

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

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

Mathematica

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

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

Maple

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

\[u \left (x , t\right ) = \frac {12 \pi \left (\moverset {\infty }{\munderset {n =1}{\sum }}\frac {{\mathrm e}^{-n^{2} t} \sin \left (n x \right )}{\pi \,n^{3}}\right )-6 \left (\frac {1}{6} x^{2}+t -\frac {1}{3} \pi x \right ) \left (x -\pi \right )}{6 \pi }\]

____________________________________________________________________________________