I am attempting to solve the time-independent Schrodinger equation as a numerical analysis exercise, but my QM is a bit weak. I have the following potential and I want the energy/eigenvalue. \begin{equation*} V(x) = \begin{cases} \infty & (- \infty , 0)\cup (2l, \infty) \\ 0 & x \in [0,l]\\ V_0 & x \in [l,2l] \end{cases} \end{equation*}

I was wondering if this was a correct way of attacking it. I have found solutions $\psi_1(x)$ and $\psi_2(x)$ for $x \in [0,l]$ and $x \in [l,2l]$ by making initial guesses of $\psi_1'(0)$, $\psi_2'(2l)$ and $E$ which I want to use to extract the true solution by the shooting method. For the $x \in [l,2l]$ case I used a negative step size to traverse backwards, I was unsure if this was correct but I dont think starting at $\psi_2'(l)$ would suffice because it's not at the boundary where potential is infinite and the wave function is 0, so there's no good information for an initial/boundary value .

My main question is when it is time to "clean up" my guesses for the true values of the constants should I normalise with $\displaystyle \int_{0}^{l} |\psi_1|^2$ and $\displaystyle \int_{l}^{2l} |\psi_2|^2$ or $\displaystyle \int_{-\infty}^{\infty} |\psi_1|^2$ and $\displaystyle \int_{-\infty}^{\infty} |\psi_2|^2$ or even $\displaystyle \int_{-\infty}^{\infty} |\psi|^2$ where $\psi$ takes the appropriate values depending on the region. I am also unsure if I am looking for a single eigenvalue that works for both $\psi_1(x)$ and $\psi_2(x)$ or for $E_i$ s.t. $\hat{H}\psi_i(x) = E_i\psi_i(x)$

Apologies if this should be in scicomp.stackexchange or is a little basic, thanks.

  • $\begingroup$ Just from curiosity, what software do you use for this calculation? $\endgroup$
    – eranreches
    Dec 28, 2017 at 23:41
  • $\begingroup$ Python with numpy if thats what you mean. $\endgroup$ Dec 28, 2017 at 23:43
  • $\begingroup$ That's what I meant. I don't know Python very much, did the same in Matlab. $\endgroup$
    – eranreches
    Dec 28, 2017 at 23:44

2 Answers 2


I) First, I am doing it analytically,

Solutions of Schrodinger Eqution:

$\psi_I(x; 0<x\le l)=A \sin k_1 x+B \cos k_1 x \Rightarrow \psi_I(x)=A \sin k_1 x$ (after using the BC: $\psi(0)=0$)

$\psi_{II}(x; l<x\le 2l)=C \sin k_2 x+D \cos k_2 x \Rightarrow \psi_{II}(x)=C (\sin k_2 x - $ $\tan k_22l \cos k_2x)$ (after using the BC: $\psi_{II}(2l)=0)$.

where $k_1=\sqrt(e); k_2=\sqrt(e-V_0)$ (I have taken $\hbar^2=1=2m$)

Now matching the solutions at $l$: $\psi_{I}(l)=\psi_{II}(l),$ and $\psi_{I}'(l)=\psi_{II}'(l),$ This eliminates the coefficients $A$ and $C$.

We get the following transcendental Eq.,

$\frac{\tan k_1l}{k_1l}=\frac{\sin k_2l-\tan k_2 2l \cos k_1 l}{k_2l(\cos k_2l+\tan k_2 2l \sin k_2 l)} \Rightarrow \frac{\tan (k_1(e)l)}{k_1(e)l}-\frac{\sin (k_2(e)l)-\tan (k_2(e) 2l) \cos (k_1(e) l)}{k_2(e)l [\cos (k_2(e)l)+\tan (k_2(e) 2l) \sin (k_2(e) l)]} {=}0$

Example: Let's take $l=1$ and $V_0=2.$

First two roots of this equation are: $\textbf {3.367, 10.944} $; These are the first two eigenvalues.

II) Numerically, There is a nice way to do it in Mathematica,

Here, I am integrating the Schrodinger equation from ( with BCs:$ \psi(0)=0,\psi'(0)=1)$ $0$ to $2l$, then looking for zeros of $\psi(2l,e)$.

k[e_] := Sqrt[e];
v0 = 2;
l = 1;
pot[x_] := Which[0 < x <= l, 0, a < x <= 2*l, v0];
sol1 = ParametricNDSolve[{sy1''[x] + sy1[x]*(k[e]^2 - pot[x]) == 0,sy1[0] == 0, sy1'[0] == 1}, {sy1}, {x, 0, 2*l}, {e}];
sy2[x_, e_] := sy1[e][x] /. sol1;
Plot[sy2[2*l, e], {e, 0, 20}]
FindRoot[sy2[2*l, e] == 0, {e, 4}]
FindRoot[sy2[2*l, e] ==0, {e,10}]

Plot of Sy2[2*l,e]

Here I have taken $l=1$ and $V_0=2.$

The above plot is for "sy2[2 l, e]" ( i.e. $\psi(2l,e)$). The first two roots are {e $\rightarrow$ $\textbf {3.36726, 10.9443} $}; These are first two eigenvalues.


Because you are only interested in the energy eigenvalues, you don't need to normalize $\psi$. Observe that if $\psi$ is a solution to the Schrodinger equation

$$-\frac{\hbar^{2}}{2m}\frac{{\rm d}^{2}\psi}{{\rm d}x^{2}}+V\left(x\right)\psi=E\psi$$

then so as $A\psi$ for every $A\neq 0$ with the same $E$. Also, since this is a second order differential equation, you only need to set two conditions on $\psi$. Because you are trying to solve the problem numerically, you need to set the conditions at $x=0$ (I assume you solve forwards and not backwards). I argue that you must require


The first condition is the consequence of the infinite potential at the boundaries. The second condition is equivalent to $\psi^{\prime}\left(x=0\right)\neq 0$ - because remember! We don't care about the normalization! Now you use the shooting method. You guess $E$, solve the ODE and get $\psi\left(x=2L\right)$. Keep guessing till you get $\psi\left(x=2L\right)=0$. In other words, use a root finder to solve the equation


for $E$. Start the iterations at the guess $E_{0}=0$ for the ground state. For higher states you'll need to use trial and error. I'd recommend you to plot $\psi_{E}\left(x=2L\right)$ as a function of $E$. The zeros of this graph are the eigenvalues.

  • $\begingroup$ Since I am treating it as all a single $\psi$ solving the ODE on $[0,2l]$ does that mean I write $V(x)$ as a piecewise function on $[0,2l]$ And if I care about the normalisation after I obtain $E$ I just integrate $|\psi|^2$ over $\mathbb{R}$ right? Otherwise this makes a lot of sense thank you. $\endgroup$ Dec 28, 2017 at 22:50
  • $\begingroup$ @TheoDiamantakis Yes. $V(x)$ is a piecewise function. As for the normalization, you integrate over $\mathbb{R}$, but $\psi$ is essentially zero outside $\left[0,2L\right]$. Thus you need to integrate over $\left[0,2L\right]$ only. $\endgroup$
    – eranreches
    Dec 28, 2017 at 22:52
  • $\begingroup$ Excellent thank you, just to make sure I understand, does $\psi'(x=0) = 1$ just because 1 is a nice non zero number or does this initial condition come from a physical reasoning? $\endgroup$ Dec 28, 2017 at 22:54
  • $\begingroup$ @TheoDiamantakis Just because $1$ is a nice non-zero number. I actually did the calculation myself now. If you have graphs, you can add an answer of yourself to the question. It would be nice to see the results! $\endgroup$
    – eranreches
    Dec 28, 2017 at 22:56

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.