#### 4.1.2 Finite domain (bar), left end homogeneous, right end not

4.1.2.6 [204] convection heat loss
4.1.2.7 [205] nonhomogeneous BC
4.1.2.8 [206] nonhomogeneous BC
4.1.2.9 [207] nonhomogeneous BC

##### 4.1.2.1 [199] left end insulated (general case)

problem number 199

Solve the heat equation

$u_t = k u_{xx}$

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

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

Mathematica

$\left \{\left \{u(x,t)\to \frac {2 \underset {n=0}{\overset {\infty }{\sum }}e^{-\frac {k (2 \pi n+\pi )^2 t}{4 L^2}} \cos \left (\frac {(2 n+1) \pi x}{2 L}\right ) \int _0^L \cos \left (\frac {(2 n+1) \pi K[2]}{2 L}\right ) (f(K[2])-\text {T0}) \, dK[2]}{L}+\text {T0}\right \}\right \}$

Maple

$u \left (x , t\right ) = \mathit {T0} +2 \left (\moverset {\infty }{\munderset {n =0}{\sum }}\frac {\left (\int _{0}^{L}\left (-\mathit {T0} +f \relax (x )\right ) \cos \left (\frac {\left (2 n +1\right ) \pi x}{2 L}\right )d x \right ) \cos \left (\frac {\left (2 n +1\right ) \pi x}{2 L}\right ) {\mathrm e}^{-\frac {\pi ^{2} \left (2 n +1\right )^{2} k t}{4 L^{2}}}}{L}\right )$

Hand solution

Solve $$u_{t}=ku_{xx}$$ with $$u\left (x,0\right ) =f\relax (x)$$ and $$u_{x}\left (0,t\right ) =0,u\left (L,t\right ) =T_{0}$$. Since the right end is not homogeneous, we need to ﬁnd a reference function. Let $$r\left ( x\right ) =Ax+B$$. Then $$r^{\prime }\relax (x) =A$$. Since $$u_{x}\left ( 0,t\right ) =0$$, then $$A=0$$. Hence $$r\relax (x) =B$$. Since $$u\left ( L,0\right ) =T_{0}$$, then $$r\relax (L) =T_{0}$$. Hence $$B=T_{0}$$. Therefore $$r\relax (x) =T_{0}$$. Now let the solution be\begin {equation} u\left (x,t\right ) =v\left (x,t\right ) +r\relax (x) \tag {1} \end {equation} Where $$v\left (x,t\right )$$ solves the same pde but with homogeneous boundary conditions\begin {align*} v_{t} & =kv_{xx}\\ v_{x}\left (0,t\right ) & =0\\ v\left (L,0\right ) & =0\\ v\left (x,0\right ) & =u\left (x,0\right ) -r\relax (x) \\ & =F\relax (x) \end {align*}

The above general PDE was solved in problem 4.1.1.28 on page 863 and the solution is$v\left (x,t\right ) =\frac {2}{L}\sum _{n=0}^{\infty }\left (\int _{0}^{L}F\relax (x) \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}$ Since here $$F\relax (x) =u\left (x,0\right ) -r\relax (x) =f\relax (x) -T_{0}$$ the above becomes\begin {equation} v\left (x,t\right ) =\frac {2}{L}\sum _{n=0}^{\infty }\left (\int _{0}^{L}\left (f\relax (x) -T_{0}\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}\tag {2} \end {equation} From (1,2) the ﬁnal solution is$u\left (x,t\right ) =T_{0}+\frac {2}{L}\sum _{n=0}^{\infty }\left (\int _{0}^{L}\left (f\relax (x) -T_{0}\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}$

________________________________________________________________________________________

##### 4.1.2.2 [200] left end insulated (special case)

problem number 200

Solve the heat equation

$u_t = k u_{xx}$

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

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

Mathematica

$\left \{\left \{u(x,t)\to \frac {2}{5} \left (\underset {n=0}{\overset {\infty }{\sum }}-\frac {100 e^{-\frac {(2 \pi n+\pi )^2 t}{10000}} \cos (n \pi ) \cos \left (\frac {1}{10} (2 n+1) \pi x\right )}{2 \pi n+\pi }+25\right )\right \}\right \}$

Maple

$u \left (x , t\right ) = -40 \left (\moverset {\infty }{\munderset {n =0}{\sum }}\frac {\left (-1\right )^{n} \cos \left (\frac {\left (2 n +1\right ) \pi x}{10}\right ) {\mathrm e}^{-\frac {\pi ^{2} \left (2 n +1\right )^{2} t}{10000}}}{\left (2 n +1\right ) \pi }\right )+10$

Hand solution

The general solution for this type of PDE is given in problem 4.1.1.28 on page 863 as$u\left (x,t\right ) =T_{0}+\frac {2}{L}\sum _{n=0}^{\infty }\left (\int _{0}^{L}\left (f\relax (x) -T_{0}\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}$ In this problem $$u\left (x,0\right ) =$$ $$f\relax (x) =0,L=5,k=\frac {1}{100}$$ and $$T_{0}=10$$, Hence the above becomes$u\left (x,t\right ) =10+\frac {2}{5}\sum _{n=0}^{\infty }\left (\int _{0}^{5}-10\cos \left (\frac {\left (2n+1\right ) \pi }{10}x\right ) dx\right ) \cos \left (\frac {\left (2n+1\right ) \pi }{10}x\right ) e^{-\frac {1}{100}\left (\frac {\left (2n+1\right ) \pi }{10}\right ) ^{2}t}$ But $$\int _{0}^{5}-10\cos \left (\frac {\left (2n+1\right ) \pi }{10}x\right ) dx=-\frac {100\cos \left (\pi n\right ) }{\pi \left (1+2n\right ) }=\frac {-100\left (-1\right ) ^{n}}{\pi \left (1+2n\right ) }$$ and the above becomes\begin {align*} u\left (x,t\right ) & =10+\frac {2}{5}\sum _{n=0}^{\infty }\frac {-100\left ( -1\right ) ^{n}}{\pi \left (1+2n\right ) }\cos \left (\frac {\left ( 2n+1\right ) \pi }{10}x\right ) e^{-\frac {1}{100}\left (\frac {\left ( 2n+1\right ) \pi }{10}\right ) ^{2}t}\\ & =10-\frac {40}{\pi }\sum _{n=0}^{\infty }\frac {\left (-1\right ) ^{n}}{\left ( 1+2n\right ) }\cos \left (\frac {\left (2n+1\right ) \pi }{10}x\right ) e^{-\frac {1}{100}\left (\frac {\left (2n+1\right ) \pi }{10}\right ) ^{2}t} \end {align*}

The following is an animation of the solution

Source code used for the above

________________________________________________________________________________________

##### 4.1.2.3 [201] right end nonhomogeneous BC (general case)

problem number 201

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

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

Mathematica

$\left \{\left \{u(x,t)\to \underset {n=1}{\overset {\infty }{\sum }}\frac {2 e^{-\frac {k n^2 \pi ^2 t}{L^2}} \left (\int _0^L \left (f(x)-\frac {\text {T0} x}{L}\right ) \sin \left (\frac {n \pi x}{L}\right ) \, dx\right ) \sin \left (\frac {n \pi x}{L}\right )}{L}+\frac {\text {T0} x}{L}\right \}\right \}$

Maple

$u \left (x , t\right ) = \frac {\mathit {T0} x}{L}+\left (\moverset {\infty }{\munderset {n =1}{\sum }}\frac {2 \left (\int _{0}^{L}\left (L f \relax (x )-\mathit {T0} x \right ) \sin \left (\frac {\pi n x}{L}\right )d x \right ) {\mathrm e}^{-\frac {\pi ^{2} k \,n^{2} t}{L^{2}}} \sin \left (\frac {\pi n x}{L}\right )}{L^{2}}\right )$

Hand solution

Since the right side boundary condition is not homogeneous, then we need to ﬁrst ﬁnd a reference function. Let $$r\relax (x) =Ax+B$$. At $$x=0,0=B$$. Hence $$r\relax (x) =Ax$$. At $$x=L,T_{0}=AL$$, hence $$A=\frac {T_{0}}{L}$$. Therefore $r\relax (x) =\frac {T_{0}}{L}x$ Now let $$u\left (x,t\right ) =v\left (x,t\right ) +r\relax (x)$$ where $$v_{t}=v_{xx}$$ but with homogeneous BC $$v\left (0,t\right ) =0,v\left ( L,0\right ) =0$$. The basic solution for this type of PDE was already given in problem 4.1.1.1 on page 741 as$v\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. Hence \begin {align} u\left (x,t\right ) & =r\relax (x) +v\left (x,t\right ) \nonumber \\ & =\frac {T_{0}}{L}x+\sum _{n=1}^{\infty }B_{n}e^{-k\lambda _{n}t}\sin \left ( \sqrt {\lambda _{n}}x\right ) \tag {1} \end {align}

At $$t=0$$$f\relax (x) -\frac {T_{0}}{L}x=\sum _{n=1}^{\infty }B_{n}e^{-k\lambda _{n}t}\sin \left (\sqrt {\lambda _{n}}x\right )$ Multiplying both sides by $$\sin \left (\sqrt {\lambda _{n^{\prime }}}x\right )$$ and integrating$\int _{0}^{L}\left (f\relax (x) -\frac {T_{0}}{L}x\right ) \sin \left ( \sqrt {\lambda _{n^{\prime }}}x\right ) dx=\int _{0}^{L}\sum _{n=1}^{\infty }B_{n}\sin \left (\sqrt {\lambda _{n^{\prime }}}x\right ) \sin \left ( \sqrt {\lambda }x\right ) dx$ Moving integration inside summation and by orthogonality of $$\sin$$ function the above reduces to\begin {align*} \int _{0}^{L}\left (f\relax (x) -\frac {T_{0}}{L}x\right ) \sin \left ( \sqrt {\lambda _{n}}x\right ) dx & =B_{n}\int _{0}^{L}\sin ^{2}\left (\frac {n\pi }{L}x\right ) dx\\ \int _{0}^{L}\left (f\relax (x) -\frac {T_{0}}{L}x\right ) \sin \left ( \sqrt {\lambda _{n}}x\right ) dx & =\frac {L}{2}B_{n}\\ B_{n} & =\frac {2}{L}\int _{0}^{L}\left (f\relax (x) -\frac {T_{0}}{L}x\right ) \sin \left (\sqrt {\lambda _{n}}x\right ) dx \end {align*}

Therefore the solution from (1) is$u\left (x,t\right ) =\frac {T_{0}}{L}x+\frac {2}{L}\sum _{n=1}^{\infty }\left ( \int _{0}^{L}\left (f\relax (x) -\frac {T_{0}}{L}x\right ) \sin \left ( \sqrt {\lambda _{n}}x\right ) dx\right ) e^{-k\lambda _{n}t}\sin \left ( \sqrt {\lambda _{n}}x\right )$

________________________________________________________________________________________

##### 4.1.2.4 [202] right end nonhomogeneous BC (special case)

problem number 202

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

Initial condition is $$u(x,0)=f(x)$$ using these values \begin {align*} k&=\frac {1}{100}\\ L&=100\\ T_0&=100\\ f(x)&=x \end {align*}

Mathematica

$\{\{u(x,t)\to x\}\}$

Maple

$u \left (x , t\right ) = x$

Hand solution

The general solution for this type of PDE is given in problem 4.1.2.3 on page 958 as$u\left (x,t\right ) =\frac {T_{0}}{L}x+\frac {2}{L}\sum _{n=1}^{\infty }\left ( \int _{0}^{L}\left (f\relax (x) -\frac {T_{0}}{L}x\right ) \sin \left ( \sqrt {\lambda _{n}}x\right ) dx\right ) e^{-k\lambda _{n}t}\sin \left ( \sqrt {\lambda _{n}}x\right )$ With $$\lambda _{n}=\left (\frac {n\pi }{L}\right ) ^{2},n=1,2,3,\cdots$$. In this problem \begin {align*} L & =100\\ k & =\frac {1}{100}\\ T_{0} & =100\\ f\relax (x) & =x \end {align*}

Hence the solution becomes\begin {align*} u\left (x,t\right ) & =x+\frac {2}{100}\sum _{n=1}^{\infty }\left (\int _{0}^{100}\left (x-x\right ) \sin \left (\frac {n\pi }{100}x\right ) dx\right ) e^{-\frac {1}{100}\left (\frac {n\pi }{100}\right ) ^{2}t}\sin \left (\frac {n\pi }{100}x\right ) \\ & =x+0\\ & =x \end {align*}

________________________________________________________________________________________

##### 4.1.2.5 [203] right end nonhomogeneous BC, special case

problem number 203

Added July 2, 2018. Can not ﬁnd where I found this PDE.

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) &= 1 \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

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

Maple

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

Hand solution

The general solution for this type of PDE is given in problem 4.1.2.3 on page 958 as$u\left (x,t\right ) =\frac {T_{0}}{L}x+\frac {2}{L}\sum _{n=1}^{\infty }\left ( \int _{0}^{L}\left (f\relax (x) -\frac {T_{0}}{L}x\right ) \sin \left ( \sqrt {\lambda _{n}}x\right ) dx\right ) e^{-k\lambda _{n}t}\sin \left ( \sqrt {\lambda _{n}}x\right )$ With $$\lambda _{n}=\left (\frac {n\pi }{L}\right ) ^{2},n=1,2,3,\cdots$$. In this problem \begin {align*} L & =1\\ k & =1\\ T_{0} & =1\\ f\relax (x) & =\left \{ \begin {array} [c]{ccc}1 & & x=1\\ 0 & & \text {otherwise}\end {array} \right . \end {align*}

Hence the solution becomes\begin {equation} u\left (x,t\right ) =x+2\sum _{n=1}^{\infty }\left (\int _{0}^{1}\left ( f\relax (x) -x\right ) \sin \left (n\pi x\right ) dx\right ) e^{-\left (n\pi \right ) ^{2}t}\sin \left (n\pi x\right ) \tag {1} \end {equation} But\begin {align*} \int _{0}^{1}\left (f\relax (x) -x\right ) \sin \left (n\pi x\right ) dx & =\int _{0}^{1}f\relax (x) \sin \left (n\pi x\right ) dx-\int _{0}^{1}x\sin \left (n\pi x\right ) dx\\ & =0-\int _{0}^{1}x\sin \left (n\pi x\right ) dx \end {align*}

$$\int _{0}^{1}x\sin \left (n\pi x\right ) dx=\frac {\left (-1\right ) ^{n+1}}{n\pi }$$, hence \begin {align*} \int _{0}^{1}\left (f\relax (x) -x\right ) \sin \left (n\pi x\right ) dx & =-\frac {\left (-1\right ) ^{n+1}}{n\pi }\\ & =\frac {\left (-1\right ) ^{n}}{n\pi } \end {align*}

Therefore (1) becomes$u\left (x,t\right ) =x+2\sum _{n=1}^{\infty }\frac {\left (-1\right ) ^{n}}{n\pi }e^{-\left (n\pi \right ) ^{2}t}\sin \left (n\pi x\right )$ This is animation of the solution for $$0.3$$ seconds. (Animation will show only in the HTML version).

Source code used for the above

________________________________________________________________________________________

##### 4.1.2.6 [204] convection heat loss

problem number 204

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

$\left \{\left \{u(x,t)\to \begin {array}{cc} \{ & \begin {array}{cc} x^2+\underset {K[1]=1}{\overset {\infty }{\sum }}\frac {\sqrt {2} \sqrt {h} \left (\frac {\sqrt {2} e^{-t K[2,K[1]]} \left (2 h+\cos \left (\sqrt {K[2,K[1]]}\right ) ((h-2) K[2,K[1]]-2 h)-\sqrt {K[2,K[1]]} (2 h+K[2,K[1]]-2) \sin \left (\sqrt {K[2,K[1]]}\right )\right )}{K[2,K[1]]^{3/2} \sqrt {h \left (-\cos ^2\left (\sqrt {K[2,K[1]]}\right )+h+2\right )+\frac {\left (h-\cos ^2\left (\sqrt {K[2,K[1]]}\right )\right ) K[2,K[1]]}{h}}}-\frac {2 \sqrt {2} \left (1-e^{-t K[2,K[1]]}\right ) \left (h \left (\cos \left (\sqrt {K[2,K[1]]}\right )-1\right )-\sqrt {K[2,K[1]]} \sin \left (\sqrt {K[2,K[1]]}\right )\right )}{K[2,K[1]]^{3/2} \sqrt {h \left (-\cos ^2\left (\sqrt {K[2,K[1]]}\right )+h+2\right )+\frac {\left (h-\cos ^2\left (\sqrt {K[2,K[1]]}\right )\right ) K[2,K[1]]}{h}}}\right ) \left (\sqrt {K[2,K[1]]} \cos \left (x \sqrt {K[2,K[1]]}\right )+h \sin \left (x \sqrt {K[2,K[1]]}\right )\right )}{\sqrt {h^3-\cos ^2\left (\sqrt {K[2,K[1]]}\right ) h^2+2 h^2+K[2,K[1]] h-\cos ^2\left (\sqrt {K[2,K[1]]}\right ) K[2,K[1]]}} & h \tan \left (\sqrt {K[2,K[1]]}\right )+\sqrt {K[2,K[1]]}=0\land K[1]\in \mathbb {Z}\land K[1]\geq 1\land K[2,K[1]]>0 \\ \text {Indeterminate} & \text {True} \\\end {array} \\\end {array}\right \}\right \}$

Maple

time expired

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\relax (x)$$.

Because the second B.C. is not zero, we need to introduce a reference function $$r\relax (x)$$ which satisﬁes the nonhomogeneous boundary conditions.

Let $$r\relax (x) =Ax+B$$. When $$x=0$$ then the ﬁrst BC gives$A-hB=0$ And the second BC gives$A+B=1$ From the ﬁrst 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\relax (x) & =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\relax (0) =\frac {1}{1+h}$$. Hence $$r_{x}\relax (0) -hr\relax (0) =\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\relax (x)$$ then we write$u\left (x,t\right ) =v\left (x,t\right ) +r\relax (x)$ 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 }\relax (0) -hX\relax (0) & =0\\ X\relax (1) & =0 \end {align*}

The above is known eigenvalue problem which we found before. It has the following eigenfunctions and eigenvalues\begin {align*} \phi _{n}\relax (x) & =\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}\relax (t) \phi _{n}\relax (x) \tag {2} \end {equation} Substituting into the PDE $$v_{t}=v_{xx}$$ gives\begin {align*} \sum _{n=1}^{\infty }B_{n}^{\prime }\relax (t) \phi _{n}\relax (x) & =\sum _{n=1}^{\infty }B_{n}\relax (t) \phi _{n}^{\prime \prime }\left ( x\right ) \\ & =-\sum _{n=1}^{\infty }B_{n}\relax (t) \alpha _{n}^{2}\phi _{n}\left ( x\right ) \end {align*}

Therefore the ODE is$B_{n}^{\prime }\relax (t) +\alpha _{n}^{2}B_{n}\relax (t) =0$ The solution is $B_{n}\relax (t) =B_{n}\relax (0) e^{-\alpha _{n}^{2}t}$ Hence (2) becomes$v\left (x,t\right ) =\sum _{n=1}^{\infty }B_{n}\relax (0) e^{-\alpha _{n}^{2}t}\phi _{n}\relax (x)$ And since $$u\left (x,t\right ) =v\left (x,t\right ) +r\relax (x)$$ then$u\left (x,t\right ) =\sum _{n=1}^{\infty }B_{n}\relax (0) e^{-\alpha _{n}^{2}t}\phi _{n}\relax (x) +\frac {hx+1}{1+h}$ Now we ﬁnd $$B_{n}\relax (0)$$ from initial conditions. At $$t=0$$ the above becomes\begin {align*} 0 & =\sum _{n=1}^{\infty }B_{n}\relax (0) \phi _{n}\relax (x) +\frac {hx+1}{1+h}\\ -\frac {hx+1}{1+h} & =\sum _{n=1}^{\infty }B_{n}\relax (0) \phi _{n}\relax (x) \end {align*}

Hence \begin {align} B_{n}\relax (0) & =\left \langle -\frac {hx+1}{1+h},\phi _{n}\left ( x\right ) \right \rangle \nonumber \\ & =-\int _{0}^{1}p\relax (x) \frac {hx+1}{1+h}\phi _{n}\relax (x) 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 simpliﬁes 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}\relax (0) & =\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 ﬁnal 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}\relax (x) \\ & =\frac {hx+1}{1+h}+\sum _{n=1}^{\infty }B_{n}\relax (0) \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*}

________________________________________________________________________________________

##### 4.1.2.7 [205] nonhomogeneous BC

problem number 205

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

Failed

Maple

$u \left (x , t\right ) = \frac {x^{2}}{2}+13 t +2 \left (\moverset {\infty }{\munderset {n =1}{\sum }}\frac {\left (\left (-1\right )^{n}-1\right ) \cos \left (\pi n x \right ) {\mathrm e}^{-13 \pi ^{2} n^{2} t}}{\pi ^{2} n^{2}}\right )+\frac {1}{2}$

________________________________________________________________________________________

##### 4.1.2.8 [206] nonhomogeneous BC

problem number 206

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

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

Maple

$u \left (x , t\right ) = A x +\moverset {\infty }{\munderset {n =0}{\sum }}\left (-\frac {8 A \left (-1\right )^{n} {\mathrm e}^{-\frac {\left (2 n +1\right )^{2} t}{4}} \sin \left (n x +\frac {1}{2} x \right )}{\pi \left (2 n +1\right )^{2}}\right )$

________________________________________________________________________________________

##### 4.1.2.9 [207] nonhomogeneous BC

problem number 207

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

$\left \{\left \{u(r,t)\to \underset {K[1]=1}{\overset {\infty }{\sum }}\sqrt {2} \sqrt {\frac {1}{a}} \left (e^{-\frac {k \pi ^2 t K[1]^2}{a^2}} \int _0^a \sqrt {2} \sqrt {\frac {1}{a}} r (f(r)-\phi (0)) \sin \left (\frac {\pi r K[1]}{a}\right ) \, dr+\int _0^t \frac {(-1)^{K[1]} \sqrt {2} e^{-\frac {k \pi ^2 K[1]^2 (t-K[2])}{a^2}} \phi '(K[2])}{\left (\frac {1}{a}\right )^{3/2} \pi K[1]} \, dK[2]\right ) \sin \left (\frac {\pi r K[1]}{a}\right )+r \phi (t)\right \}\right \}$

Maple

$u \left (r , t\right ) = r \phi \relax (t )+\int _{0}^{t}\left (\moverset {\infty }{\munderset {n =1}{\sum }}\frac {2 a \left (-1\right )^{n} \left (\frac {d}{d \tau }\phi \left (\tau \right )\right ) {\mathrm e}^{-\frac {\pi ^{2} \left (t -\tau \right ) k \,n^{2}}{a^{2}}} \sin \left (\frac {\pi n r}{a}\right )}{\pi n}\right )d \tau +\left (\moverset {\infty }{\munderset {n =1}{\sum }}\frac {2 \left (\int _{0}^{a}\left (f \relax (r )-\phi \relax (0)\right ) r \sin \left (\frac {\pi n r}{a}\right )d r \right ) {\mathrm e}^{-\frac {\pi ^{2} k \,n^{2} t}{a^{2}}} \sin \left (\frac {\pi n r}{a}\right )}{a}\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 \relax (t) \end {align*}

And initial conditions$u\left (r,0\right ) =rf\relax (r)$ Since the boundary conditions are not homogeneous, the ﬁrst 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 \relax (t)$$. Now we write$u\left (r,t\right ) =w\left (r,t\right ) +v\left (r,t\right )$ Where $$w\left (r,t\right )$$ satisﬁes the PDE but with homogeneous B.C. Substituting the above into (1) gives\begin {align} w_{t}\left (r,t\right ) +r\phi ^{\prime }\relax (t) & =kw_{rr}\nonumber \\ w_{t}\left (r,t\right ) & =kw_{rr}-r\phi ^{\prime }\relax (t) \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}\relax (r) =\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}\relax (t) \Phi _{n}\relax (r) \tag {2A} \end {equation} Substituting the above back into (2) gives\begin {equation} \sum _{n=1}^{\infty }C_{n}^{\prime }\relax (t) \Phi _{n}\relax (r) =k\sum _{n=1}^{\infty }C_{n}\relax (t) \Phi _{n}^{\prime \prime }\left ( r\right ) -\sum _{n=1}^{\infty }q_{n}\relax (t) \Phi _{n}\relax (r) \tag {3} \end {equation} Where $$q_{n}\relax (t)$$ are the Fourier coeﬃcients of $$r\phi ^{\prime }\relax (t)$$ which are found by$r\phi ^{\prime }\relax (t) =\sum _{n=1}^{\infty }q_{n}\relax (t) \Phi _{n}\relax (r)$ Applying orthogonality using $$\Phi _{n}\relax (r)$$ gives\begin {align*} \int _{0}^{a}r\phi ^{\prime }\relax (t) \Phi _{m}\relax (r) dr & =\int _{0}^{a}\sum _{n=1}^{\infty }q_{n}\relax (t) \Phi _{n}\left ( r\right ) \Phi _{m}\relax (r) dr\\ & =\sum _{n=1}^{\infty }q_{n}\relax (t) \int _{0}^{r}\Phi _{n}\left ( r\right ) \Phi _{m}\relax (r) dr \end {align*}

But $$\int _{0}^{a}\Phi _{n}\relax (r) \Phi _{m}\relax (r) 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 }\relax (t) \Phi _{m}\left ( s\right ) dr=q_{m}\relax (t)$ Substituting the above back into (3) gives$\sum _{n=1}^{\infty }C_{n}^{\prime }\relax (t) \Phi _{n}\relax (r) =k\sum _{n=1}^{\infty }C_{n}\relax (t) \Phi _{n}^{\prime \prime }\left ( r\right ) -\sum _{n=1}^{\infty }\left (\frac {2}{a}\int _{0}^{a}r\phi ^{\prime }\relax (t) \Phi _{m}\relax (r) dr\right ) \Phi _{n}\left ( r\right )$ But $$\Phi _{n}^{\prime \prime }\relax (r) =-\lambda _{n}\Phi _{n}\left ( r\right )$$ and above simpliﬁes to\begin {align*} \sum _{n=1}^{\infty }C_{n}^{\prime }\relax (t) \Phi _{n}\relax (r) +k\sum _{n=1}^{\infty }C_{n}\relax (t) \lambda _{n}\Phi _{n}\left ( r\right ) & =-\sum _{n=1}^{\infty }\left (\frac {2}{a}\int _{0}^{a}r\phi ^{\prime }\relax (t) \Phi _{m}\relax (r) dr\right ) \Phi _{n}\relax (r) \\ C_{n}^{\prime }\relax (t) +kC_{n}\relax (t) \lambda _{n} & =-\frac {2}{a}\int _{0}^{a}r\phi ^{\prime }\relax (t) \Phi _{m}\left ( r\right ) dr\\ & =-\frac {2}{a}\phi ^{\prime }\relax (t) \int _{0}^{a}r\sin \left ( \frac {n\pi }{a}r\right ) dr\\ & =-\frac {2}{a}\phi ^{\prime }\relax (t) \frac {\left (-1\right ) ^{n+1}a^{2}}{n\pi }\\ & =-2a\phi ^{\prime }\relax (t) \frac {\left (-1\right ) ^{n+1}}{n\pi } \end {align*}

This is ﬁrst order ODE in $$C\relax (t)$$. The solution is$C_{n}\relax (t) =e^{-k\lambda _{n}t}C_{n}\relax (0) +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}\relax (0) +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}\relax (0) +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 \relax (t) \tag {4} \end {align}

At $$t=0$$ the above becomes\begin {align*} rf\relax (r) & =\sum _{n=1}^{\infty }C_{n}\relax (0) \sin \left ( \frac {n\pi }{a}r\right ) +r\phi \relax (0) \\ \sum _{n=1}^{\infty }C_{n}\relax (0) \sin \left (\frac {n\pi }{a}r\right ) & =r\left (f\relax (r) -\phi \relax (0) \right ) \end {align*}

Hence $$C_{n}\relax (0)$$ is the Fourier sine coeﬃcients of $$\ r\left (f\relax (r) -\phi \relax (0) \right )$$\begin {align*} \frac {a}{2}C_{n}\relax (0) & =\int _{0}^{a}r\left (f\relax (r) -\phi \relax (0) \right ) \sin \left (\frac {n\pi }{a}r\right ) dr\\ C_{n}\relax (0) & =\frac {2}{a}\int _{0}^{a}r\left (f\relax (r) -\phi \relax (0) \right ) \sin \left (\frac {n\pi }{a}r\right ) dr \end {align*}

Substituting this into (4) gives the ﬁnal solution as\begin {align*} u\left (r,t\right ) & =r\phi \relax (t) +\sum _{n=1}^{\infty }\left ( e^{-k\lambda _{n}t}\left (\frac {2}{a}\int _{0}^{a}r\left (f\relax (r) -\phi \relax (0) \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 \relax (t) +\sum _{n=1}^{\infty }\left (e^{-k\lambda _{n}t}\left (\frac {2}{a}\int _{0}^{a}r\left (f\relax (r) -\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 \relax (t) +\sum _{n=1}^{\infty }e^{-k\lambda _{n}t}\left ( \frac {2}{a}\int _{0}^{a}r\left (f\relax (r) -\phi \relax (0) \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 \relax (t) \\ & +\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\relax (r) -\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}$$.

________________________________________________________________________________________