2
$\begingroup$

I've been trying to plot the eigenfunctions of a square well with a quadratic surface. I don't know why, but when I try to plot it, it doesn't plot anything. Here is my code:

schrod = ParametricNDSolve[{-1/2 \[Psi]''[r] + r^2 == Ei \[Psi][r], \[Psi][-20] == 0, \[Psi][20] == 0}, 
         \[Psi][r], {r, -20, 20}, {Ei}];
Plot[\[Psi][5][r] /. schrod, {r, -20, 20}]

That's my code trying to plot the 5th eigenfunction, and this is what's returned. plot of the 5th eigenfunction

Am I doing something wrong?

$\endgroup$

1 Answer 1

3
$\begingroup$

Change the function to ψ[r][5]

Clear[schrod]; schrod = 
 ParametricNDSolve[{-1/2 ψ''[r] + r^2 == 
    Ei ψ[r], ψ[-20] == 0, ψ[20] == 0}, ψ[
   r], {r, -20, 20}, {Ei}];
Plot[ψ[r][5] /. schrod, {r, -20, 20}]

enter image description here

$\endgroup$
2
  • $\begingroup$ Nice! Thank you very much! $\endgroup$ Aug 20, 2022 at 11:58
  • 1
    $\begingroup$ @MichaelAdrianJavier We can accept the answer by the symbol ✔ at the leftside of the answer. $\endgroup$
    – cvgmt
    Aug 20, 2022 at 12:03

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.