When i try to plot the numerical solution of quantum harmonic oscillator , it blows up even for the correct energies. Why does this happen and how can it be fixed? The code i used is as following.
sol =
First[
NDSolve[
{-1/2 D[ψ[x], {x, 2}] + 1/2 x^2 ψ[x] == (1 + 1/2) ψ[x],
ψ[0] == 0, ψ'[0] == 1},
ψ[x], {x, -a, a}],
MaxSteps -> 10000000]
Plot[ψ[x] /. sol, {x, -a, a}, PlotRange -> 1]
a? – zhk Dec 22 '16 at 08:04WorkingPrecisionwill delay this, but you'll hit the effect at even higher values ofa. BTW, this ODE can be solved byDSolve[]. – J. M.'s missing motivation Dec 22 '16 at 08:10MaxSteps->inside ofFirst, notNDSolve[], you might also be interested inNDSolveValue[]– Feyre Dec 22 '16 at 08:54, WorkingPrecision -> 50gives you an accurate plot for the entire domain given. But like @J.M. said, this won't help you inC. – Feyre Dec 22 '16 at 08:56