3
$\begingroup$

I was trying to verify my hand solution using Mathematica for this problem

$$ y^{\prime\prime}+\lambda y=0 $$

The domain is $0<x<L$ and the boundary conditions are

\begin{align*} y(0)+y^{\prime}(0)&=0\\ y(L)+y^{\prime}(L)&=0 \end{align*}

My hand solution gives these eigenvalues

$$ \lambda=\left\{ -1,\frac{\pi^{2}}{L^{2}},\frac{4\pi^{2}}{L^{2}},\frac {9\pi^{2}}{L^{2}},\frac{16\pi^{2}}{L^{2}},\cdots\right\} $$

Mathematica agrees with the above, but it also claims zero is an eigenvalue

$$ \lambda=\left\{ -1,0,\frac{\pi^{2}}{L^{2}},\frac{4\pi^{2}}{L^{2}},\frac {9\pi^{2}}{L^{2}},\frac{16\pi^{2}}{L^{2}},\cdots\right\} $$

Which I think is wrong. zero should not be an eigenvalue.

The question is: Is Mathematica result wrong? Am I reading Mathematica output wrong?

Mathematica output

ClearAll[L0, x, y, lam];
bc = {y'[0] + y[0] == 0, y'[L0] + y[L0] == 0};
Assuming[L0 > 0 && Element[lam, Reals], 
 DSolve[{y''[x] + lam y[x] == 0, bc}, y[x], x]]

Mathematica graphics

The problem that I see is $n\geq 0$ in the above. Using the above result:

 tab1 = Table[(4*n^2*Pi^2)/L0^2, {n, 0, 4}];    
 tab2 = Table[(Pi^2 + 4*n*Pi^2 + 4*n^2*Pi^2)/L0^2, {n, 0, 4}]; 
 Union[tab1,tab2]

Mathematica graphics

You see zero eigenvalue shows up, from applying it to (4 n^2 Pi^2)/L0^2. Mathematica result will match my hand solution if it said $n>0$ for (4 n^2 Pi^2)/L0^2 and said $n\geq 0$ for the second part (Pi^2 + 4 n Pi^2 + 4 n^2 Pi^2)/L0^2:

tab1 = Table[(4*n^2*Pi^2)/L0^2, {n, 1, 4}]; (*fixed. make it start from 1*)
tab2 = Table[(Pi^2 + 4*n*Pi^2 + 4*n^2*Pi^2)/L0^2, {n, 0, 4}]; 
Union[tab1,tab2]

Mathematica graphics

Version 11.2 on windows 7.

Update

TO answer comment below, Here is the hand solution. The question was just misunderstanding on my part reading result of DSolve, since $\lambda=0$ can not be an eigenvalue, but it also showed there in the solution to DSolve, so I was asking why.

But DSolve is allowed to return trivial solution $y(x)=0$ which is not allowed when finding the eigenvalues. Lesson of the day: Use DEigenvalues to find eigenvalues instead of DSolve.

NDEigenvalues[{-y''[x]+NeumannValue[-y[x],x==1]+NeumannValue[y[x],x==0]},y[x],{x,0,1},6]

Mathematica graphics

L0=1;
tab1=Table[ n^2 Pi^2/L0,{n,{1,2,3,4,5}}]//N;
Join[{-1},tab1]

Mathematica graphics

Hand solution

Assume the solution is $y=Ae^{rx}$, then the characteristic equation is

\begin{align*} r^{2}+\lambda & =0\\ r & =\pm\sqrt{-\lambda} \end{align*}

Assuming $\lambda<0$

In this case $-\lambda$ is positive and hence $\sqrt{-\lambda}$ is also positive. Let $\sqrt{-\lambda}=\mu$ where $\mu>0$. Hence the roots are $\pm \mu$. This gives the solution

$$ y=c_{1}\cosh\left( \mu x\right) +c_{2}\sinh\left( \mu x\right) $$

Hence

$$ y^{\prime}=\mu c_{1}\sinh\left( \mu x\right) +\mu c_{2}\cosh\left( \mu x\right) $$

Left B.C. gives

\begin{equation} 0=c_{1}+\mu c_{2}\tag{1} \end{equation}

Right B.C. gives

\begin{align*} 0 & =c_{1}\cosh\left( \mu L\right) +c_{2}\sinh\left( \mu L\right) +\mu c_{1}\sinh\left( \mu L\right) +\mu c_{2}\cosh\left( \mu L\right) \\ & =\cosh\left( \mu L\right) \left( c_{1}+\mu c_{2}\right) +\sinh\left( \mu L\right) \left( c_{2}+\mu c_{1}\right) \end{align*}

Using (1) in the above, it simplifies to

$$ 0=\sinh\left( \mu L\right) \left( c_{2}+\mu c_{1}\right) $$

But from (1) again, we see that $c_{1}=-\mu c_{2}$ and the above becomes

\begin{align*} 0 & =\sinh\left( \mu L\right) \left( c_{2}-\mu\left( \mu c_{2}\right) \right) \\ & =\sinh\left( \mu L\right) \left( c_{2}-\mu^{2}c_{2}\right) \\ & =c_{2}\sinh\left( \mu L\right) \left( 1-\mu^{2}\right) \end{align*}

But $\sinh\left( \mu^{2}L\right) \neq0$ since $\mu^{2}L\neq0$ and so either $c_{2}=0$ or $\left( 1-\mu^{2}\right) =0$. $c_{2}=0$ results in trivial solution, therefore $\left( 1-\mu^{2}\right) =0$ or $\mu^{2}=1$ but $\mu ^{2}=-\lambda$, hence $\lambda=-1$ is the eigenvalue.

Corresponding eigenfunction is

$$ y=c_{1}\cosh\left( x\right) +c_{2}\sinh\left( x\right) $$

Using (1) the above simplifies to

\begin{align*} y & =-\mu c_{2}\cosh\left( x\right) +c_{2}\sinh\left( x\right) \\ & =c_{2}\left( -\mu\cosh\left( x\right) +\sinh\left( x\right) \right) \end{align*}

But $\mu=\sqrt{-\lambda}=1$, hence the eigenfunction is

$$ \fbox{$y\left( x\right) =c_2\left( -\cosh\left( x\right) +\sinh\left( x\right) \right) $} $$

Assuming $\lambda=0$

Solution now is

$$ y=c_{1}x+c_{2} $$

Therefore

$$ y^{\prime}=c_{1} $$

Left B.C. $0=y\left( 0\right) +y^{\prime}\left( 0\right) $ gives

\begin{equation} 0=c_{2}+c_{1} \tag{2} \end{equation}

Right B.C. $0=y\left( L\right) +y^{\prime}\left( L\right) $ gives

\begin{align*} 0 & =\left( c_{1}L+c_{2}\right) +c_{1}\\ 0 & =c_{1}\left( 1+L\right) +c_{2} \end{align*}

But from (2) $c_{1}=-c_{2}$ and the above becomes

\begin{align*} 0 & =-c_{2}\left( 1+L\right) +c_{2}\\ 0 & =-c_{2}L \end{align*}

Which means $c_{2}=0$ and therefore the trivial solution. Therefore $\lambda=0$ is not an eigenvalue.

Assuming $\lambda>0$

Solution is \begin{equation} y=c_{1}\cos\left( \sqrt{\lambda}x\right) +c_{2}\sin\left( \sqrt{\lambda }x\right) \tag{A} \end{equation}

Hence

$$ y^{\prime}=-\sqrt{\lambda}c_{1}\sin\left( \sqrt{\lambda}x\right) +\sqrt{\lambda}c_{2}\cos\left( \sqrt{\lambda}x\right) $$

Left B.C. gives

\begin{equation} 0=c_{1}+\sqrt{\lambda}c_{2} \tag{3} \end{equation}

Right B.C. gives

\begin{align*} 0 & =c_{1}\cos\left( \sqrt{\lambda}L\right) +c_{2}\sin\left( \sqrt{\lambda}L\right) -\sqrt{\lambda}c_{1}\sin\left( \sqrt{\lambda }L\right) +\sqrt{\lambda}c_{2}\cos\left( \sqrt{\lambda}L\right) \\ & =\cos\left( \sqrt{\lambda}L\right) \left( c_{1}+\sqrt{\lambda} c_{2}\right) +\sin\left( \sqrt{\lambda}L\right) \left( c_{2}-\sqrt {\lambda}c_{1}\right) \end{align*}

Using (3) in the above, it simplifies to

$$ 0=\sin\left( \sqrt{\lambda}L\right) \left( c_{2}-\sqrt{\lambda} c_{1}\right) $$

But from (3), we see that $c_{1}=-\sqrt{\lambda}c_{2}$. Therefore the above becomes \begin{align*} 0 & =\sin\left( \sqrt{\lambda}L\right) \left( c_{2}-\sqrt{\lambda}\left( -\sqrt{\lambda}c_{2}\right) \right) \\ & =\sin\left( \sqrt{\lambda}L\right) \left( c_{2}+\lambda c_{2}\right) \\ & =c_{2}\sin\left( \sqrt{\lambda}L\right) \left( 1+\lambda\right) \end{align*}

Only choice for non trivial solution is either $\left( 1+\lambda\right) =0$ or $\sin\left( \sqrt{\lambda}L\right) =0$. But $\left( 1+\lambda\right) =0$ implies $\lambda=-1$ but we said that $\lambda>0$. Hence other choice is \begin{align*} \sin\left( \sqrt{\lambda}L\right) & =0\\ \sqrt{\lambda}L & =n\pi\qquad n=1,2,3,\cdots\\ \lambda_{n} & =\left( \frac{n\pi}{L}\right) ^{2}\qquad n=1,2,3,\cdots \end{align*}

The above are the eigenvalues. The corresponding eigenfunction is from (A)

$$ y=c_{1_{n}}\cos\left( \sqrt{\lambda_{n}}x\right) +c_{2_{n}}\sin\left( \sqrt{\lambda_{n}}x\right) $$

But $c_{1_{n}}=-\sqrt{\lambda_{n}}c_{2_{n}}$ and the above becomes

\begin{align*} y\left( x\right) & =-\sqrt{\lambda_{n}}c_{2_{n}}\cos\left( \sqrt {\lambda_{n}}x\right) +c_{2}\sin\left( \sqrt{\lambda_{n}}x\right) \\ & =C_{n}\left( -\sqrt{\lambda_{n}}\cos\left( \sqrt{\lambda_{n}}x\right) +\sin\left( \sqrt{\lambda_{n}}x\right) \right) \end{align*}

Summary

Eigenvalue $\lambda=-1$ with eigenfunction $y\left( x\right) =c_{2}\left( -\cosh\left( x\right) +\sinh\left( x\right) \right) $ and eigenvalues $\lambda_{n}=\left( \frac{n\pi}{L}\right) ^{2},n=1,2,3,\cdots$ with eigenfunctions $C_{n}\left( -\sqrt{\lambda_{n}}\cos\left( \sqrt{\lambda_{n} }x\right) +\sin\left( \sqrt{\lambda_{n}}x\right) \right) $. Listing the eigenvalues in order:

$$ \lambda=\left\{ -1,\frac{\pi^{2}}{L^{2}},\frac{4\pi^{2}}{L^{2}},\frac {9\pi^{2}}{L^{2}},\frac{16\pi^{2}}{L^{2}},\cdots\right\} $$

$\endgroup$
  • 5
    $\begingroup$ "but it also claims zero is an eigenvalue" No, it doesn't. It just claims when $\lambda=0$, the BVP has a solution. If one wants to find the eigenvalue, DEigenvalues in principle can be used, but something like DEigenvalues[{-y''[x] + NeumannValue[-y[x], x == 1] + NeumannValue[y[x], x == 0]}, y[x], {x, 0, 1}, 5] doesn't work, NDEigenvalues works, though… $\endgroup$ – xzczd Feb 2 '18 at 11:39
  • $\begingroup$ @xzczd Ok, thanks. I am used to using DSolve as above to find the eigenvalues since it is easier to use than the syntax of DEigenvalues, but I did not realize that the trivial solution will be also given by DSolve. This was the confusing part for me. So I should switch to DEigenvalues from now on to check my solution. $\endgroup$ – Nasser Feb 2 '18 at 11:46
  • $\begingroup$ I agree NeumannValue is somewhat hard to use. (You may want to read this post. ) Hope DEigenvalues etc. will be more flexible and powerful in future versions. $\endgroup$ – xzczd Feb 2 '18 at 11:56
  • $\begingroup$ A simple reminder that for an eigenvalue you have to have a nonzero eigenvector would have been enough. Just a brain fart. :) $\endgroup$ – Michael E2 Feb 2 '18 at 18:57
  • $\begingroup$ @MichaelE2 The \underline{Summary} makes me believe the details were already written before :) $\endgroup$ – anderstood Feb 2 '18 at 19:22
7
$\begingroup$

The value lambda = 0 simply corresponds to the most trivial solution, but Mathematica never claims it to be an eigenvalue: it only claims that it's a possible solution to the differential equation you put into DSolve. There's no real reason why DSolve shouldn't give you the trivial solution.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.