Solve the heat equation
For \(-L<x<L\) and \(t>0\). The boundary conditions are periodic
And initial conditions \(u(x,0)=f(x)\)
Mathematica ✓
ClearAll["Global`*"]; 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]];
Maple ✓
restart; 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'));
___________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
Added Sept 21, 2019
Solve the heat equation
For \(-\pi <x<\pi \) and \(t>0\). The boundary conditions are periodic
No initial conditions give.
Mathematica ✓
ClearAll["Global`*"]; pde = D[u[x, t], t] == k*D[u[x, t], {x, 2}]; bc = {u[-Pi, t] == u[Pi, t], Derivative[1, 0][u][-Pi, t] == Derivative[1, 0][u][Pi, t]}; sol = AbsoluteTiming[TimeConstrained[DSolve[{pde, bc}, u[x, t], {x, t}], 60*10]];
Maple ✗
restart; interface(showassumed=0); pde := diff(u(x,t),t)=k*diff(u(x,t),x$2); bc := u(-Pi,t)=u(Pi,t),D[1](u)(-Pi,0)=D[1](u)(Pi,0); cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol',pdsolve([pde,bc],u(x,t)) ),output='realtime'));
sol=()
Hand solution
Solve the heat equation \(u_{t}=ku_{xx}\) with periodic boundary conditions \(u\left ( t,-\pi \right ) =u\left ( t,\pi \right ) ,u_{x}\left ( t,-\pi \right ) =u_{x}\left ( t,\pi \right ) \)
Solution
Using separation of variables, Let \(u\left ( x,t\right ) =T\left ( t\right ) X\left ( x\right ) \). Substituting this into \(u_{t}=ku_{xx}\) gives \(T^{\prime }X=TX^{\prime \prime }\). Dividing by \(XT\neq 0\) gives
Where \(\lambda \) is the seperation constant. This gives the following ODE’s to solve
Where \(\lambda \) is the separation constant. Eigenfunctions are solutions to the spatial ODE.
To determine the actual eigenfunctions and eigenvalues, boundary conditions are used. Starting with the spatial ODE above, and transferring the boundary condition to \(X\), it becomes
This is an eigenvalue boundary value problem. The solution is
Since \(\lambda <0\), then \(-\lambda \) is positive. Let \(\mu =-\lambda \), where \(\mu \) is now positive. The solution (1) becomes
The above can be written as
Applying first B.C. \(X\left ( -\pi \right ) =X\left ( \pi \right ) \) using (2) gives
But \(\sinh \) is only zero when its argument is zero which is not the case here. Therefore the above implies that \(c_{2}=0\). The solution (2) now reduces to
Applying the second BC \(X^{\prime }\left ( -\pi \right ) =X^{\prime }\left ( \pi \right ) \) using (4) gives
But \(\sinh \) is only zero when its argument is zero which is not the case here. Therefore the above implies that \(c_{1}=0\). This means a trivial solution. Therefore \(\lambda <0\) is not an eigenvalue.
case \(\lambda =0\)
In this case the solution is \(X\left ( x\right ) =c_{1}+c_{2}x\). Applying first BC \(X\left ( -\pi \right ) =X\left ( \pi \right ) \) gives
This gives \(c_{2}=0\). The solution now becomes \(X\left ( x\right ) =c_{1}\) and \(X^{\prime }\left ( x\right ) =0\). Applying the second boundary conditions \(X^{\prime }\left ( -\pi \right ) =X^{\prime }\left ( \pi \right ) \) is not satisfies (\(0=0\)). Therefore \(\lambda =0\) is an eigenvalue with eigenfunction \(X_{0}\left ( 0\right ) =1\) (selected \(c_{1}=1\) since an arbitrary constant).
case \(\lambda >0\)
The solution in this case is
Which can be rewritten as (the constants \(c_{1},c_{2}\) below will be different than the above \(c_{1},c_{2}\), but kept the same name for simplicity).
Applying first B.C. \(X\left ( -\pi \right ) =X\left ( \pi \right ) \) using the above gives
There are two choices here. If \(\sin \left ( -\sqrt {\lambda }\pi \right ) \neq \sin \left ( \sqrt {\lambda }\pi \right ) \), then this implies that \(c_{2}=0\). If \(\sin \left ( -\sqrt {\lambda }\pi \right ) =\sin \left ( \sqrt {\lambda }\pi \right ) \) then \(c_{2}\neq 0\). Assuming for now that \(\sin \left ( -\sqrt {\lambda }\pi \right ) =\sin \left ( \sqrt {\lambda }\pi \right ) \). This happens when \(\sqrt {\lambda }\pi =n\pi ,n=1,2,3,\cdots \), or
Using this choice, we will now look to see what happens using the second BC. The solution (5) now becomes
Therefore
Applying the second BC \(X^{\prime }\left ( -\pi \right ) =X^{\prime }\left ( \pi \right ) \) using the above gives
Since \(n\) is integer. Therefore this means that using \(\lambda _{n}=n^{2}\) will satisfy both boundary conditions with \(c_{2}\neq 0,c_{1}\neq 0\). This means the solution (5) becomes
The above says that there are two eigenfunctions in this case. They are
Since there is also zero eigenvalue, then the complete set of eigenfunctions become
Now that the eigenvalues are found, the solution to the time ODE can be found. Recalling that the time ODE from above was found to be
For the zero eigenvalue case, the above reduces to \(T^{\prime }\left ( t\right ) =0\) which has the solution \(T_{0}\left ( t\right ) =C_{0}\). For non zero eigenvalues \(\lambda _{n}=n^{2}\), the ODE becomes \(T^{\prime }\left ( t\right ) +n^{2}T\left ( t\right ) =0\), whose solution is \(T_{0}\left ( t\right ) =C_{n}e^{-kn^{2}t}\).
Putting all the above together, gives the fundamental solution as
Therefore the complete solution is the sum of the above solutions
The constants \(C_{0},C_{n},B_{n}\) can be found from initial conditions.
___________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
Added Sept 21, 2019
Solve the heat equation
For \(-\pi <x<\pi \) and \(t>0\). The boundary conditions are periodic
No initial conditions give.
Mathematica ✗
ClearAll["Global`*"]; pde = D[u[x, t], t] == k*D[u[x, t], {x, 2}] -u[x,t]; bc = {u[-Pi, t] == u[Pi, t], Derivative[1, 0][u][-Pi, t] == Derivative[1, 0][u][Pi, t]}; sol = AbsoluteTiming[TimeConstrained[DSolve[{pde, bc}, u[x, t], {x, t}], 60*10]];
Failed
Maple ✗
restart; interface(showassumed=0); pde := diff(u(x,t),t)=k*diff(u(x,t),x$2)-u(x,t); bc := u(-Pi,t)=u(Pi,t),D[1](u)(-Pi,0)=D[1](u)(Pi,0); cpu_time := timelimit(60*10,CodeTools[Usage](assign('sol',pdsolve([pde,bc],u(x,t)) ),output='realtime'));
sol=()
Hand solution
Solve the heat equation \(u_{t}=ku_{xx}-u\) with periodic boundary conditions \(u\left ( t,-\pi \right ) =u\left ( t,\pi \right ) ,u_{x}\left ( t,-\pi \right ) =u_{x}\left ( t,\pi \right ) \)
Solution
Using separation of variables, Let \(u\left ( x,t\right ) =T\left ( t\right ) X\left ( x\right ) \). Substituting this into \(u_{t}=ku_{xx}\) gives \(T^{\prime }X=TX^{\prime \prime }\). Dividing by \(XT\neq 0\) gives
Where \(\lambda \) is the seperation constant. This gives the following ODE’s to solve
Where \(\lambda \) is the separation constant. Eigenfunctions are solutions to the spatial ODE.
To determine the actual eigenfunctions and eigenvalues, boundary conditions are used. Transferring the boundary condition to \(X\), it becomes
This is an eigenvalue boundary value problem. The solution is
Since \(\lambda <0\), then \(-\lambda \) is positive. Let \(\mu =-\lambda \), where \(\mu \) is now positive. The solution (1) becomes
The above can be written as
Applying first B.C. \(X\left ( -\pi \right ) =X\left ( \pi \right ) \) using (2) gives
But \(\sinh \) is only zero when its argument is zero which is not the case here. Therefore the above implies that \(c_{2}=0\). The solution (2) now reduces to
Applying the second BC \(X^{\prime }\left ( -\pi \right ) =X^{\prime }\left ( \pi \right ) \) using (4) gives
But \(\sinh \) is only zero when its argument is zero which is not the case here. Therefore the above implies that \(c_{1}=0\). This means a trivial solution. Therefore \(\lambda <0\) is not an eigenvalue.
case \(\lambda =0\)
In this case the solution is \(X\left ( x\right ) =c_{1}+c_{2}x\). Applying first BC \(X\left ( -\pi \right ) =X\left ( \pi \right ) \) gives
This gives \(c_{2}=0\). The solution now becomes \(X\left ( x\right ) =c_{1}\) and \(X^{\prime }\left ( x\right ) =0\). Applying the second boundary conditions \(X^{\prime }\left ( -\pi \right ) =X^{\prime }\left ( \pi \right ) \) is not satisfies (\(0=0\)). Therefore \(\lambda =0\) is an eigenvalue with eigenfunction \(X_{0}\left ( 0\right ) =1\) (selected \(c_{1}=1\) since an arbitrary constant).
case \(\lambda >0\)
The solution in this case is
Which can be rewritten as (the constants \(c_{1},c_{2}\) below will be different than the above \(c_{1},c_{2}\), but kept the same name for simplicity).
Applying first B.C. \(X\left ( -\pi \right ) =X\left ( \pi \right ) \) using the above gives
There are two choices here. If \(\sin \left ( -\sqrt {\lambda }\pi \right ) \neq \sin \left ( \sqrt {\lambda }\pi \right ) \), then this implies that \(c_{2}=0\). If \(\sin \left ( -\sqrt {\lambda }\pi \right ) =\sin \left ( \sqrt {\lambda }\pi \right ) \) then \(c_{2}\neq 0\). Assuming for now that \(\sin \left ( -\sqrt {\lambda }\pi \right ) =\sin \left ( \sqrt {\lambda }\pi \right ) \). Then happens when \(\sqrt {\lambda }\pi =n\pi ,n=1,2,3,\cdots \), or
Using this choice, we will now look to see what happens using the second BC. The solution (5) now becomes
Therefore
Applying the second BC \(X^{\prime }\left ( -\pi \right ) =X^{\prime }\left ( \pi \right ) \) using the above gives
Since \(n\) is integer. Therefore this means that using \(\lambda _{n}=n^{2}\) will satisfy both boundary conditions with \(c_{2}\neq 0,c_{1}\neq 0\). This means the solution (5) becomes
The above says that there are two eigenfunctions in this case. They are
Since there is also zero eigenvalue, then the complete set of eigenfunctions become
Now that the eigenvalues are found, the solution to the time ODE can be found. Recalling that the time ODE from above was found to be
For the zero eigenvalue case, the above reduces to \(T^{\prime }\left ( t\right ) +kT\left ( t\right ) =0\) which has the solution \(T_{0}\left ( t\right ) =C_{0}e^{-kt}\). For non zero eigenvalues \(\lambda _{n}=n^{2}\), the ODE becomes \(T^{\prime }\left ( t\right ) +k\left ( n^{2}+1\right ) T\left ( t\right ) =0\), whose solution is \(T_{0}\left ( t\right ) =C_{n}e^{-k\left ( n^{2}+1\right ) t}\).
Putting all the above together, gives the fundamental solution as
Therefore the complete solution is the sum of the above solutions
The constants \(C_{0},C_{n},B_{n}\) can be found from initial conditions.
___________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________