8
$\begingroup$

For example, say I have $y'' + \lambda y = 0$ and the endpoint conditions are $y'(0) = 0$ and $y'(\pi) = 0$.

How can I find the values for $\lambda$ that for which there is a non-trivial ($y\neq0$) solution using Mathematica?

$\endgroup$

3 Answers 3

7
$\begingroup$

The solution gives

de = y''[x] + lam y[x] == 0;
sol = y[x] /. First@DSolve[{ode}, y[x], x]

Mathematica graphics

Taking derivative and applying boundary conditions gives

yd = D[sol, x];
eq1 = (yd /. x -> 0) == 0

Mathematica graphics

eq2 = (yd /. x -> Pi) == 0

Mathematica graphics

From first equation, only choice is C[2]=0 hence the second equation becomes

eq3 = eq2 /. C[2] -> 0

Mathematica graphics

And now for C[1] not to be zero (else trivial solution) then either $\lambda=0$ or $\sin(\sqrt{\lambda} \pi)=0$. We do not want $\lambda=0$ so the only choice left is $\sin(\sqrt{\lambda} \pi)=0$ which happens when $\sqrt{\lambda} \pi=n \pi$ for integer $n$.

So Mathematica choose $n=0$ and hence $\sqrt{\lambda} \pi=0$ which means $\lambda=0$ but this is not possible, so only choice is C[1] is zero. Hence the trivial solution.

To force $n$ to be something other than zero,

 Assuming[Element[n, Integers] && n != 0 && (Sqrt[lam] Pi) == n Pi, 
      Solve[{eq1, eq2}, {C[1], C[2]}, Reals]]

Mathematica graphics

So there are the conditions

update: I should say, if I was doing this by hand, I will just write at the end above that $\sqrt{\lambda} \pi = m \pi$ for $m \neq 0$ and $m$ integers. Hence just say that $\lambda=m^2$. This does give the same conditions as well as above:

Assuming[Element[n, Integers] && n != 0 && lam == n^2, 
  Solve[{eq1, eq2}, {C[1], C[2]}, Reals]]

Mathematica graphics

The bottom line, is that Mathematica gave trivial solution, since it saw Sin[x]==0 and just said x=0

$\endgroup$
6
$\begingroup$
sol = y[x] /. First@DSolve[{y''[x] + lam y[x] == 0, y'[0] == 0}, y[x], x]
sol2 = Solve[(D[sol, x] /. x -> Pi ) == 0 && lam != 0 && C[1] != 0, lam, Reals]
FindSequenceFunction@ Most[Union @@ Table[lam /. sol2 /. C[2] -> x, {x, 0, 20}]]

(*
C[1] Cos[Sqrt[lam] x]

{{lam -> ConditionalExpression[4 C[2]^2, C[2] ∈ Integers && C[2] >= 1]}, 
 {lam -> ConditionalExpression[1 + 4 C[2] + 4 C[2]^2, C[2] ∈ Integers && C[2] >= 0]}}

#1^2 &

*)

So lam must be a squared integer.

$\endgroup$
1
$\begingroup$

I suppose the proper formulation of the problem, assuming C[1] == C[2] == 0 corresponds to the trivial solution, is

Exists[{C[1], C[2]}, bcs && (C[2] != 0 || C[1] != 0) /. gensol]

where bcs are the boundary conditions and gensol is the general solution.

The OP's case:

gensol = First@DSolve[y''[x] + λ y[x] == 0, y, x];
bcs = y'[0] == 0 && y'[π] == 0;

Resolve[Exists[{C[1], C[2]}, bcs && (C[2] != 0 || C[1] != 0) /. gensol], Reals]
Solve[Simplify[%], λ]
(*
λ == 0 || λ == 0 || λ == 0 || λ == 0 ||
 (C[3] ∈ Integers && C[3] >= 0 && λ == 1 + 4 C[3] + 4 C[3]^2) ||
 (C[3] ∈ Integers && C[3] >= 1 && λ == 4 C[3]^2)

{{λ -> ConditionalExpression[4 C[3]^2, 
    C[3] ∈ Integers && C[3] >= 1]},
 {λ -> ConditionalExpression[1 + 4 C[3] + 4 C[3]^2, 
    C[3] ∈ Integers && C[3] >= 0]},
 {λ -> 0}}
*)

I can't get Mathematica to combine the odd and even nonnegative integers into a single solution. One could resort to belisarius's method of using FindSequenceFunction, which works in the OP's case.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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