I've just finished learning the physics behind the problem and would like to write a program in C++ than can solve the problem. I'm actually stuck at the start. I've quite a bit of research, the problem is there is not too many examples of code used to solve the problem.
I'm going to solve the problem using finite-difference form.
$$\dfrac{d^2\psi}{dx^2}\approx \dfrac{\psi_{n+1}+\psi_{n-1}-2\psi_{n}}{(\Delta x)^2}$$
Which allows us to rearrange in the form
$$\psi_{n+1}=2\psi_{n} - \psi_{n-1}-2(\Delta x)^2(E-V_n)\psi_n$$
Using the even-parity solution, we have
$$\psi(0)=1 \quad \quad \psi'(0)=0$$
at $n=0 \implies x=0$
Letting $m=1$ and $\hbar = 1$ I know that at the ground state $E_g =\frac{\pi^2}{8}$
I'm struggling to write code that can help me find $\psi_n$ for values of $n$.
Can I assume that $V_0 = 0$ since we want the wave function to be inside the well?
I'm not asking for someone to write the code for me, I'd just like tips on what I need to define and which method I should use.
Thanks in advance
EDIT: This is what I have so far
#include <iostream>
#include <string>
#include <stdio.h>
#include <unistd.h>
#include <math.h>
#include <stdlib.h>
#include <stdarg.h>
#include <assert.h>
using namespace std;
const double PI = 3.14159265358979323846264338327950;
int main() {
cout < "1D Particle-in-a-Box"\n;
double psi0, dpsi0, N, dx, x_end, E;
int number_steps, nr;
double value_x [number_steps];
double psi [number_steps];
double V [number_steps];
//read parameters (even-parity)
cout < "psi0 = ";
cin > psi0;
cout < "dpsi0 = ";
cin > dpsi0;
dx = x_end / number_steps;
value_x [0] = 0;
psi [0] = psi0;
V [0] = 0.0
//finite-difference form
while (nr < number_steps)
{
value_x [nr+1] = dx*(nr+1);
psi[nr+1] = 2*psi[nr] - psi[nr-1] - (2*(dt*dt))*(E-V[nr])*(psi[nr]);
nr = nr + 1;
}