2
$\begingroup$

I was experimenting with solving differential equations using eigenfunction expansions. I was troubled by the fact that my solution was very different from the solution produced by NDSolve, so I examined my code and noticed the following issue.

I have the following code in Mathematica:

Clear["Global`*"]
a[x_] := 2
b[x_] := x + 1
c[x_] := 0
L = 2 Pi;
ODE = Exp[Integrate[b[x]/a[x], x]] y''[x] + 
    Exp[Integrate[b[x]/a[x], x]] b[x]/a[x]*y'[x] + 
    Exp[Integrate[b[x]/a[x], x]] c[x]/a[x]*y[x] == 
   Exp[Integrate[b[x]/a[x], x]] f[x]/a[x];
n0 = 30;
{eigV, eigF} = 
  NDEigensystem[{ODE[[1]], DirichletCondition[y[x] == 0, True]}, 
   y, {x, 0, L}, n0];
eigF[[2]][5]
Plot[eigF[[2]][x], {x, 0, L}]

As I understand it (I might be wrong), the commands:

eigF[[2]][5]
Plot[eigF[[2]][x], {x, 0, L}]

should give the same answer whether n0=3 or n0=30. But this does not happen. Why?

$\endgroup$

1 Answer 1

4
$\begingroup$

They are the same.

Remember, sign on eigenvector do not make difference. It is arbitrary.

n0 = 30;
{eigV, eigF} = 
  NDEigensystem[{ODE[[1]], DirichletCondition[y[x] == 0, True]}, 
   y, {x, 0, L}, n0];
eigF[[2]][5]
Plot[eigF[[2]][x], {x, 0, L}]

enter image description here

n0=3;
{eigV,eigF}=NDEigensystem[{ODE[[1]],DirichletCondition[y[x]==0,True]},y,{x,0,L},n0]
-eigF[[2]][5]
Plot[-eigF[[2]][x],{x,0,L}]

enter image description here

$\endgroup$
1
  • $\begingroup$ You are right. For me (Mathematica 13.3), the one eigenfunction was simply the opposite of the other. I didn't notice, in my desperation to find where I went wrong. Thank you, anyway! $\endgroup$ Commented Jun 19 at 7:40

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.