____________________________________________________________________________________
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[u, t, k, x, L, n]; 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 ✓
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)=6*sin(9*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\,\sin \left ( 9\,{\frac {\pi \,x}{L}} \right ) {{\rm e}^{-81\,{\frac {k{\pi }^{2}t}{{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 ?? on page ?? 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*}
____________________________________________________________________________________
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 ✓
NumericQ[L] =. ; ClearAll[u, t, k, x, n]; 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 ✓
L:='L'; u:='u'; t:='t'; x:='x'; 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 {k{\pi }^{2}t}{{L}^{2}}}}}-\sin \left ( 3\,{\frac {\pi \,x}{L}} \right ) {{\rm e}^{-9\,{\frac {k{\pi }^{2}t}{{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 ?? on page ?? 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}\]
____________________________________________________________________________________
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[u, t, k, x, L, n]; 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]];
\[ \left \{\left \{u(x,t)\to \sum _{K[1]=1}^{\infty } \frac {4 \left (1+(-1)^{K[1]}\right ) e^{-\frac {k \pi ^2 t K[1]^2}{L^2}} K[1] \sin \left (\frac {\pi x K[1]}{L}\right )}{\pi \left (K[1]^2-9\right )}\right \}\right \} \]
but \(n=3\) should be special case
Maple ✓
L:='L'; u:='u'; t:='t'; x:='x'; 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 {k{\pi }^{2}{n}^{2}t}{{L}^{2}}}}}}\pi -16\,\sin \left ( 2\,{\frac {\pi \,x}{L}} \right ) {{\rm e}^{-4\,{\frac {k{\pi }^{2}t}{{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 ?? on page ?? 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}\]
____________________________________________________________________________________
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[u, t, k, x, L, n]; 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 ✓
L:='L'; u:='u'; t:='t'; x:='x'; 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\,n\pi \right ) +2+4\, \left ( -1 \right ) ^{1+n}}{n\pi }\sin \left ( {\frac {n\pi \,x}{L}} \right ) {{\rm e}^{-{\frac {k{\pi }^{2}{n}^{2}t}{{L}^{2}}}}}} \]
Hand solution
The basic solution for this type of PDE was already given in problem ?? on page ?? 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}\]
____________________________________________________________________________________
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[u, t, k, x, L, sol, n, f]; 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}{L}+\frac {\int _0^L f(x) \, dx}{L}\right \}\right \} \]
Maple ✓
L:='L'; u:='u'; t:='t'; x:='x';f:='f'; 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 {k{\pi }^{2}{n}^{2}t}{{L}^{2}}}}}\int _{0}^{L}\!f \left ( x \right ) \cos \left ( {\frac {n\pi \,x}{L}} \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.
____________________________________________________________________________________
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[u, t, k, x, L, a, f, alpha]; 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]];
\[ \text {Failed} \]
Maple ✓
L:='L'; u:='u'; t:='t'; x:='x'; a:='a';f:='f';alpha:='alpha'; 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 {n\pi \,x}{L}} \right ) {{\rm e}^{-{\frac {t \left ( k{\pi }^{2}{n}^{2}+{L}^{2}\alpha \right ) }{{L}^{2}}}}}\int _{0}^{L}\!f \left ( x \right ) \sin \left ( {\frac {n\pi \,x}{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 \]
____________________________________________________________________________________
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[u, t, k, x, 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] == 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 ✓
L:='L'; u:='u'; t:='t'; x:='x'; 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); 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))),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 {k{\pi }^{2}{n}^{2}t}{{L}^{2}}}}}} \]
____________________________________________________________________________________
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 ✓
NumericQ[L] =. ; ClearAll[u, t, k, x, 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 ✓
L:='L'; u:='u'; t:='t'; x:='x'; 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 {k\,{\pi }^{2}t}{{L}^{2}}}}} \]
Hand solution
The general solution for this type of PDE is given in problem 5.5 on page 87 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}\]
____________________________________________________________________________________
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[u, t, k, x, 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] == -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 ✓
L:='L'; u:='u'; t:='t'; x:='x'; 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 {k\,{\pi }^{2}{n}^{2}t}{{L}^{2}}}}}}\pi -4 \right ) } \]
Hand solution
The general solution for this type of PDE is given in problem 5.5 on page 87 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}\]
____________________________________________________________________________________
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 ✓
NumericQ[L] =. ; ClearAll[u, t, k, x, 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 ✓
L:='L'; u:='u'; t:='t'; x:='x'; 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 {k\,{\pi }^{2}t}{{L}^{2}}}}} \]
____________________________________________________________________________________
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[u, t, k, x, L, f]; 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 n+1)^2 \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 ✓
L:='L'; u:='u'; t:='t'; x:='x';f:='f'; interface(showassumed=0); pde:=diff(u(x,t),t)=k*diff(u(x,t),x$2); bc:=D[1](u)(0,t)=0,u(L,t)=0; assume(L>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 ) =\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 {{\pi }^{2}k\, \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*}
____________________________________________________________________________________
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[u, x, t, k]; 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]];
\[ \text {Failed} \]
Maple ✓
unassign('u,t,x,k,f'); 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 ) =\mbox {{\tt casesplit/ans}} \left ( \sum _{n=0}^{\infty }3\,{\frac { \left ( \left ( -{\lambda _{{n}}}^{2}+2 \right ) \cos \left ( \lambda _{{n}} \right ) -2+ \left ( {\lambda _{{n}}}^{3}+2\,\lambda _{{n}} \right ) \sin \left ( \lambda _{{n}} \right ) \right ) {{\rm e}^{-k{\lambda _{{n}}}^{2}t}}\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 ) \]
____________________________________________________________________________________
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[u, x, t, k, h, f]; 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]];
\[ \text {Failed} \]
Maple ✓
unassign('u,t,x,k,f,h'); 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 ) =\mbox {{\tt casesplit/ans}} \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 {k \left ( \sin \left ( \lambda _{{n}} \right ) \right ) ^{2}{h}^{2}t}{ \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*}
____________________________________________________________________________________
Added April 28, 2019
Problem 2, section 77, Fourier series and Boundary value problem, 8th edition by Brown and Churchill.
Solve the heat equation
\[ u_t = u_{xx} \]
For \(0<x<1,t>0\). The boundary conditions are \(u_x(0,t)=h u(0,t)\) and on the right end \(u(1,t)=1\) with \(h>0\). Initial conditions \(u(x,0)=0\)
Mathematica ✗
ClearAll[u, x, t, k,h]; pde = D[u[x, t], t] == D[u[x, t], {x, 2}]; ic = u[x, 0] == 0; bc = {Derivative[1, 0][u][0, t] == h * u[0,t], u[1, t] == 1}; sol = AbsoluteTiming[TimeConstrained[DSolve[{pde, bc, ic}, u[x, t], {x, t}, Assumptions->h>0], 60*10]];
\[ \text {Failed} \]
Maple ✗
unassign('u,t,x,k,f,h'); pde := diff(u(x,t), t) = (diff(u(x,t), x, x)); ic := u(x,0) = 0; bc:= eval(diff(u(x,t), x), x = 0) = h*u(0,t), u(1,t) = 1; cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol',pdsolve([pde,bc,ic],u(x,t)) assuming h>0),output='realtime'));
\[ \text { Exception } \]
Hand solution
Solve
\[ u_{t}=u_{xx}\qquad 0<x<1,t>0 \] With boundary conditions\begin {align*} u_{x}\left ( 0,t\right ) -hu\left ( 0,t\right ) & =0\\ u\left ( 1,t\right ) & =1 \end {align*}
With \(h>0\). And initial conditions \(u\left ( x,0\right ) =f\left ( x\right ) \).
Because the second B.C. is not zero, we need to introduce a reference function \(r\left ( x\right ) \) which satisfies the nonhomogeneous boundary conditions.
Let \(r\left ( x\right ) =Ax+B\). When \(x=0\) then the first BC gives\[ A-hB=0 \] And the second BC gives\[ A+B=1 \] From the first equation \(A=hB\). Substituting in the second equation give \(hB+B=1\) or \(B\left ( 1+h\right ) =1\) or \(B=\frac {1}{1+h}\). Hence \(A=\frac {h}{1+h}\). Therefore\begin {align} r\left ( x\right ) & =Ax+B\nonumber \\ & =\frac {h}{1+h}x+\frac {1}{1+h}\nonumber \\ & =\frac {hx+1}{1+h}\tag {1} \end {align}
To verify. \(r_{x}=\frac {h}{1+h}\). When \(x=0\) then \(r\left ( 0\right ) =\frac {1}{1+h}\). Hence \(r_{x}\left ( 0\right ) -hr\left ( 0\right ) =\frac {h}{1+h}-h\frac {1}{1+h}=0\) as expected. And when \(x=1\) then \(r\left ( 1\right ) =1\) as expected. Now that we found \(r\left ( x\right ) \) then we write\[ u\left ( x,t\right ) =v\left ( x,t\right ) +r\left ( x\right ) \] Where \(v\left ( x,t\right ) \) is the solution to the homogenous PDE\[ v_{t}=v_{xx}\qquad 0<x<1,t>0 \] With boundary conditions\begin {align*} v_{x}\left ( 0,t\right ) -hv\left ( 0,t\right ) & =0\\ v\left ( 1,t\right ) & =0 \end {align*}
We can now solve for \(v\left ( x,t\right ) \,\) using separation of variables since boundary conditions are homogenous. Separation of variables gives\begin {align*} X^{\prime \prime }+\lambda X & =0\\ X^{\prime }\left ( 0\right ) -hX\left ( 0\right ) & =0\\ X\left ( 1\right ) & =0 \end {align*}
The above is known eigenvalue problem which we found before. It has the following eigenfunctions and eigenvalues\begin {align*} \phi _{n}\left ( x\right ) & =\sqrt {\frac {2h}{h+\cos ^{2}\alpha _{n}}}\sin \left ( \alpha _{n}\left ( 1-x\right ) \right ) \qquad n=1,2,\cdots \\ \tan \left ( \alpha _{n}\right ) & =\frac {-\alpha _{n}}{h} \end {align*}
With \(\alpha _{n}>0\). Hence the solution \(v\left ( x,t\right ) \) using generalized Fourier series is\begin {equation} v\left ( x,t\right ) =\sum _{n=1}^{\infty }B_{n}\left ( t\right ) \phi _{n}\left ( x\right ) \tag {2} \end {equation} Substituting into the PDE \(v_{t}=v_{xx}\) gives\begin {align*} \sum _{n=1}^{\infty }B_{n}^{\prime }\left ( t\right ) \phi _{n}\left ( x\right ) & =\sum _{n=1}^{\infty }B_{n}\left ( t\right ) \phi _{n}^{\prime \prime }\left ( x\right ) \\ & =-\sum _{n=1}^{\infty }B_{n}\left ( t\right ) \alpha _{n}^{2}\phi _{n}\left ( x\right ) \end {align*}
Therefore the ODE is\[ B_{n}^{\prime }\left ( t\right ) +\alpha _{n}^{2}B_{n}\left ( t\right ) =0 \] The solution is \[ B_{n}\left ( t\right ) =B_{n}\left ( 0\right ) e^{-\alpha _{n}^{2}t}\] Hence (2) becomes\[ v\left ( x,t\right ) =\sum _{n=1}^{\infty }B_{n}\left ( 0\right ) e^{-\alpha _{n}^{2}t}\phi _{n}\left ( x\right ) \] And since \(u\left ( x,t\right ) =v\left ( x,t\right ) +r\left ( x\right ) \) then\[ u\left ( x,t\right ) =\sum _{n=1}^{\infty }B_{n}\left ( 0\right ) e^{-\alpha _{n}^{2}t}\phi _{n}\left ( x\right ) +\frac {hx+1}{1+h}\] Now we find \(B_{n}\left ( 0\right ) \) from initial conditions. At \(t=0\) the above becomes\begin {align*} 0 & =\sum _{n=1}^{\infty }B_{n}\left ( 0\right ) \phi _{n}\left ( x\right ) +\frac {hx+1}{1+h}\\ -\frac {hx+1}{1+h} & =\sum _{n=1}^{\infty }B_{n}\left ( 0\right ) \phi _{n}\left ( x\right ) \end {align*}
Hence \begin {align} B_{n}\left ( 0\right ) & =\left \langle -\frac {hx+1}{1+h},\phi _{n}\left ( x\right ) \right \rangle \nonumber \\ & =-\int _{0}^{1}p\left ( x\right ) \frac {hx+1}{1+h}\phi _{n}\left ( x\right ) dx\nonumber \\ & =-\int _{0}^{1}\frac {hx+1}{1+h}\sqrt {\frac {2h}{h+\cos ^{2}\alpha _{n}}}\sin \left ( \alpha _{n}\left ( 1-x\right ) \right ) dx\nonumber \\ & =-\frac {1}{1+h}\sqrt {\frac {2h}{h+\cos ^{2}\alpha _{n}}}\int _{0}^{1}\left ( hx+1\right ) \sin \left ( \alpha _{n}\left ( 1-x\right ) \right ) dx\tag {3} \end {align}
But\begin {align*} \int _{0}^{1}\left ( hx+1\right ) \sin \left ( \alpha _{n}\left ( 1-x\right ) \right ) dx & =\int _{0}^{1}\sin \left ( \alpha _{n}\left ( 1-x\right ) \right ) dx+h\int _{0}^{1}x\sin \left ( \alpha _{n}\left ( 1-x\right ) \right ) dx\\ & =\left [ \frac {\cos \left ( \alpha _{n}\left ( 1-x\right ) \right ) }{\alpha _{n}}\right ] _{0}^{1}+h\left [ \frac {\alpha _{n}x\cos \left ( \alpha _{n}\left ( 1-x\right ) \right ) +\sin \left ( \alpha _{n}\left ( 1-x\right ) \right ) }{\alpha _{n}^{2}}\right ] _{0}^{1}\\ & =\frac {1-\cos \left ( \alpha _{n}\right ) }{\alpha _{n}}+\frac {h}{\alpha _{n}^{2}}\left [ \alpha _{n}x\cos \left ( \alpha _{n}\left ( 1-x\right ) \right ) +\sin \left ( \alpha _{n}\left ( 1-x\right ) \right ) \right ] _{0}^{1}\\ & =\frac {1-\cos \left ( \alpha _{n}\right ) }{\alpha _{n}}+\frac {h}{\alpha _{n}^{2}}\left [ \alpha _{n}-\sin \alpha _{n}\right ] \\ & =\frac {\alpha _{n}-\alpha _{n}\cos \left ( \alpha _{n}\right ) +h\alpha _{n}-h\sin \alpha _{n}}{\alpha _{n}^{2}} \end {align*}
But \(\frac {\sin \left ( \alpha _{n}\right ) }{\cos \left ( \alpha _{n}\right ) }=-\frac {\alpha _{n}}{h}\) or \(h\sin \left ( \alpha _{n}\right ) =-\alpha _{n}\cos \left ( \alpha _{n}\right ) \) or \(-h\sin \alpha _{n}=\alpha _{n}\cos \left ( \alpha _{n}\right ) \), hence the above simplifies to \begin {align*} \int _{0}^{1}\left ( hx+1\right ) \sin \left ( \alpha _{n}\left ( 1-x\right ) \right ) dx & =\frac {\alpha _{n}+h\alpha _{n}}{\alpha _{n}^{2}}\\ & =\frac {1+h}{\alpha _{n}} \end {align*}
Therefore (3) becomes\begin {align*} B_{n}\left ( 0\right ) & =\frac {-1}{1+h}\sqrt {\frac {2h}{h+\cos ^{2}\alpha _{n}}}\left ( \frac {1+h}{\alpha _{n}}\right ) \\ & =-\frac {1}{\alpha _{n}}\sqrt {\frac {2h}{h+\cos ^{2}\alpha _{n}}} \end {align*}
Hence final solution becomes\begin {align*} u\left ( x,t\right ) & =\frac {hx+1}{1+h}+\sum _{n=1}^{\infty }B_{n}\left ( 0\right ) e^{-\alpha _{n}^{2}t}\phi _{n}\left ( x\right ) \\ & =\frac {hx+1}{1+h}+\sum _{n=1}^{\infty }B_{n}\left ( 0\right ) \exp \left ( -\alpha _{n}^{2}t\right ) \sqrt {\frac {2h}{h+\cos ^{2}\alpha _{n}}}\sin \left ( \alpha _{n}\left ( 1-x\right ) \right ) \\ & =\frac {hx+1}{1+h}+\sum _{n=1}^{\infty }-\frac {1}{\alpha _{n}}\sqrt {\frac {2h}{h+\cos ^{2}\alpha _{n}}}\exp \left ( -\alpha _{n}^{2}t\right ) \sqrt {\frac {2h}{h+\cos ^{2}\alpha _{n}}}\sin \left ( \alpha _{n}\left ( 1-x\right ) \right ) \\ & =\frac {hx+1}{1+h}-2h\sum _{n=1}^{\infty }\frac {\sin \left ( \alpha _{n}\left ( 1-x\right ) \right ) }{\alpha _{n}\left ( h+\cos ^{2}\alpha _{n}\right ) }\exp \left ( -\alpha _{n}^{2}t\right ) \end {align*}
____________________________________________________________________________________
Solve the heat equation
\[ u_t = k u_{xx} \]
For \(-L<x<L\) and \(t>0\). The boundary conditions are periodic \begin {align*} u(-L,t) &= u(L,t) \\ \frac { \partial u}{\partial x}(-L,t) &= \frac { \partial u}{\partial x}(L,t) \end {align*}
And initial conditions \(u(x,0)=f(x)\)
Mathematica ✗
ClearAll[u, t, x, L, c, f, k]; pde = D[u[x, t], t] == k*D[u[x, t], {x, 2}]; bc = {u[-L, t] == u[L, t], Derivative[1, 0][u][-L, t] == Derivative[1, 0][u][L, t]}; ic = u[x, 0] == f[x]; sol = AbsoluteTiming[TimeConstrained[DSolve[{pde, bc, ic}, u[x, t], {x, t}, Assumptions -> L > 0], 60*10]];
\[ \text {Failed} \]
Maple ✓
L:='L'; u:='u'; t:='t'; x:='x';f:='f'; interface(showassumed=0); pde:=diff(u(x,t),t)=k*diff(u(x,t),x$2); bc:=u(-L,t)=u(L,t),eval(diff(u(r,t),r),r=-L)=eval(diff(u(r,t),r),r=L); 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),output='realtime'));
\[ u \left ( x,t \right ) =1/2\,{\frac {1}{L} \left ( 2\,\sum _{n=1}^{\infty } \left ( {\frac {1}{L}{{\rm e}^{-{\frac {k{\pi }^{2}{n}^{2}t}{{L}^{2}}}}} \left ( \sin \left ( {\frac {n\pi \,x}{L}} \right ) \int _{-L}^{L}\!f \left ( x \right ) \sin \left ( {\frac {n\pi \,x}{L}} \right ) \,{\rm d}x+\cos \left ( {\frac {n\pi \,x}{L}} \right ) \int _{-L}^{L}\!f \left ( x \right ) \cos \left ( {\frac {n\pi \,x}{L}} \right ) \,{\rm d}x \right ) } \right ) L+\int _{-L}^{L}\!f \left ( x \right ) \,{\rm d}x \right ) } \]
____________________________________________________________________________________
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 ✗
NumericQ[L] =. ; ClearAll[u, t, x, k, L, f]; 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]; NumericQ[L] = True; sol = AbsoluteTiming[TimeConstrained[DSolve[{pde, bc, ic}, u[x, t], {x, t}, Assumptions -> {t >= 0, k > 0, x >= 0, x <= L}], 60*10]]; NumericQ[L] =. ;
\[ \text {Failed} \]
Maple ✓
L:='L'; u:='u'; t:='t'; x:='x';mu:='mu';lambda:='lambda';f:='f'; 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 t>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 {k{\pi }^{2}{n}^{2}t}{{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 ) \]
____________________________________________________________________________________
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[u, t, x, f]; 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]];
\[ \text {Failed} \]
Maple ✓
L:='L'; u:='u'; t:='t'; x:='x';f:='f'; 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 ( n\pi \,x \right ) {{\rm e}^{-{\pi }^{2}{n}^{2}t}}\int _{-1}^{1}\!f \left ( x \right ) \sin \left ( n\pi \,x \right ) \,{\rm d}x+\cos \left ( 1/2\, \left ( 2\,n-1 \right ) \pi \,x \right ) {{\rm e}^{-1/4\,{\pi }^{2} \left ( 2\,n-1 \right ) ^{2}t}}\int _{-1}^{1}\!f \left ( x \right ) \cos \left ( 1/2\, \left ( 2\,n-1 \right ) \pi \,x \right ) \,{\rm d}x \right ) \]
____________________________________________________________________________________
Taken from Maple PDE help pages
Solve the heat equation
\[ \frac { \partial u}{\partial t} = \frac { \partial ^2 u}{\partial x^2} \]
For \(0<x<1\) and \(t>0\). The boundary conditions are \begin {align*} u(0,t) &= 20 \\ u(1,t) &= 50 \end {align*}
Initial condition is \(u(x,0)=0\)
Mathematica ✓
ClearAll[u, x, t, n]; pde = D[u[x, t], t] == D[u[x, t], {x, 2}]; bc = {u[0, t] == 20, u[1, t] == 50}; ic = u[x, 0] == 0; 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 -\frac {2 \sum _{n=1}^{\infty }\frac {\left (20-50 (-1)^n\right ) e^{-n^2 \pi ^2 t} \sin (n \pi x)}{n}}{\pi }+30 x+20\right \}\right \} \]
Maple ✓
u:='u'; t:='t'; x:='x'; pde := diff(u(x,t),t)+k*diff(u(x,t),x$2); ic := u(x,0)=0; bc := u(0,t)=20, u(1,t)=50; cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol',pdsolve([pde,ic,bc],u(x,t))),output='realtime'));
\[ u \left ( x,t \right ) =20+30\,x+\sum _{n=1}^{\infty }{\frac { \left ( 100\, \left ( -1 \right ) ^{n}-40 \right ) \sin \left ( n\pi \,x \right ) {{\rm e}^{k{\pi }^{2}{n}^{2}t}}}{n\pi }} \]
____________________________________________________________________________________
Added Nov 27, 2018
This is problem 8.2.1 part(a) 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} \]
For \(0<x<L\) and \(t>0\). The boundary conditions are \begin {align*} u(0,t) &= A \\ \frac { \partial u}{\partial x}(L,t) &= B \end {align*}
Initial condition is \(u(x,0)=f(x)\)
Mathematica ✗
ClearAll[u, x, t, k, f, A, B, L, Q]; pde = D[u[x, t], t] == k*D[u[x, t], {x, 2}]; bc = {u[0, t] == A, Derivative[1, 0][u][L, t] == B}; ic = u[x, 0] == f[x]; sol = AbsoluteTiming[TimeConstrained[DSolve[{pde, ic, bc}, u[x, t], x, t, Assumptions -> L > 0], 60*10]];
\[ \text {Failed} \]
Maple ✓
L:='L'; u:='u'; t:='t'; x:='x';f:='f';A:='A';B:='B';k:='k';Q:='Q'; interface(showassumed=0); pde := diff(u(x,t),t)=k*diff(u(x,t),x$2); ic := u(x,0)=f(x); bc := u(0,t)=A, eval( diff(u(x,t),x),x=L)=B; 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=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}\! \left ( Bx+A-f \left ( x \right ) \right ) \sin \left ( 1/2\,{\frac { \left ( 1+2\,n \right ) \pi \,x}{L}} \right ) \,{\rm d}x} \right ) +Bx+A \]
Hand solution
Let \begin {equation} u\left ( x,t\right ) =v\left ( x,t\right ) +u_{E}\left ( x\right ) \tag {1} \end {equation} We can look for \(u_{E}\left ( x\right ) \) which is the steady state solution that satisfies the non-homogenous boundary conditions. In (1) \(v\left ( x,t\right ) \) satisfies the PDE itself but with homogenous boundary conditions. The first step is to find \(u_{E}\left ( x\right ) \). We use the equilibrium solution in this case. At equilibrium \(\frac {\partial u_{E}\left ( x,t\right ) }{\partial t}=0\) and hence the solution is given \(\frac {d^{2}u_{E}}{\partial x^{2}}=0\) or \[ u_{E}\left ( x\right ) =c_{1}x+c_{2}\] At \(x=0,u_{E}\left ( x\right ) =A\), Hence \[ c_{2}=A \] And solution becomes \(u_{E}\left ( x\right ) =c_{1}x+A\). at \(x=L,\frac {\partial u_{E}\left ( x\right ) }{\partial x}=c_{1}=B\), Therefore\[ u_{E}\left ( x\right ) =Bx+A \] Now we plug-in (1) into the original PDE, this gives\[ \frac {\partial v\left ( x,t\right ) }{\partial t}=k\left ( \frac {\partial ^{2}v\left ( x,t\right ) }{\partial x}+\frac {\partial ^{2}u_{E}\left ( x\right ) }{\partial x}\right ) \] But \(\frac {\partial ^{2}u_{E}\left ( x\right ) }{\partial x}=0\), hence we need to solve \[ \frac {\partial v\left ( x,t\right ) }{\partial t}=k\frac {\partial ^{2}v\left ( x,t\right ) }{\partial x}\] for \(v\left ( x,t\right ) =u\left ( x,t\right ) -u_{E}\left ( x\right ) \) with homogenous boundary conditions \(v\left ( 0,t\right ) =0,\frac {\partial v\left ( L,t\right ) }{\partial t}=0\) and initial conditions \begin {align*} v\left ( x,0\right ) & =u\left ( x,0\right ) -u_{E}\left ( x\right ) \\ & =f\left ( x\right ) -\left ( Bx+A\right ) \end {align*}
This PDE we already solved before and we know that it has the following solution\begin {align} v\left ( x,t\right ) & =\sum _{n=1,3,5,\cdots }^{\infty }b_{n}\sin \left ( \sqrt {\lambda _{n}}x\right ) e^{-k\lambda _{n}t}\nonumber \\ \lambda _{n} & =\left ( \frac {n\pi }{2L}\right ) ^{2}\qquad n=1,3,5,\cdots \tag {2} \end {align}
With \(b_{n}\) found from orthogonality using initial conditions \(v\left ( x,0\right ) =f\left ( x\right ) -\left ( Bx+A\right ) \)\begin {align*} v\left ( x,0\right ) & =\sum _{n=1,3,5,\cdots }^{\infty }b_{n}\sin \left ( \sqrt {\lambda _{n}}x\right ) \\ \int _{0}^{L}\left ( f\left ( x\right ) -\left ( Bx+A\right ) \right ) \sin \left ( \sqrt {\lambda _{m}}x\right ) dx & =\int _{0}^{L}\sum _{n=1,3,5,\cdots }^{\infty }b_{n}\sin \left ( \sqrt {\lambda _{n}}x\right ) \sin \left ( \sqrt {\lambda _{m}}x\right ) dx\\ \int _{0}^{L}\left ( f\left ( x\right ) -\left ( Bx+A\right ) \right ) \sin \left ( \sqrt {\lambda _{m}}x\right ) dx & =b_{m}\frac {L}{2} \end {align*}
Hence\begin {equation} b_{n}=\frac {2}{L}\int _{0}^{L}\left ( f\left ( x\right ) -\left ( Bx+A\right ) \right ) \sin \left ( \sqrt {\lambda _{n}}x\right ) dx\qquad n=1,3,5,\cdots \tag {3} \end {equation} Therefore, from (1) the solution is\begin {align*} u\left ( x,t\right ) & =\sum _{n=1,3,5,\cdots }^{\infty }b_{n}\sin \left ( \sqrt {\lambda _{n}}x\right ) e^{-k\lambda _{n}t}+\overset {u_{E}\left ( x\right ) }{\overbrace {Bx+A}}\\ & =Bx+A+\sum _{n=1,3,5,\cdots }^{\infty }\left ( \frac {2}{L}\int _{0}^{L}\left ( f\left ( x\right ) -\left ( Bx+A\right ) \right ) \sin \left ( \sqrt {\frac {n\pi }{L}}x\right ) dx\right ) \sin \left ( \sqrt {\frac {n\pi }{L}}x\right ) e^{-k\left ( \frac {n\pi }{L}\right ) ^{2}t} \end {align*}
Or
\[ u\left ( x,t\right ) =Bx+A+\sum _{n=0}^{\infty }\left ( \frac {2}{L}\int _{0}^{L}\left ( f\left ( x\right ) -\left ( Bx+A\right ) \right ) \sin \left ( \sqrt {\frac {\left ( 2n+1\right ) \pi }{2L}}x\right ) dx\right ) \sin \left ( \sqrt {\frac {\left ( 2n+1\right ) \pi }{2L}}x\right ) e^{-k\left ( \frac {\left ( 2n+1\right ) \pi }{2L}\right ) ^{2}t}\]
____________________________________________________________________________________
This is problem 8.2.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} + k \]
For \(0<x<1\) and \(t>0\). The boundary conditions are \begin {align*} u(0,t) &= A \\ u(L,t) &= B \end {align*}
Initial condition is \(u(x,0)=f(x)\)
Mathematica ✗
ClearAll[u, x, t, k, f, A0, B0, L0]; pde = D[u[x, t], t] == k*D[u[x, t], {x, 2}] + k; bc = {u[0, t] == A0, u[L0, t] == B0}; ic = u[x, 0] == f[x]; sol = AbsoluteTiming[TimeConstrained[DSolve[{pde, ic, bc}, u[x, t], x, t], 60*10]];
\[ \text {Failed} \]
Maple ✓
L:='L'; u:='u'; t:='t'; x:='x';f:='f';A:='A';B:='B'; interface(showassumed=0); pde := diff(u(x,t),t)=k*diff(u(x,t),x$2)+k; ic := u(x,0)=f(x); bc := u(0,t)=A, u(L,t)=B; cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol',pdsolve([pde,ic,bc],u(x,t))),output='realtime'));
\[ u \left ( x,t \right ) =1/2\,{\frac {1}{L} \left ( 2\,\sum _{n=1}^{\infty } \left ( -{\frac {1}{{L}^{2}}\sin \left ( {\frac {n\pi \,x}{L}} \right ) {{\rm e}^{-{\frac {k{\pi }^{2}{n}^{2}t}{{L}^{2}}}}}\int _{0}^{L}\!2\,\sin \left ( {\frac {n\pi \,x}{L}} \right ) \left ( -f \left ( x \right ) L+1/2\,{L}^{2}x+ \left ( -1/2\,{x}^{2}+A \right ) L-x \left ( A-B \right ) \right ) \,{\rm d}x} \right ) L+{L}^{2}x+ \left ( -{x}^{2}+2\,A \right ) L-2\,x \left ( A-B \right ) \right ) } \]
Hand solution
Let \begin {equation} u\left ( x,t\right ) =v\left ( x,t\right ) +u_{E}\left ( x\right ) \tag {1} \end {equation} Where \(u_{E}\left ( x\right ) \) is the equilibrium solution which needs to satisfy only the nonhomogeneous B.C. And \(v\left ( x,t\right ) \) is transient solution to heat PDE with homogeneous B.C.
At equilibrium, \(u_{t}=ku_{xx}+Q\left ( x\right ) \) becomes\begin {align*} 0 & =ku_{E}^{\prime \prime }+Q\left ( x\right ) \\ & =ku_{E}^{\prime \prime }+k\\ & =k\left ( u_{E}^{\prime \prime }+1\right ) \end {align*}
Hence\[ u_{E}^{\prime \prime }=-1 \] The solution to this ODE is \[ u_{E}=c_{1}x+c_{2}-\frac {1}{2}x^{2}\] At \(x=0\), the above gives\[ A=c_{2}\] And at \(x=L\)\begin {align*} B & =c_{1}L+A-\frac {1}{2}L^{2}\\ c_{1} & =\frac {B-A+\frac {1}{2}L^{2}}{L}\\ & =\frac {B}{L}-\frac {A}{L}+\frac {1}{2}L \end {align*}
Hence \[ u_{E}=\left ( \frac {B}{L}-\frac {A}{L}+\frac {1}{2}L\right ) x+A-\frac {1}{2}x^{2}\] Hence from (1)\begin {align} u\left ( x,t\right ) & =v\left ( x,t\right ) +u_{E}\tag {1A}\\ & =v\left ( x,t\right ) +\left ( \frac {B}{L}-\frac {A}{L}+\frac {1}{2}L\right ) x+A-\frac {1}{2}x^{2}\nonumber \end {align}
Substituting this in \(u_{t}=ku_{xx}+k\) gives\begin {align} v_{t} & =k\left ( v_{xx}-1\right ) +k\nonumber \\ & =kv_{xx}\tag {2} \end {align}
We need to solve the above for \(v\left ( x,t\right ) \), but with homogeneous B.C. \(v\left ( 0,t\right ) =0,v\left ( L,t\right ) =0\). The eigenvalues for the homogeneous PDE \(v_{t}=kv_{xx}\) with these boundary conditions is known to be \(\lambda _{n}=\left ( \frac {n\pi }{L}\right ) ^{2}\,\), for \(n=1,2,\cdots \) and the corresponding eigenfunctions are \(X_{n}\left ( x\right ) =\sin \left ( \sqrt {\lambda _{n}}x\right ) \). Now, using eigenfunction expansion, let\begin {equation} v\left ( x,t\right ) =\sum _{n=1}^{\infty }b_{n}\left ( t\right ) X_{n}\left ( x\right ) \tag {3} \end {equation} Substituting (3) into (2) gives\[ \sum _{n=1}^{\infty }b_{n}^{\prime }\left ( t\right ) X_{n}\left ( x\right ) =k\sum _{n=1}^{\infty }b_{n}\left ( t\right ) X_{n}^{\prime \prime }\left ( x\right ) \] But \(X_{n}^{\prime \prime }\left ( x\right ) =-\lambda _{n}X_{n}\left ( x\right ) \), therefore the above becomes\[ \sum _{n=1}^{\infty }b_{n}^{\prime }\left ( t\right ) X_{n}\left ( x\right ) +k\sum _{n=1}^{\infty }\lambda _{n}b_{n}\left ( t\right ) X_{n}\left ( x\right ) =0 \] Since the above is true for each \(n\) and since eigenfunctions can not be zero, the above simplifies to\begin {equation} b_{n}^{\prime }\left ( t\right ) +k\lambda _{n}b_{n}\left ( t\right ) =0\tag {4} \end {equation} This is linear in \(b\left ( t\right ) \). The solution using integrating factor is\[ b_{n}\left ( t\right ) =b_{0}\left ( 0\right ) e^{-k\left ( \frac {n\pi }{L}\right ) ^{2}t}\] Therefore (3) becomes\begin {align*} v\left ( x,t\right ) & =\sum _{n=1}^{\infty }b_{n}\left ( t\right ) X_{n}\left ( x\right ) \\ & =\sum _{n=1}^{\infty }b_{0}\left ( 0\right ) e^{-k\left ( \frac {n\pi }{L}\right ) ^{2}t}\sin \left ( \frac {n\pi }{L}x\right ) \end {align*}
And from (1)\begin {align} u\left ( x,t\right ) & =v\left ( x,t\right ) +u_{E}\left ( x\right ) \nonumber \\ & =\overset {u_{E}}{\overbrace {\left ( \frac {B}{L}-\frac {A}{L}+\frac {1}{2}L\right ) x+A-\frac {1}{2}x^{2}}}+\sum _{n=1}^{\infty }b_{0}\left ( 0\right ) e^{-k\left ( \frac {n\pi }{L}\right ) ^{2}t}\sin \left ( \frac {n\pi }{L}x\right ) \tag {5} \end {align}
At \(t=0\) the above becomes\[ f\left ( x\right ) =\frac {Bx}{L}-\frac {Ax}{L}+\frac {1}{2}Lx+A-\frac {1}{2}x^{2}+\sum _{n=1}^{\infty }b_{0}\left ( 0\right ) \sin \left ( \frac {n\pi }{L}x\right ) \] For \(n>0\), and applying orthogonality\[ \int _{0}^{L}f\left ( x\right ) \sin \left ( \frac {n\pi }{L}x\right ) dx=\int _{0}^{L}\left ( \frac {Bx}{L}-\frac {Ax}{L}+\frac {1}{2}Lx+A-\frac {1}{2}x^{2}\right ) \sin \left ( \frac {n\pi }{L}x\right ) dx+\int _{0}^{L}b_{0}\left ( 0\right ) \sin ^{2}\left ( \frac {n\pi }{L}x\right ) dx \] Hence\[ \int _{0}^{L}\left ( f\left ( x\right ) -\left ( \frac {Bx}{L}-\frac {Ax}{L}+\frac {1}{2}Lx+A-\frac {1}{2}x^{2}\right ) \right ) \sin \left ( \frac {n\pi }{L}x\right ) dx=\frac {L}{2}b_{0}\left ( 0\right ) \] Therefore\[ b_{0}\left ( 0\right ) =\frac {2}{L}\int _{0}^{L}\left ( f\left ( x\right ) -\left ( \frac {Bx}{L}-\frac {Ax}{L}+\frac {1}{2}Lx+A-\frac {1}{2}x^{2}\right ) \right ) \sin \left ( \frac {n\pi }{L}x\right ) dx \] Substituting the above in (5) gives\begin {align*} u\left ( x,t\right ) & =\left ( \frac {Bx}{L}-\frac {Ax}{L}+\frac {1}{2}Lx+A-\frac {1}{2}x^{2}\right ) \\ & +\sum _{n=1}^{\infty }\left ( \frac {2}{L}\int _{0}^{L}\left ( f\left ( x\right ) -\left ( \frac {Bx}{L}-\frac {Ax}{L}+\frac {1}{2}Lx+A-\frac {1}{2}x^{2}\right ) \right ) \sin \left ( \frac {n\pi }{L}x\right ) dx\right ) e^{-k\frac {n\pi }{L}t}\sin \left ( \frac {n\pi }{L}x\right ) \end {align*}
____________________________________________________________________________________
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[x, t, u, f, L]; 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]];
\[ \text {Failed} \]
Maple ✓
L:='L'; u:='u'; t:='t'; x:='x';f:='f'; 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 {n\pi \,x}{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 {n\pi \,x}{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*}
____________________________________________________________________________________
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[x, t, u, f, L]; f = Sin[2*Pi*x] - Sin[5*Pi*x]; 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] == f; sol = AbsoluteTiming[TimeConstrained[DSolve[{pde, ic, bc}, u[x, t], x, t][[1,1]], 60*10]];
\[ u(x,t)\to e^{-400 \pi ^2 t} \sin (2 \pi x)-e^{-2500 \pi ^2 t} \sin (5 \pi x) \]
Maple ✓
L:='L'; u:='u'; t:='t'; x:='x'; interface(showassumed=0); 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}} \]
____________________________________________________________________________________
Added Feb 10, 2018.
Solve the heat equation
\[ \frac { \partial u}{\partial t} = \frac { \partial ^2 u}{\partial x^2} \]
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[x, t, u, f, L, n]; 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 ✓
L:='L'; u:='u'; t:='t'; x:='x'; 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\,n\pi \right ) }{{\pi }^{2}{n}^{2}}{{\rm e}^{-{\frac {{\pi }^{2}{n}^{2}t}{1600}}}}} \]
____________________________________________________________________________________
Added July 2, 2018, taken from Maple 2018.1 improvement to PDE document.
Solve the heat equation
\[ u_t = 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\left (x,0\right ) =\left \{ \begin {array} [c]{ccc}1 & x=1\\ 0 & \text {otherwise} \end {array} \right . \)
Mathematica ✓
ClearAll[u, x, t]; pde = D[u[x, t], t] == D[u[x, t], {x, 2}]; bc = {u[0, t] == 0, u[1, t] == 0}; ic = u[x, 0] == Piecewise[{{0, x == 0}, {1, True}}]; 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 {2 \left (-1+(-1)^n\right ) e^{-n^2 \pi ^2 t} \sin (n \pi x)}{n \pi }\right \}\right \} \]
Maple ✓
pde := diff(u(x,t), t) = diff(u(x,t), x, x); bc := u(0,t) = 0, u(1,t) = 1; ic := u(x,0) = piecewise(x = 0, 0, 1); cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol', pdsolve([pde, ic, bc])),output='realtime'));
\[ u \left ( x,t \right ) =x+\sum _{n=1}^{\infty }2\,{\frac {\sin \left ( n\pi \,x \right ) {{\rm e}^{-{\pi }^{2}{n}^{2}t}}}{n\pi }} \]
____________________________________________________________________________________
added March 8, 2018. Exam problem
Solve the heat equation
\[ \frac { \partial u}{\partial t}= \frac { \partial ^2 u}{\partial x^2} \]
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[u, t, x, n]; 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 \sum _{n=1}^{\infty }-\frac {\left (2-2 e^{-n^2 t}\right ) \sin (n x)}{n^3 \pi }-\frac {t x}{\pi }+t\right \}\right \} \]
Maple ✓
u:='u'; t:='t'; x:='x'; 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 ) =1/6\,{\frac {1}{\pi } \left ( 6\,\sum _{n=1}^{\infty }2\,{\frac {\sin \left ( nx \right ) {{\rm e}^{-{n}^{2}t}}}{\pi \,{n}^{3}}}\pi -6\, \left ( 1/6\,{x}^{2}-1/3\,\pi \,x+t \right ) \left ( -\pi +x \right ) \right ) } \]
____________________________________________________________________________________
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[u, x, t, k, f, L]; 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]];
\[ \text {Failed} \]
Maple ✓
L:='L'; u:='u'; t:='t'; x:='x';f:='f'; k:='k'; 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}\int _{0}^{L}\!{L}^{2}\cos \left ( {\frac {n\pi \,x}{L}} \right ) \sin \left ( 2\,{\frac {\pi \,x}{L}} \right ) -2\,\pi \, \left ( -2\,\pi \,k{\it \_C2}+2\,\pi \,kf \left ( x \right ) +Lx \right ) \cos \left ( {\frac {n\pi \,x}{L}} \right ) \,{\rm d}x\cos \left ( {\frac {n\pi \,x}{L}} \right ) {{\rm e}^{{\frac {k{\pi }^{2}{n}^{2}t}{{L}^{2}}}}}} \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\,f \left ( x \right ) {\pi }^{2}k+4\,{\it \_C2}\,{\pi }^{2}k+{L}^{2}\sin \left ( 2\,{\frac {\pi \,x}{L}} \right ) -2\,Lx\pi \,{\rm d}x \right ) } \]
____________________________________________________________________________________
Added July 2, 2018. Taken from Maple 2018.1 document, originally exercise 6.25 from Pinchover and Rubinstein.
Solve the heat equation
\[ \frac { \partial u}{\partial t}= k \frac { \partial ^2 u}{\partial x^2} + \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[u, x, t, k, L]; 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]];
\[ \text {Failed} \]
Maple ✓
L:='L'; u:='u'; t:='t'; x:='x';k:='k'; 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 {k{\pi }^{2}{n}^{2}t}{{L}^{2}}}}}}w+2\,\sin \left ( wt \right ) \right ) } \]
____________________________________________________________________________________
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[u, x, t, k, f, L, c]; 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]];
\[ \text {Failed} \]
Maple ✓
L:='L'; u:='u'; t:='t'; x:='x';f:='f';c:='c'; 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-{\pi }^{2}k \right ) } \left ( L\sum _{n=3}^{\infty }-12\,{\frac {{L}^{2} \left ( \left ( -1 \right ) ^{n}-1 \right ) \left ( {L}^{2}c-{\pi }^{2}k \right ) }{ \left ( -{\pi }^{2}k{n}^{2}+{L}^{2}c \right ) \left ( {n}^{2}-4 \right ) }\cos \left ( {\frac {n\pi \,x}{L}} \right ) \left ( {{\rm e}^{-tc}}-{{\rm e}^{-{\frac {{\pi }^{2}k{n}^{2}t}{{L}^{2}}}}} \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}k{n}^{2}t}{{L}^{2}}}}}\int _{0}^{L}\!f \left ( x \right ) \cos \left ( {\frac {n\pi \,x}{L}} \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}{{\rm e}^{-tc}}\cos \left ( {\frac {\pi \,x}{L}} \right ) +3\,\int _{0}^{L}\!f \left ( x \right ) \,{\rm d}x\pi \, \left ( {L}^{2}c-{\pi }^{2}k \right ) \right ) } \]
____________________________________________________________________________________
Added April 3, 2018.
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[u, x, t, k, f, L, c]; 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 ✓
unassign('u,t,x'); 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}}} \]
____________________________________________________________________________________
Added July 2, 2018.
Pinchover and Rubinstein’s exercise 6.17. Taken from Maple document for new improvements in Maple 2018.1
Solve the heat equation
\[ {\frac {\partial }{\partial t}}u \left ( x,t \right ) -{\frac {\partial ^{2}}{\partial {x}^{2}}}u \left ( x,t \right ) =1+x\cos \left ( t\right ) \]
For \(0<x<1\) and \(t>0\). The boundary conditions are \begin {align*} \frac {\partial u}{\partial x}(0,t) &=\sin (t) \\ \frac {\partial u}{\partial x}(1,t) &=\sin (t) \end {align*}
Initial condition is \(u (x,0) =1+ \cos ( 2 \pi x)\).
Mathematica ✗
pde = D[u[x, t], x] == D[u[x, t], {x, 2}] + 1 + x*Cos[t]; bc = {Derivative[1, 0][u][0, t] == Sin[t], Derivative[1, 0][u][1, t] == Sin[t]}; ic = u[x, 0] == 1 + Cos[2*Pi*x]; sol = AbsoluteTiming[TimeConstrained[Simplify[DSolve[{pde, ic, bc}, u[x, t], x, t]], 60*10]];
\[ \text {Failed} \]
Maple ✓
x:='x';t:='t'; pde := diff(u(x, t), t)= (diff(u(x, t), x, x)) + 1+x*cos(t); bc := (D[1](u))(0, t) = sin(t), (D[1](u))(1, t) = sin(t); ic := u(x, 0) = 1+cos(2*Pi*x); cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol', pdsolve([pde, ic, bc],u(x,t))),output='realtime'));
\[ u \left ( x,t \right ) =1+\cos \left ( 2\,\pi \,x \right ) {{\rm e}^{-4\,{\pi }^{2}t}}+t+x\sin \left ( t \right ) \]
____________________________________________________________________________________
Added July 2, 2018.
Second example from Maple document for new improvements in Maple 2018.1
Solve the heat equation
\[ 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 ✗
pde = D[u[x, t], x] == 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]];
\[ \text {Failed} \]
Maple ✓
x:='x';t:='t'; pde := diff(u(x, t), t) = 13*(diff(u(x, t), x, x)); bc := D[1](u)(0,t)=0,D[1](u)(1,t)=1; ic := u(x, 0) = 1/2*x^2+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 ) =1/2+\sum _{n=1}^{\infty }2\,{\frac {\cos \left ( n\pi \,x \right ) {{\rm e}^{-13\,{\pi }^{2}{n}^{2}t}} \left ( -1+ \left ( -1 \right ) ^{n} \right ) }{{\pi }^{2}{n}^{2}}}+13\,t+1/2\,{x}^{2} \]
____________________________________________________________________________________
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[u, t, x, f, g]; 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 {e^{3 t} \cos (17 \pi x)}{3+289 \pi ^2}-\frac {e^{-289 \pi ^2 t} \cos (17 \pi x)}{3+289 \pi ^2}+3 e^{-1764 \pi ^2 t} \cos (42 \pi x)\right \}\right \} \]
Maple ✓
f:='f';g:='g';x:='x';y:='y';t:='t'; 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}^{3\,t}}-{{\rm e}^{-289\,{\pi }^{2}t}} \right ) }{289\,{\pi }^{2}+3}} \]
____________________________________________________________________________________
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[u, t, x]; 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 {e^{-4004001 t} \cos (2001 x)}{16032024008001}+\frac {t \cos (2001 x)}{4004001}-\frac {\cos (2001 x)}{16032024008001}\right \}\right \} \]
Maple ✓
x:='x';t:='t'; 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 \]
____________________________________________________________________________________
Added March 28, 2018. A problem from my PDE animation page.
Solve the heat equation
\[ u_t = k u_{xx} + x \]
For \(0<x<\pi \) and \(t>0\). The boundary conditions are \begin {align*} u(0,t) &= \frac {t \sin t}{5} \\ u(\pi ,t) &= \frac {t \cos t}{10} \\ \end {align*}
Initial condition is \(u(x,0)=60 - 20 x\).
Mathematica ✗
ClearAll[u, x, t, x]; pde = D[u[x, t], t] == D[u[x, t], {x, 2}] + x; bc = {u[0, t] == (t*Sin[t])/5, u[Pi, t] == (t*Cos[t])/10}; ic = u[x, 0] == 60 - 2*x; sol = AbsoluteTiming[TimeConstrained[DSolve[{pde, ic, bc}, u[x, t], x, t, Assumptions -> {t > 0, x > 0}], 60*10]];
\[ \text {Failed} \]
Maple ✓
L:='L'; u:='u'; t:='t'; x:='x';f:='f';c:='c'; interface(showassumed=0); pde := diff(u(x,t),t)=diff(u(x,t),x$2)+x; ic := u(x,0)=(60-2*x); bc := u(0,t)=t/5*sin(t), u(Pi,t)=t/10*cos(t); cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol', pdsolve([pde,ic,bc],u(x,t)) assuming t>0,x>0),output='realtime'));
\[ u \left ( x,t \right ) =1/10\,{\frac {1}{\pi } \left ( \cos \left ( t \right ) tx+2\, \left ( \pi -x \right ) t\sin \left ( t \right ) +10\,\sum _{n=1}^{\infty }1/10\,{\frac {1}{\pi \,{n}^{3} \left ( {n}^{4}+1 \right ) ^{2}} \left ( 40\, \left ( \left ( 30\,{n}^{10}+1/20\,{n}^{8}+60\,{n}^{6}+30\,{n}^{2} \right ) \left ( -1 \right ) ^{1+n}+ \left ( \pi \,{n}^{10}+1/2\,\pi \,{n}^{8}+2\,\pi \,{n}^{6}+ \left ( \pi +1/20 \right ) {n}^{4}+\pi \,{n}^{2}+\pi /2 \right ) \left ( -1 \right ) ^{n}+30\,{n}^{10}+{\frac {299\,{n}^{6}}{5}}+30\,{n}^{2} \right ) \sin \left ( nx \right ) {{\rm e}^{-{n}^{2}t}}-{n}^{2} \left ( {n}^{2} \left ( t{n}^{4}-2\,{n}^{2}+t \right ) \left ( -1 \right ) ^{n}+2\,{n}^{6}+2\,t{n}^{4}-2\,{n}^{2}+2\,t \right ) \cos \left ( nx-t \right ) + \left ( {n}^{2} \left ( {n}^{6}+t{n}^{4}-{n}^{2}+t \right ) \left ( -1 \right ) ^{n}-2\,{n}^{4} \left ( t{n}^{4}-2\,{n}^{2}+t \right ) \right ) \sin \left ( nx-t \right ) +{n}^{2} \left ( 2\, \left ( -1 \right ) ^{1+n}{n}^{4}+t{n}^{2} \left ( {n}^{4}+1 \right ) \left ( -1 \right ) ^{n}+2\,{n}^{6}+2\,t{n}^{4}-2\,{n}^{2}+2\,t \right ) \cos \left ( nx+t \right ) + \left ( {n}^{2} \left ( {n}^{6}+t{n}^{4}-{n}^{2}+t \right ) \left ( -1 \right ) ^{n}-2\,{n}^{4} \left ( t{n}^{4}-2\,{n}^{2}+t \right ) \right ) \sin \left ( nx+t \right ) +20\,\pi \,\sin \left ( nx \right ) \left ( -1 \right ) ^{1+n} \left ( {n}^{4}+1 \right ) ^{2} \right ) }\pi \right ) } \]
____________________________________________________________________________________
Taken from Maple PDE help pages
Solve the heat equation for \(u(x,t)\)
\[ u_t= k u_{xx} + f(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)=g(x)\)
Mathematica ✗
ClearAll[u, x, t, k, f, g, c]; pde = D[u[x, t], t] == k*D[u[x, t], {x, 2}] + f[x, t]; bc = {u[0, t] == 0, u[1, t] == 0}; ic = u[x, 0] == g[x]; sol = AbsoluteTiming[TimeConstrained[DSolve[{pde, ic, bc}, u[x, t], x, t, Assumptions -> {k > 0, t > 0, x > 0, x < 1}], 60*10]];
\[ \text {Failed} \]
Maple ✓
u:='u'; t:='t'; x:='x';f:='f';k:='k';g:='g'; interface(showassumed=0); pde:= diff(u(x, t), t) = k*(diff(u(x, t), x, x))+f(x, t); bc := u(0, t) = 0, u(l, t) = 0; ic:= u(x, 0) = g(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 {n\pi \,x}{l}} \right ) {{\rm e}^{-{\frac {{\pi }^{2}{n}^{2}kt}{{l}^{2}}}}}\int _{0}^{l}\!g \left ( x \right ) \sin \left ( {\frac {n\pi \,x}{l}} \right ) \,{\rm d}x} \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}\!f \left ( x,\tau \right ) \sin \left ( {\frac {n\pi \,x}{l}} \right ) \,{\rm d}x} \right ) \,{\rm d}\tau \]
____________________________________________________________________________________
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\)
For hand solution see my HW9, Math 322, UW Madison.
Mathematica ✗
ClearAll[u, x, t]; 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]];
\[ \text {Failed} \]
Maple ✓
x:='x'; u:='u'; t:='t'; 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 ) =1/23\,{\frac {1}{\pi } \left ( 23\,\sum _{n=1}^{\infty }-2\,{\frac {\sin \left ( nx \right ) {{\rm e}^{-{n}^{2}t}}}{n\pi }}\pi +\pi \, \left ( {{\rm e}^{-2\,t}}-{{\rm e}^{-25\,t}} \right ) \sin \left ( 5\,x \right ) -23\,x+23\,\pi \right ) } \]
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 ?? on page ?? 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
____________________________________________________________________________________
Added Nov 27, 2018.
Problem 8.2.2 part(a) from Richard Haberman applied partial differential equations book, 5th edition
Solve the heat equation for \(u(x,t)\)
\[ u_t=u_{xx} + Q(x,t) \]
For \(0<x<L\) and \(t>0\). The boundary conditions are \begin {align*} \frac { \partial u}{\partial x}(0,t) &= A(t) \\ \frac { \partial u}{\partial x}(L,t) &= B(t)\\ \end {align*}
Initial condition is \(u(x,0)=f(x)\)
For hand solution see my HW9, Math 322, UW Madison. The text does not actually asks to solve this PDE but only to reduce the problem to one with homogeneous B.C.
Mathematica ✗
ClearAll[u, x, t, k, f, A, B, L, Q]; pde = D[u[x, t], t] == k*D[u[x, t], {x, 2}] + Q[x, t]; bc = {Derivative[1, 0][u][0, t] == A[t], Derivative[1, 0][u][L, t] == B[t]}; ic = u[x, 0] == f[x]; sol = AbsoluteTiming[TimeConstrained[DSolve[{pde, ic, bc}, u[x, t], x, t, Assumptions -> L > 0], 60*10]];
\[ \text {Failed} \]
Maple ✓
L:='L'; u:='u'; t:='t'; x:='x';f:='f';A:='A';B:='B';k:='k';Q:='Q'; interface(showassumed=0); pde := diff(u(x,t),t)+k*diff(u(x,t),x$2)+Q(x,t); ic := u(x,0)=f(x); bc := eval( diff(u(x,t),x),x=0)=A(t), eval( diff(u(x,t),x),x=L)=B(t); 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}{{L}^{2}} \left ( 2\,xA \left ( t \right ) {L}^{2}-{x}^{2}A \left ( t \right ) L+{x}^{2}B \left ( t \right ) L+2\,\sum _{n=1}^{\infty } \left ( {\frac {1}{{L}^{2}}{{\rm e}^{{\frac {k{\pi }^{2}{n}^{2}t}{{L}^{2}}}}}\int _{0}^{L}\! \left ( -2\,\tau \,A \left ( 0 \right ) L+{\tau }^{2}A \left ( 0 \right ) -{\tau }^{2}B \left ( 0 \right ) +2\,f \left ( \tau \right ) L \right ) \cos \left ( {\frac {n\pi \,\tau }{L}} \right ) \,{\rm d}\tau \cos \left ( {\frac {n\pi \,x}{L}} \right ) } \right ) {L}^{2}+2\,\int _{0}^{t}\!1/2\,{\frac {1}{{L}^{2}} \left ( 2\,\sum _{n=1}^{\infty } \left ( -{\frac {1}{{L}^{2}}\int _{0}^{L}\!-2\,\cos \left ( {\frac {n\pi \,x}{L}} \right ) \left ( 1/2\,x \left ( x-2\,L \right ) {\frac {\rm d}{{\rm d}\tau }}A \left ( \tau \right ) -1/2\,{x}^{2}{\frac {\rm d}{{\rm d}\tau }}B \left ( \tau \right ) -Q \left ( x,\tau \right ) L+ \left ( A \left ( \tau \right ) -B \left ( \tau \right ) \right ) k \right ) \,{\rm d}x\cos \left ( {\frac {n\pi \,x}{L}} \right ) {{\rm e}^{{\frac {k{\pi }^{2}{n}^{2} \left ( t-\tau \right ) }{{L}^{2}}}}}} \right ) {L}^{2}-\int _{0}^{L}\!-x \left ( x-2\,L \right ) {\frac {\rm d}{{\rm d}\tau }}A \left ( \tau \right ) +{x}^{2}{\frac {\rm d}{{\rm d}\tau }}B \left ( \tau \right ) +2\,Q \left ( x,\tau \right ) L-2\, \left ( A \left ( \tau \right ) -B \left ( \tau \right ) \right ) k\,{\rm d}x \right ) }\,{\rm d}\tau {L}^{2}+\int _{0}^{L}\! \left ( -2\,L\tau +{\tau }^{2} \right ) A \left ( 0 \right ) -{\tau }^{2}B \left ( 0 \right ) +2\,f \left ( \tau \right ) L\,{\rm d}\tau \right ) } \]
Hand solution
Solve \begin {align*} u_{t} & =ku_{xx}+Q\left ( x,t\right ) \\ u_{x}\left ( 0,t\right ) & =A\left ( t\right ) \\ u_{x}\left ( L,0\right ) & =B\left ( t\right ) \\ u\left ( x,0\right ) & =f\left ( x\right ) \end {align*}
Let \begin {equation} u\left ( x,t\right ) =v\left ( x,t\right ) +r\left ( x,t\right ) \tag {1} \end {equation} Since the problem has time dependent source function \(Q\left ( x,t\right ) \) then \(r\left ( x,t\right ) \) is now a reference function that only needs to satisfy the non-homogenous boundary conditions which in this problem are at both ends and \(v\left ( x,t\right ) \) has homogenous boundary conditions. The first step is to find \(r\left ( x,t\right ) \). Let\[ r\left ( x,t\right ) =c_{1}\left ( t\right ) x+c_{2}\left ( t\right ) x^{2}\] Then\[ \frac {\partial r\left ( x,t\right ) }{\partial x}=c_{1}\left ( t\right ) +2c_{2}\left ( t\right ) x \] At \(x=0\)\[ A\left ( t\right ) =c_{1}\left ( t\right ) \] And at \(x=L\)\begin {align*} B\left ( t\right ) & =c_{1}\left ( t\right ) +2c_{2}\left ( t\right ) L\\ c_{2}\left ( t\right ) & =\frac {B\left ( t\right ) -c_{1}\left ( t\right ) }{2L} \end {align*}
Solving for \(c_{1},c_{2}\) gives\begin {equation} r\left ( x,t\right ) =A\left ( t\right ) x+\left ( \frac {B\left ( t\right ) -A\left ( t\right ) }{2L}\right ) x^{2} \tag {2} \end {equation} Replacing (1) into the original PDE \(u_{t}=ku_{xx}+Q\left ( x,t\right ) \) gives\begin {align*} \frac {\partial }{\partial t}\left ( v\left ( x,t\right ) -r\left ( x,t\right ) \right ) & =k\frac {\partial ^{2}}{\partial x}\left ( v\left ( x,t\right ) -r\left ( x,t\right ) \right ) +Q\left ( x,t\right ) \\ \frac {\partial v}{\partial t}-\frac {\partial r}{\partial t} & =k\frac {\partial ^{2}v}{\partial x^{2}}-k\frac {\partial ^{2}r}{\partial x^{2}}+Q\left ( x,t\right ) \end {align*}
But \(r_{xx}=\frac {B\left ( t\right ) -A\left ( t\right ) }{L}\), hence the above reduces to\begin {equation} v_{t}=kv_{xx}+Q\left ( x,t\right ) -k\frac {B\left ( t\right ) -A\left ( t\right ) }{L}+r_{t} \tag {3} \end {equation} Let \[ \tilde {Q}\left ( x,t\right ) =Q\left ( x,t\right ) +r_{t}-k\frac {B\left ( t\right ) -A\left ( t\right ) }{L}\] Then (3) becomes\begin {align} v_{t} & =kv_{xx}+\tilde {Q}\left ( x,t\right ) \tag {4}\\ v_{t}\left ( 0,t\right ) & =0\nonumber \\ v_{t}\left ( L,t\right ) & =0\nonumber \end {align}
And initial condition is \begin {align*} v\left ( x,0\right ) & =F\left ( x\right ) \\ & =u\left ( x,0\right ) -r\left ( x,0\right ) \\ & =f\left ( x\right ) -\left ( A\left ( 0\right ) x+\left ( \frac {B\left ( 0\right ) -A\left ( 0\right ) }{2L}\right ) x^{2}\right ) \end {align*}
PDE (4) with its homogenous boundary conditions is standard one, its corresponding eigenvalue boundary value ODE \(X^{\prime \prime }+\lambda X=0\) has \(\lambda =0\) as eigenvalue with corresponding eigenfunction \(\Phi _{0}\left ( x\right ) =1\) and \(\lambda _{n}=\left ( \frac {n\pi }{L}\right ) ^{2}\) for \(n=1,2,3,\cdots \) with corresponding eigenfunctions \(\Phi _{n}\left ( x\right ) =\cos \left ( \sqrt {\lambda _{n}}x\right ) \). Using these, we can write the solution to (4) using eigenfunction expansion as\begin {equation} v\left ( x,t\right ) =\sum _{n=0}^{\infty }c_{n}\left ( t\right ) \Phi _{n}\left ( x\right ) \tag {4A} \end {equation} Hence \(v_{t}\left ( x,t\right ) =\sum _{n=0}^{\infty }c_{n}^{\prime }\left ( t\right ) \Phi _{n}\left ( x\right ) \) and \(v_{xx}\left ( x,t\right ) =\sum _{n=0}^{\infty }c_{n}\left ( t\right ) \Phi _{n}^{\prime \prime }\left ( x\right ) \). Substituting these into (4) gives\[ \sum _{n=0}^{\infty }c_{n}^{\prime }\left ( t\right ) \Phi _{n}\left ( x\right ) =\sum _{n=0}^{\infty }c_{n}\left ( t\right ) \Phi _{n}^{\prime \prime }\left ( x\right ) +\tilde {Q}\left ( x,t\right ) \] Expanding \(\tilde {Q}\left ( x,t\right ) \) using same eigenfunctions since they are complete, the above becomes\[ \sum _{n=0}^{\infty }c_{n}^{\prime }\left ( t\right ) \Phi _{n}\left ( x\right ) =\sum _{n=0}^{\infty }c_{n}\left ( t\right ) \Phi _{n}^{\prime \prime }\left ( x\right ) +\sum _{n=0}^{\infty }b_{n}\left ( t\right ) \Phi _{n}\left ( x\right ) \] But \(\Phi _{n}^{\prime \prime }\left ( x\right ) =-\lambda _{n}\Phi _{n}\left ( x\right ) \) and the above becomes\begin {align} \sum _{n=0}^{\infty }c_{n}^{\prime }\left ( t\right ) \Phi _{n}\left ( x\right ) & =-\sum _{n=0}^{\infty }c_{n}\left ( t\right ) \lambda _{n}\Phi _{n}\left ( x\right ) +\sum _{n=0}^{\infty }b_{n}\left ( t\right ) \Phi _{n}\left ( x\right ) \nonumber \\ c_{n}^{\prime }\left ( t\right ) \Phi _{n}\left ( x\right ) +c_{n}\left ( t\right ) \lambda _{n}\Phi _{n}\left ( x\right ) & =b_{n}\left ( t\right ) \Phi _{n}\left ( x\right ) \nonumber \\ c_{n}^{\prime }\left ( t\right ) +c_{n}\left ( t\right ) \lambda _{n} & =b_{n}\left ( t\right ) \nonumber \\ c_{n}^{\prime }\left ( t\right ) +c_{n}\left ( t\right ) \frac {n^{2}\pi ^{2}}{L^{2}} & =b_{n}\left ( t\right ) \tag {5} \end {align}
To find \(b_{n}\left ( t\right ) \), since \(\tilde {Q}\left ( x,t\right ) =Q\left ( x,t\right ) +\frac {\partial r}{\partial t}-k\frac {B\left ( t\right ) -A\left ( t\right ) }{L}\) then\[ Q\left ( x,t\right ) +\frac {\partial r}{\partial t}-k\frac {B\left ( t\right ) -A\left ( t\right ) }{L}=\sum _{n=0}^{\infty }b_{n}\left ( t\right ) \Phi _{n}\left ( x\right ) \] Multiplying both sides by \(\Phi _{m}\left ( x\right ) \) and integrating gives\begin {align*} \int _{0}^{L}\left ( Q\left ( x,t\right ) +\frac {\partial r}{\partial t}-k\frac {B\left ( t\right ) -A\left ( t\right ) }{L}\right ) \Phi _{m}\left ( x\right ) dx & =\int _{0}^{L}\sum _{n=0}^{\infty }b_{n}\left ( t\right ) \Phi _{n}\left ( x\right ) \Phi _{m}\left ( x\right ) dx\\ & =\sum _{n=0}^{\infty }b_{n}\left ( t\right ) \left ( \int _{0}^{L}\Phi _{n}\left ( x\right ) \Phi _{m}\left ( x\right ) dx\right ) \end {align*}
By orthogonality\[ \int _{0}^{L}\left ( Q\left ( x,t\right ) +r_{t}-k\frac {B\left ( t\right ) -A\left ( t\right ) }{L}\right ) \Phi _{m}\left ( x\right ) dx=b_{m}\left ( t\right ) \int _{0}^{L}\Phi _{m}^{2}\left ( x\right ) dx \] When \(m=0,\Phi _{0}\left ( x\right ) =1\) and the above gives\begin {align*} \int _{0}^{L}Q\left ( x,t\right ) +r_{t}-k\frac {B\left ( t\right ) -A\left ( t\right ) }{L}dx & =b_{0}\left ( t\right ) \int _{0}^{L}dx\\ b_{0}\left ( t\right ) & =\frac {1}{L}\int _{0}^{L}Q\left ( x,t\right ) +r_{t}-k\frac {B\left ( t\right ) -A\left ( t\right ) }{L}dx \end {align*}
When \(m=1,2,3,\cdots \)\begin {align*} \int _{0}^{L}\left ( Q\left ( x,t\right ) +r_{t}-k\frac {B\left ( t\right ) -A\left ( t\right ) }{L}\right ) \cos \left ( \frac {m\pi }{L}x\right ) dx & =b_{m}\left ( t\right ) \int _{0}^{L}\cos ^{2}\left ( \frac {m\pi }{L}x\right ) dx\\ \int _{0}^{L}\left ( Q\left ( x,t\right ) +r_{t}-k\frac {B\left ( t\right ) -A\left ( t\right ) }{L}\right ) \cos \left ( \frac {m\pi }{L}x\right ) dx & =b_{m}\left ( t\right ) \frac {L}{2}\\ b_{m}\left ( t\right ) & =\frac {2}{L}\int _{0}^{L}\left ( Q\left ( x,t\right ) +r_{t}-k\frac {B\left ( t\right ) -A\left ( t\right ) }{L}\right ) \cos \left ( \frac {m\pi }{L}x\right ) dx \end {align*}
Therefore (5) is now solved. When \(n=0\) (5) becomes\begin {align*} c_{0}^{\prime }\left ( t\right ) +c_{0}\left ( t\right ) \frac {n^{2}\pi ^{2}}{L^{2}} & =b_{0}\left ( t\right ) \\ c_{0}^{\prime }\left ( t\right ) & =b_{0}\left ( t\right ) \\ c_{0}^{\prime }\left ( t\right ) & =\frac {1}{L}\int _{0}^{L}Q\left ( x,t\right ) +r_{t}-k\frac {B\left ( t\right ) -A\left ( t\right ) }{L}dx \end {align*}
Hence\[ c_{0}\left ( t\right ) =\int _{0}^{t}\left ( \frac {1}{L}\int _{0}^{L}Q\left ( x,\tau \right ) +r_{\tau }-k\frac {B\left ( \tau \right ) -A\left ( \tau \right ) }{L}dx\right ) dt+C_{0}\] For \(n=1,2,3,\cdots \) (5) becomes\begin {align*} c_{n}^{\prime }\left ( t\right ) +c_{n}\left ( t\right ) \frac {n^{2}\pi ^{2}}{L^{2}} & =b_{n}\left ( t\right ) \\ & =\frac {2}{L}\int _{0}^{L}\left ( Q\left ( x,\tau \right ) +r_{\tau }-k\frac {B\left ( \tau \right ) -A\left ( \tau \right ) }{L}\right ) \cos \left ( \frac {n\pi }{L}x\right ) dx \end {align*}
Integrating factor is \(I=e^{\int \frac {n^{2}\pi ^{2}}{L^{2}}dt}=e^{\frac {n^{2}\pi ^{2}}{L^{2}}t}\) and the solution to the above becomes
\begin {align*} \frac {d}{dt}\left ( c_{n}\left ( t\right ) e^{\frac {n^{2}\pi ^{2}}{L^{2}}t}\right ) & =\frac {2e^{\frac {n^{2}\pi ^{2}}{L^{2}}t}}{L}\int _{0}^{L}\left ( Q\left ( x,t\right ) +r_{t}-k\frac {B\left ( t\right ) -A\left ( t\right ) }{L}\right ) \cos \left ( \frac {n\pi }{L}x\right ) dx\\ c_{n}\left ( t\right ) e^{\frac {n^{2}\pi ^{2}}{L^{2}}t} & =\int _{0}^{t}\left ( \frac {2e^{\frac {n^{2}\pi ^{2}}{L^{2}}\tau }}{L}\int _{0}^{L}\left ( Q\left ( x,\tau \right ) +r_{\tau }-k\frac {B\left ( \tau \right ) -A\left ( \tau \right ) }{L}\right ) \cos \left ( \frac {n\pi }{L}x\right ) dx\right ) dt+C_{n}\\ c_{n}\left ( t\right ) & =e^{-\frac {n^{2}\pi ^{2}}{L^{2}}t}\int _{0}^{t}\left ( \frac {2e^{\frac {n^{2}\pi ^{2}}{L^{2}}\tau }}{L}\int _{0}^{L}\left ( Q\left ( x,\tau \right ) +r_{\tau }-k\frac {B\left ( \tau \right ) -A\left ( \tau \right ) }{L}\right ) \cos \left ( \frac {n\pi }{L}x\right ) dx\right ) dt+C_{n}e^{-\frac {n^{2}\pi ^{2}}{L^{2}}t} \end {align*}
Now that we found \(c_{n}\left ( t\right ) \) for \(n=0,1,2,3,\cdots \) the solution for \(v\left ( x,t\right ) \) is found from 4A.
\begin {align*} v\left ( x,t\right ) & =\sum _{n=0}^{\infty }c_{n}\left ( t\right ) \Phi _{n}\left ( x\right ) \\ & =\int _{0}^{t}\left ( \frac {1}{L}\int _{0}^{L}Q\left ( x,\tau \right ) +r_{\tau }-k\frac {B\left ( \tau \right ) -A\left ( \tau \right ) }{L}dx\right ) dt+C_{0}+\sum _{n=1}^{\infty }c_{n}\left ( t\right ) \Phi _{n}\left ( x\right ) \\ & \\ & =\int _{0}^{t}\left ( \frac {1}{L}\int _{0}^{L}Q\left ( x,\tau \right ) +r_{\tau }-k\frac {B\left ( \tau \right ) -A\left ( \tau \right ) }{L}dx\right ) dt+C_{0}\\ & +\sum _{n=1}^{\infty }\left ( e^{-\frac {n^{2}\pi ^{2}}{L^{2}}t}\int _{0}^{t}\left ( \frac {2e^{\frac {n^{2}\pi ^{2}}{L^{2}}\tau }}{L}\int _{0}^{L}\left ( Q\left ( x,\tau \right ) +r_{\tau }-k\frac {B\left ( \tau \right ) -A\left ( \tau \right ) }{L}\right ) \cos \left ( \frac {n\pi }{L}x\right ) dx\right ) dt+C_{n}e^{-\frac {n^{2}\pi ^{2}}{L^{2}}t}\right ) \cos \left ( \frac {n\pi }{L}x\right ) \end {align*}
But \[ u\left ( x,t\right ) =v\left ( x,t\right ) +r\left ( x,t\right ) \] Hence
\begin {align*} u\left ( x,t\right ) & =A\left ( t\right ) x+\left ( \frac {B\left ( t\right ) -A\left ( t\right ) }{2L}\right ) x^{2}+\int _{0}^{t}\left ( \frac {1}{L}\int _{0}^{L}Q\left ( x,\tau \right ) +r_{\tau }-k\frac {B\left ( \tau \right ) -A\left ( \tau \right ) }{L}dx\right ) dt+C_{0}\\ & +\sum _{n=1}^{\infty }\left ( e^{-\frac {n^{2}\pi ^{2}}{L^{2}}t}\int _{0}^{t}\left ( \frac {2e^{\frac {n^{2}\pi ^{2}}{L^{2}}\tau }}{L}\int _{0}^{L}\left ( Q\left ( x,\tau \right ) +r_{\tau }-k\frac {B\left ( \tau \right ) -A\left ( \tau \right ) }{L}\right ) \cos \left ( \frac {n\pi }{L}x\right ) dx\right ) dt+C_{n}e^{-\frac {n^{2}\pi ^{2}}{L^{2}}t}\right ) \cos \left ( \frac {n\pi }{L}x\right ) \end {align*}
But \begin {align*} r_{\tau } & =\frac {d}{dt}\left ( A\left ( \tau \right ) x+\left ( \frac {B\left ( \tau \right ) -A\left ( \tau \right ) }{2L}\right ) x^{2}\right ) \\ & =\frac {2LA^{\prime }\left ( \tau \right ) x+\left ( B^{\prime }\left ( \tau \right ) -A^{\prime }\left ( \tau \right ) \right ) x^{2}}{2L} \end {align*}
Hence
\begin {gather*} u\left ( x,t\right ) =C_{0}+A\left ( t\right ) x+\left ( \frac {B\left ( t\right ) -A\left ( t\right ) }{2L}\right ) x^{2}\\ +\frac {1}{2L^{2}}\int _{0}^{t}\left ( \int _{0}^{L}2LQ\left ( x,\tau \right ) +2LA^{\prime }\left ( \tau \right ) x+\left ( B^{\prime }\left ( \tau \right ) -A^{\prime }\left ( \tau \right ) \right ) x^{2}-2k\left ( B\left ( \tau \right ) -A\left ( \tau \right ) \right ) dx\right ) dt+\\ \sum _{n=1}^{\infty }\cos \frac {n\pi }{L}x\left ( e^{-\frac {n^{2}\pi ^{2}}{L^{2}}t}\int _{0}^{t}\left ( \frac {e^{\frac {n^{2}\pi ^{2}}{L^{2}}\tau }}{L^{2}}\int _{0}^{L}\left ( 2LQ\left ( x,\tau \right ) +2LA^{\prime }\left ( \tau \right ) x+\left ( B^{\prime }\left ( \tau \right ) -A^{\prime }\left ( \tau \right ) \right ) x^{2}-2k\left ( B\left ( \tau \right ) -A\left ( \tau \right ) \right ) \right ) \cos \left ( \frac {n\pi }{L}x\right ) dx\right ) dt+C_{n}e^{-\frac {n^{2}\pi ^{2}}{L^{2}}t}\right ) \end {gather*}
The constants \(C_{0},C_{n}\) are found from initial conditions \(u\left ( x,0\right ) =f\left ( x\right ) \).
____________________________________________________________________________________
Added December 20, 2018.
Example 8.4.1 from Partial differential equations and boundary value problems with Maple by George A. Articolo, 2nd ed.
Solve the heat equation for \(u(x,t)\)
\[ \frac { \partial u}{\partial t}= k \frac { \partial ^2 u}{\partial x^2} \]
For \(0<x<1\) and \(t>0\). The boundary conditions are \begin {align*} u(0,t)=10 \\ u(1,t) = 20\\ \end {align*}
Initial condition is \(u(x,0)=60 x - 50 x^2+10\) and \(k=\frac {1}{20}\)
Mathematica ✓
ClearAll[u, x, t, k, n]; k = 1/20; pde = D[u[x, t], t] == k*D[u[x, t], {x, 2}]; bc = {u[0, t] == 10, u[1, t] == 20}; ic = u[x, 0] == 60*x - 50*x^2 + 10; 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 {1}{20} n^2 \pi ^2 t} \sin (n \pi x)}{n^3 \pi ^3}+10 x+10\right \}\right \} \]
Maple ✓
u:='u'; t:='t'; x:='x'; k := 1/20; pde := diff(u(x,t),t)= k*diff(u(x,t),x$2); bc := u(0, t) = 10, u(1, t) = 20; ic := u(x, 0) = 60*x - 50*x^2 + 10; cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol', pdsolve([pde, ic, bc], u(x, t))),output='realtime'));
\[ u \left ( x,t \right ) =10+10\,x+\sum _{n=1}^{\infty }-200\,{\frac { \left ( -1+ \left ( -1 \right ) ^{n} \right ) \sin \left ( n\pi \,x \right ) {{\rm e}^{-1/20\,{\pi }^{2}{n}^{2}t}}}{{n}^{3}{\pi }^{3}}} \]
____________________________________________________________________________________
Added December 20, 2018.
Example 8.4.3 from Partial differential equations and boundary value problems with Maple by George A. Articolo, 2nd ed.
Solve the heat equation for \(u(x,t)\)
\[ u_t = k u_{xx} + t \]
For \(0<x<1\) and \(t>0\). The boundary conditions are \begin {align*} u(0,t)&=5 \\ u(1,t)+ \frac {\partial u}{\partial x}(1,t) &= 10\\ \end {align*}
Initial condition is \(u(x,0)=\frac {- 40 x^2}{3}+ \frac {45 x}{2}+5\) and \(k=\frac {1}{20}\)
Mathematica ✗
ClearAll[u, x, t, k, n]; k = 1/20; pde = D[u[x, t], t] == k*D[u[x, t], {x, 2}] + t; bc = {u[0, t] == 5, u[1, t] + Derivative[1, 0][u][1, t] == 10}; ic = u[x, 0] == (-40*x^2)/3 + (45*x)/2 + 5; sol = AbsoluteTiming[TimeConstrained[DSolve[{pde, ic, bc}, u[x, t], x, t], 60*10]];
\[ \text {Failed} \]
Maple ✗
u:='u'; t:='t'; x:='x'; pde := diff(u(x, t), t) = (1/20)*(diff(u(x, t), x$2))+t; bc := u(0, t) = 5, (u(1, t)+ eval( diff(u(x,t),x),x=1)) = 10; ic:= u(x, 0) = -40*x^2/3+45*x/2+5; cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol', pdsolve([pde, bc,ic], u(x, t))),output='realtime'));
\[ \text { Exception } \]
____________________________________________________________________________________
Added December 20, 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[u, x, t]; 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]];
\[ \text {Failed} \]
Maple ✓
u:='u'; t:='t'; x:='x'; 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 ( -1+ \left ( -1 \right ) ^{n} \right ) }{{\pi }^{2}{n}^{2}}}+13\,t+1/2\,{x}^{2} \]
____________________________________________________________________________________
Added January 18, 2019.
Solve the heat equation for \(u(x,t)\) \[ u_t = u_{xx} \] For \(0<x<\pi \) and \(t>0\). The boundary conditions are \begin {align*} u_x(0,t) &= 1\\ u_x(1,t) &= -1 \end {align*}
Initial condition is \(u(x,0)=\sin (x)\)
Mathematica ✗
ClearAll[u, x, t]; pde = D[u[x, t], t] == D[u[x, t], {x, 2}] + (x - (1*x^2)/Pi); ic = u[x, 0] == Sin[x]; bc = {Derivative[1, 0][u][0, t] == 1, Derivative[1, 0][u][Pi, t] == -1}; sol = AbsoluteTiming[TimeConstrained[DSolve[{pde, ic, bc}, u[x, t], {x, t}], 60*10]];
\[ \text {Failed} \]
Maple ✓
u:='u'; t:='t'; x:='x'; pde := diff(u(x, t), t) = diff(u(x, t), x$2): ic := u(x, 0) = sin(x): bc := eval(diff(u(x,t),x),x=0)=1, eval( diff(u(x,t),x),x=Pi)=-1: cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol', pdsolve({pde, ic, bc}, u(x, t))),output='realtime'));
\[ u \left ( x,t \right ) =1/6\,{\frac {1}{\pi } \left ( -{\pi }^{2}+6\,\sum _{n=2}^{\infty }-2\,{\frac {\cos \left ( nx \right ) {{\rm e}^{-{n}^{2}t}} \left ( \left ( -1 \right ) ^{n}+1 \right ) }{{n}^{2} \left ( {n}^{2}-1 \right ) \pi }}\pi +6\,\pi \,x-6\,{x}^{2}-12\,t+12 \right ) } \]
Hand solution
Since the boundary conditions are not homogeneous, we can’t use separation of variables. Let the solution be
\[ u=v\left ( x,t\right ) +r\left ( x\right ) \] Where \(v\left ( x,t\right ) \) is the solution to \(v_{t}=v_{xx}\) and homogenous B.C. \(v_{x}\left ( 0,t\right ) =0,v_{x}\left ( \pi ,t\right ) =0\) and \(r\left ( x\right ) \) is any reference solution which only needs to satisfy the nonhomogeneous boundary conditions: \(r^{\prime }\left ( 0\right ) =1,r^{\prime }\left ( \pi \right ) =-1\). By guessing, let \(r\left ( x\right ) =Ax+Bx^{2}\). Let see if this satisfies the boundary conditions. \(r^{\prime }=A+2Bx\). At \(x=0\) this implies \(1=A\). Hence \(r=x+Bx^{2}\). Now \(r^{\prime }=1+2Bx\). At \(x=\pi \) this gives \(-1=1+2B\pi \) or \(B=-\frac {1}{\pi }\). Therefore \[ r\left ( x\right ) =x-\frac {1}{\pi }x^{2}\] Substituting \(u=v\left ( x,t\right ) +r\left ( x\right ) \) into the PDE \(u_{t}=u_{xx}\) and noting that \(r^{\prime \prime }\left ( x\right ) =-\frac {2}{\pi }\) gives\begin {equation} v_{t}=v_{xx}-\frac {2}{\pi }\tag {1} \end {equation} PDE (1) is now solved using eigenfunction expansion. We need to find eigenfunctions and eigenvalues of \(v_{t}=v_{xx}\) with \(v_{x}\left ( 0,t\right ) =0,v_{x}\left ( \pi ,t\right ) =0\). This is known PDE and have eigenfunctions and eigenvalues as follows. For zero eigenvalue, the eigenfunction is an arbitrary constant. Say \(\beta \). let \(\beta =1\) since scale is not important.\[ \Phi _{0}\left ( x\right ) =1 \] And for \(n=1,2,3,\cdots \) \begin {align*} \Phi _{n}\left ( x\right ) & =\cos \left ( \sqrt {\lambda _{n}}x\right ) \\ & =\cos \left ( nx\right ) \end {align*}
with eigenvalues \(\lambda _{n}=n^{2}\) for \(n=1,2,3,\cdots \). Now we can eigenfunction expansion and assume the solution to (1) is \begin {equation} v\left ( x,t\right ) =\sum _{n=0}^{\infty }A_{n}\left ( t\right ) \Phi _{n}\left ( x\right ) \tag {2} \end {equation} Plugging this into the PDE (1) gives\[ \sum _{n=0}^{\infty }A_{n}^{\prime }\left ( t\right ) \Phi _{n}\left ( x\right ) =\sum _{n=0}^{\infty }A_{n}\left ( t\right ) \Phi _{n}^{\prime \prime }\left ( x\right ) -\frac {2}{\pi }\] But \(\Phi _{n}^{\prime \prime }\left ( x\right ) =-\lambda _{n}\Phi _{n}\left ( x\right ) \) and the above simplifies to\[ \sum _{n=0}^{\infty }A_{n}^{\prime }\left ( t\right ) \Phi _{n}\left ( x\right ) =-\sum _{n=0}^{\infty }A_{n}\left ( t\right ) \lambda _{n}\Phi _{n}\left ( x\right ) -\frac {2}{\pi }\] Since eigenfunctions are complete, we can expand \(\frac {2}{\pi }\) using them and the above becomes\begin {align} \sum _{n=0}^{\infty }A_{n}^{\prime }\left ( t\right ) \Phi _{n}\left ( x\right ) & =-\sum _{n=0}^{\infty }A_{n}\left ( t\right ) \lambda _{n}\Phi _{n}\left ( x\right ) -\sum _{n=0}^{\infty }C_{n}\Phi _{n}\left ( x\right ) \nonumber \\ A_{n}^{\prime }\left ( t\right ) \Phi _{n}\left ( x\right ) +A_{n}\left ( t\right ) \lambda _{n}\Phi _{n}\left ( x\right ) & =-C_{n}\Phi _{n}\left ( x\right ) \nonumber \\ A_{n}^{\prime }\left ( t\right ) +A_{n}\left ( t\right ) \lambda _{n} & =-C_{n}\tag {3} \end {align}
To find \(C_{n}\)\[ \sum _{n=0}^{\infty }C_{n}\Phi _{n}\left ( x\right ) =\frac {2}{\pi }\] For \(n=0\)\[ C_{0}\Phi _{0}\left ( x\right ) =\frac {2}{\pi }\] But \(\Phi _{0}\left ( x\right ) =1\), hence \[ C_{0}=\frac {2}{\pi }\] All other \(C_{m}\,\ \) for \(m>0\) are zero. Hence (3) becomes, for \(n=0\) (since \(\lambda _{0}=0\))\begin {align*} A_{0}^{\prime }\left ( t\right ) & =-\frac {2}{\pi }\\ A_{0}\left ( t\right ) & =-\frac {2}{\pi }t+B_{0} \end {align*}
Where \(B_{0}\) is integration constant. For \(n>0\) (3) becomes\[ A_{n}^{\prime }\left ( t\right ) +A_{n}\left ( t\right ) n^{2}=0 \] This has the solution\[ A_{n}\left ( t\right ) =B_{n}e^{-n^{2}t}\] Where \(B_{n}\) is constant of integration. Hence from (2)\begin {align*} v\left ( x,t\right ) & =\sum _{n=0}^{\infty }A_{n}\left ( t\right ) \Phi _{n}\left ( x\right ) \\ & =A_{0}\left ( t\right ) +\sum _{n=1}^{\infty }A_{n}\left ( t\right ) \Phi _{n}\left ( x\right ) \\ & =-\frac {2}{\pi }t+B_{0}+\sum _{n=1}^{\infty }B_{n}e^{-n^{2}t}\cos \left ( nx\right ) \end {align*}
Since \(u=v\left ( x,t\right ) +r\left ( x\right ) \) then the solution becomes\begin {equation} u\left ( x,t\right ) =\left ( x-\frac {1}{\pi }x^{2}\right ) -\frac {2}{\pi }t+B_{0}+\sum _{n=1}^{\infty }B_{n}e^{-n^{2}t}\cos \left ( nx\right ) \tag {4} \end {equation} At \(t=0\)\begin {equation} \sin \left ( x\right ) =\left ( x-\frac {1}{\pi }x^{2}\right ) +B_{0}+\sum _{n=1}^{\infty }B_{n}\cos \left ( nx\right ) \tag {5} \end {equation} case \(n=0\)\[ \int _{0}^{\pi }\sin \left ( x\right ) \cos \left ( \sqrt {\lambda _{0}}x\right ) dx=\int _{0}^{\pi }\left ( x-\frac {1}{\pi }x^{2}\right ) \cos \left ( \sqrt {\lambda _{0}}x\right ) dx+\int _{0}^{\pi }B_{0}\cos \left ( \sqrt {\lambda _{0}}x\right ) dx \] But \(\lambda _{0}=0\) hence\begin {align*} \int _{0}^{\pi }\sin \left ( x\right ) dx & =\int _{0}^{\pi }\left ( x-\frac {1}{\pi }x^{2}\right ) dx+\int _{0}^{\pi }B_{0}dx\\ 2 & =\frac {\pi ^{2}}{6}+B_{0}\pi \\ B_{0} & =\frac {2}{\pi }-\frac {\pi }{6} \end {align*}
For \(n>0\), Multiplying both sides of (5) by \(\cos \left ( mx\right ) \) and integrating\[ \int _{0}^{\pi }\sin \left ( x\right ) \cos \left ( mx\right ) dx=\int _{0}^{\pi }\left ( x-\frac {1}{\pi }x^{2}\right ) \cos \left ( mx\right ) dx+\sum _{n=1}^{\infty }B_{n}\int _{0}^{\pi }\cos \left ( nx\right ) \cos \left ( mx\right ) dx \] For \(m=1\)\begin {align*} 0 & =0+B_{1}\frac {\pi }{2}\\ B_{1} & =0 \end {align*}
For \(m>1\)\begin {align*} -\frac {1+\left ( -1\right ) ^{m}}{m^{2}\left ( -1+m^{2}\right ) } & =\frac {\pi }{2}B_{m}\\ B_{m} & =\frac {-2}{\pi }\left ( \frac {1}{m^{2}}\frac {\left ( -1\right ) ^{m}+1}{m^{2}-1}\right ) \end {align*}
Hence solution (4) becomes\begin {align*} u\left ( x,t\right ) & =\left ( x-\frac {1}{\pi }x^{2}\right ) -\frac {2}{\pi }t-\frac {\pi }{6}+\frac {2}{\pi }+\sum _{n=1}^{\infty }B_{n}e^{-n^{2}t}\cos \left ( nx\right ) \\ u\left ( x,t\right ) & =\left ( x-\frac {1}{\pi }x^{2}\right ) -\frac {2}{\pi }t-\frac {\pi }{6}+\frac {2}{\pi }+\sum _{n=2}^{\infty }\frac {-2}{\pi }\left ( \frac {1}{n^{2}}\frac {\left ( -1\right ) ^{n}+1}{n^{2}-1}\right ) e^{-n^{2}t}\cos \left ( nx\right ) \end {align*}
____________________________________________________________________________________
Added March 31, 2019.
Solve the heat equation for \(u(x,t)\) \[ u_t = k u_{xx} \] For \(0<x<\pi \) and \(t>0\). The boundary conditions are \begin {align*} u(0,t) &= 0\\ u_x(\pi ,t) &= A \end {align*}
Initial condition is \(u(x,0)=0\)
Mathematica ✗
ClearAll[u, x, t,A]; pde = D[u[x, t], t] == D[u[x, t], {x, 2}] ; ic = u[x, 0] == 0; bc = {u[0,t] == 0, Derivative[1, 0][u][Pi, t] == A}; sol = AbsoluteTiming[TimeConstrained[DSolve[{pde, ic, bc}, u[x, t], {x, t},Assumptions->A>0], 60*10]];
\[ \text {Failed} \]
Maple ✓
u:='u'; t:='t'; x:='x';A:='A'; pde := diff(u(x, t), t) = diff(u(x, t), x$2): ic := u(x, 0) = 0: bc := u(0,t)=0, eval( diff(u(x,t),x),x=Pi)=A: cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol', pdsolve({pde, ic, bc}, u(x, t)) assuming A>0),output='realtime'));
\[ u \left ( x,t \right ) =\sum _{n=0}^{\infty }8\,{\frac {\sin \left ( nx+x/2 \right ) {{\rm e}^{-1/4\, \left ( 1+2\,n \right ) ^{2}t}} \left ( -1 \right ) ^{1+n}A}{\pi \, \left ( 1+2\,n \right ) ^{2}}}+Ax \]
____________________________________________________________________________________
Added April 15, 2019.
Solve the heat equation for \(u(x,t)\) \[ u_t = k u_{rr} \] For \(0<r<a\) and \(t>0\). The boundary conditions are \begin {align*} u(0,t) &= 0\\ u(a,t) &= a \phi (t) \end {align*}
Initial condition is \(u(r,0)=r f(r)\)
Mathematica ✗
ClearAll[u, x, t,A]; pde = D[u[r, t], t] == k*D[u[r, t], {r, 2}] ; ic = u[r, 0] == r*f[r]; bc = {u[0, t] == 0, u[a, t] == a*phi[t]}; sol = AbsoluteTiming[TimeConstrained[DSolve[{pde, ic, bc}, u[r, t], {r, t}], 60*10]];
\[ \text {Failed} \]
Maple ✓
unassign('u,t,r,k,f,phi'); pde := diff(u(r, t), t) = k*diff(u(r, t), r$2): ic:=u(r,0)=r*f(r); bc:=u(0,t)=0,u(a,t)=a*phi(t); cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol', pdsolve({pde, ic, bc}, u(r, t))),output='realtime'));
\[ u \left ( r,t \right ) =\sum _{n=1}^{\infty } \left ( -2\,{\frac {1}{a}\sin \left ( {\frac {n\pi \,r}{a}} \right ) {{\rm e}^{-{\frac {k{\pi }^{2}{n}^{2}t}{{a}^{2}}}}}\int _{0}^{a}\!\tau \, \left ( \phi \left ( 0 \right ) -f \left ( \tau \right ) \right ) \sin \left ( {\frac {n\pi \,\tau }{a}} \right ) \,{\rm d}\tau } \right ) +\int _{0}^{t}\!\sum _{n=1}^{\infty }2\,{\frac { \left ( -1 \right ) ^{n}a{\frac {\rm d}{{\rm d}\tau }}\phi \left ( \tau \right ) }{n\pi }\sin \left ( {\frac {n\pi \,r}{a}} \right ) {{\rm e}^{-{\frac {k{\pi }^{2}{n}^{2} \left ( t-\tau \right ) }{{a}^{2}}}}}}\,{\rm d}\tau +r\phi \left ( t \right ) \]
Hand solution
Solve \begin {equation} u_{t}=ku_{rr}\qquad t>0,0<r<a \tag {1} \end {equation} With boundary conditions\begin {align*} u\left ( 0,t\right ) & =0\\ u\left ( a,t\right ) & =a\phi \left ( t\right ) \end {align*}
And initial conditions\[ u\left ( r,0\right ) =rf\left ( r\right ) \] Since the boundary conditions are not homogeneous, the first step is to convert them to homogeneous. This is done using a reference function which needs to only satisfy the boundary conditions. This reference function can be seen to be \(v\left ( r,t\right ) =r\phi \left ( t\right ) \). Now we write\[ u\left ( r,t\right ) =w\left ( r,t\right ) +v\left ( r,t\right ) \] Where \(w\left ( r,t\right ) \) satisfies the PDE but with homogeneous B.C. Substituting the above into (1) gives\begin {align} w_{t}\left ( r,t\right ) +r\phi ^{\prime }\left ( t\right ) & =kw_{rr}\nonumber \\ w_{t}\left ( r,t\right ) & =kw_{rr}-r\phi ^{\prime }\left ( t\right ) \tag {2} \end {align}
With boundary conditions\begin {align*} w\left ( 0,t\right ) & =0\\ w\left ( a,t\right ) & =0 \end {align*}
The solution to the homogeneous PDE \(w_{t}\left ( r,t\right ) =kw_{rr}\) with the above boundary conditions is easily found and known. The eigenvalues are \(\lambda _{n}=\left ( \frac {n\pi }{a}\right ) ^{2},n=1,2,\cdots \) and eigenfunctions \(\Phi _{n}\left ( r\right ) =\sin \left ( \sqrt {\lambda _{n}}r\right ) \). Let the solution to (2), using eigenfunction expansion be\begin {equation} w\left ( r,t\right ) =\sum _{n=1}^{\infty }C_{n}\left ( t\right ) \Phi _{n}\left ( r\right ) \tag {2A} \end {equation} Substituting the above back into (2) gives\begin {equation} \sum _{n=1}^{\infty }C_{n}^{\prime }\left ( t\right ) \Phi _{n}\left ( r\right ) =k\sum _{n=1}^{\infty }C_{n}\left ( t\right ) \Phi _{n}^{\prime \prime }\left ( r\right ) -\sum _{n=1}^{\infty }q_{n}\left ( t\right ) \Phi _{n}\left ( r\right ) \tag {3} \end {equation} Where \(q_{n}\left ( t\right ) \) are the Fourier coefficients of \(r\phi ^{\prime }\left ( t\right ) \) which are found by\[ r\phi ^{\prime }\left ( t\right ) =\sum _{n=1}^{\infty }q_{n}\left ( t\right ) \Phi _{n}\left ( r\right ) \] Applying orthogonality using \(\Phi _{n}\left ( r\right ) \) gives\begin {align*} \int _{0}^{a}r\phi ^{\prime }\left ( t\right ) \Phi _{m}\left ( r\right ) dr & =\int _{0}^{a}\sum _{n=1}^{\infty }q_{n}\left ( t\right ) \Phi _{n}\left ( r\right ) \Phi _{m}\left ( r\right ) dr\\ & =\sum _{n=1}^{\infty }q_{n}\left ( t\right ) \int _{0}^{r}\Phi _{n}\left ( r\right ) \Phi _{m}\left ( r\right ) dr \end {align*}
But \(\int _{0}^{a}\Phi _{n}\left ( r\right ) \Phi _{m}\left ( r\right ) dr=\int _{0}^{a}\sin \left ( \frac {n\pi }{a}r\right ) \sin \left ( \frac {m\pi }{a}r\right ) dr=\frac {a}{2}\) for \(n=m\) only, and the above becomes\[ \frac {2}{a}\int _{0}^{a}r\phi ^{\prime }\left ( t\right ) \Phi _{m}\left ( s\right ) dr=q_{m}\left ( t\right ) \] Substituting the above back into (3) gives\[ \sum _{n=1}^{\infty }C_{n}^{\prime }\left ( t\right ) \Phi _{n}\left ( r\right ) =k\sum _{n=1}^{\infty }C_{n}\left ( t\right ) \Phi _{n}^{\prime \prime }\left ( r\right ) -\sum _{n=1}^{\infty }\left ( \frac {2}{a}\int _{0}^{a}r\phi ^{\prime }\left ( t\right ) \Phi _{m}\left ( r\right ) dr\right ) \Phi _{n}\left ( r\right ) \] But \(\Phi _{n}^{\prime \prime }\left ( r\right ) =-\lambda _{n}\Phi _{n}\left ( r\right ) \) and above simplifies to\begin {align*} \sum _{n=1}^{\infty }C_{n}^{\prime }\left ( t\right ) \Phi _{n}\left ( r\right ) +k\sum _{n=1}^{\infty }C_{n}\left ( t\right ) \lambda _{n}\Phi _{n}\left ( r\right ) & =-\sum _{n=1}^{\infty }\left ( \frac {2}{a}\int _{0}^{a}r\phi ^{\prime }\left ( t\right ) \Phi _{m}\left ( r\right ) dr\right ) \Phi _{n}\left ( r\right ) \\ C_{n}^{\prime }\left ( t\right ) +kC_{n}\left ( t\right ) \lambda _{n} & =-\frac {2}{a}\int _{0}^{a}r\phi ^{\prime }\left ( t\right ) \Phi _{m}\left ( r\right ) dr\\ & =-\frac {2}{a}\phi ^{\prime }\left ( t\right ) \int _{0}^{a}r\sin \left ( \frac {n\pi }{a}r\right ) dr\\ & =-\frac {2}{a}\phi ^{\prime }\left ( t\right ) \frac {\left ( -1\right ) ^{n+1}a^{2}}{n\pi }\\ & =-2a\phi ^{\prime }\left ( t\right ) \frac {\left ( -1\right ) ^{n+1}}{n\pi } \end {align*}
This is first order ODE in \(C\left ( t\right ) \). The solution is\[ C_{n}\left ( t\right ) =e^{-k\lambda _{n}t}C_{n}\left ( 0\right ) +2ae^{-k\lambda _{n}t}\frac {\left ( -1\right ) ^{n+1}}{n\pi }\int _{0}^{t}\phi ^{\prime }\left ( \tau \right ) e^{k\lambda _{n}\tau }d\tau \] From (2A)\[ w\left ( r,t\right ) =\sum _{n=1}^{\infty }\left ( e^{-k\lambda _{n}t}C_{n}\left ( 0\right ) +2ae^{-k\lambda _{n}t}\frac {\left ( -1\right ) ^{n+1}}{n\pi }\int _{0}^{t}\phi ^{\prime }\left ( \tau \right ) e^{k\lambda _{n}\tau }d\tau \right ) \sin \left ( \frac {n\pi }{a}r\right ) \] Hence \begin {align} u\left ( r,t\right ) & =w\left ( r,t\right ) +v\left ( r,t\right ) \nonumber \\ & =\sum _{n=1}^{\infty }\left ( e^{-k\lambda _{n}t}C_{n}\left ( 0\right ) +2ae^{-k\lambda _{n}t}\frac {\left ( -1\right ) ^{n+1}}{n\pi }\int _{0}^{t}\phi ^{\prime }\left ( \tau \right ) e^{k\lambda _{n}\tau }d\tau \right ) \sin \left ( \frac {n\pi }{a}r\right ) +r\phi \left ( t\right ) \tag {4} \end {align}
At \(t=0\) the above becomes\begin {align*} rf\left ( r\right ) & =\sum _{n=1}^{\infty }C_{n}\left ( 0\right ) \sin \left ( \frac {n\pi }{a}r\right ) +r\phi \left ( 0\right ) \\ \sum _{n=1}^{\infty }C_{n}\left ( 0\right ) \sin \left ( \frac {n\pi }{a}r\right ) & =r\left ( f\left ( r\right ) -\phi \left ( 0\right ) \right ) \end {align*}
Hence \(C_{n}\left ( 0\right ) \) is the Fourier sine coefficients of \(\ r\left ( f\left ( r\right ) -\phi \left ( 0\right ) \right ) \)\begin {align*} \frac {a}{2}C_{n}\left ( 0\right ) & =\int _{0}^{a}r\left ( f\left ( r\right ) -\phi \left ( 0\right ) \right ) \sin \left ( \frac {n\pi }{a}r\right ) dr\\ C_{n}\left ( 0\right ) & =\frac {2}{a}\int _{0}^{a}r\left ( f\left ( r\right ) -\phi \left ( 0\right ) \right ) \sin \left ( \frac {n\pi }{a}r\right ) dr \end {align*}
Substituting this into (4) gives the final solution as\begin {align*} u\left ( r,t\right ) & =r\phi \left ( t\right ) +\sum _{n=1}^{\infty }\left ( e^{-k\lambda _{n}t}\left ( \frac {2}{a}\int _{0}^{a}r\left ( f\left ( r\right ) -\phi \left ( 0\right ) \right ) \sin \left ( \frac {n\pi }{a}r\right ) dr\right ) +2ae^{-k\lambda _{n}t}\frac {\left ( -1\right ) ^{n+1}}{n\pi }\int _{0}^{t}\phi ^{\prime }\left ( \tau \right ) e^{k\lambda _{n}\tau }d\tau \right ) \sin \left ( \frac {n\pi }{a}r\right ) \\ & =r\phi \left ( t\right ) +\sum _{n=1}^{\infty }\left ( e^{-k\lambda _{n}t}\left ( \frac {2}{a}\int _{0}^{a}r\left ( f\left ( r\right ) -\phi \left ( 0\right ) \right ) \sin \left ( \frac {n\pi }{a}r\right ) dr\right ) +2a\frac {\left ( -1\right ) ^{n+1}}{n\pi }\int _{0}^{t}\phi ^{\prime }\left ( \tau \right ) e^{-k\lambda _{n}\left ( t-\tau \right ) }d\tau \right ) \sin \left ( \frac {n\pi }{a}r\right ) \\ & =r\phi \left ( t\right ) +\sum _{n=1}^{\infty }e^{-k\lambda _{n}t}\left ( \frac {2}{a}\int _{0}^{a}r\left ( f\left ( r\right ) -\phi \left ( 0\right ) \right ) \sin \left ( \frac {n\pi }{a}r\right ) dr\right ) \sin \left ( \frac {n\pi }{a}r\right ) +\sum _{n=1}^{\infty }2a\frac {\left ( -1\right ) ^{n+1}}{n\pi }\int _{0}^{t}\phi ^{\prime }\left ( \tau \right ) e^{-k\lambda _{n}\left ( t-\tau \right ) }d\tau \sin \left ( \frac {n\pi }{a}r\right ) \end {align*}
Or\begin {align*} u\left ( r,t\right ) & =r\phi \left ( t\right ) \\ & +\frac {2}{a}\sum _{n=1}^{\infty }e^{-k\lambda _{n}t}\sin \left ( \frac {n\pi }{a}r\right ) \left ( \int _{0}^{a}r\left ( f\left ( r\right ) -\phi \left ( 0\right ) \right ) \sin \left ( \frac {n\pi }{a}r\right ) dr\right ) \\ & +\frac {2a}{\pi }\sum _{n=1}^{\infty }\frac {\left ( -1\right ) ^{n+1}}{n}\sin \left ( \frac {n\pi }{a}r\right ) \int _{0}^{t}\phi ^{\prime }\left ( \tau \right ) e^{-k\lambda _{n}\left ( t-\tau \right ) }d\tau \end {align*}
Where \(\lambda _{n}=\left ( \frac {n\pi }{a}\right ) ^{2}\).
____________________________________________________________________________________
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[u, x, t,h,b]; 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]];
\[ \text {Failed} \]
Maple ✓
unassign('u,t,x,h,b'); 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'));
\[ \text {Bad Latex generated} \]
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 ) \]
____________________________________________________________________________________
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[u, x, t]; 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 4 e^{9 x/2} \sin (\pi x) \left (\frac {9}{2} e^{-\frac {1}{4} \left (81+16 \pi ^2\right ) t} \cos (\pi x)+\frac {1}{2} e^{-\frac {1}{4} \left (81+36 \pi ^2\right ) t} (2 \cos (2 \pi x)+1)+\frac {5}{4} e^{-\frac {1}{4} \left (81+4 \pi ^2\right ) t}\right )\right \}\right \} \]
Maple ✗
unassign('u,t,x'); 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'));
\[ \text {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*}
____________________________________________________________________________________
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[u, x, t, f]; 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]];
\[ \text {Failed} \]
Maple ✓
unassign('u,t,x,f'); 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 {n\pi \,\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 {n\pi \,\ln \left ( x \right ) }{\ln \left ( b \right ) }} \right ) }\,{\rm d}x} \right ) \]