I'm a 3rd year college student studying maths and physics and as part of our course we do some c++ with the aim of modelling in mind. Our current project involves writing a program which creates data which can be graphed to show the wave function of a particle in a potential for a given energy. The part I'm having a problem with is normalising the curves we get. The integral of the square of the absolute value of the wave function over all space should be one. Or in other words the potential of the particle over all x should be 1. Using Simpsons rule http://en.wikipedia.org/wiki/Simpson%27s_rule for an approximation to integration I've come up with the following code.
for(k=2;k<N;k=k+2)
{
total1 = total1 + 2*(Psi[k]*Psi[k]);
}
for(k=1;k<N;k=k+2)
{
total2 = total2 + 4*(Psi[k]*Psi[k]);
}
the totals are summed and used to rescale the Psi array. The rescaling doesn't seem to work as even after teh Psi array is rescaled the integral or the sum remains the same. If you need more of the code to find the problem let me know and I'll post the rest of it.