Now, of course, we don't only want to have one single eigenvalue, we also want to determine the next
eigenvalues.
So let's try another well, you.
Let's take five point nine.
OK, now the way function goes way beyond zero.
So maybe go even higher.
OK, looks still like a sign function as it should.
OK, we need to go way higher, actually.
Thirteen point nine.
17.
OK.
OK, that looks kind of OK, I guess.
So now we have another wave function that goes back to zero for the Position X is equal to A, which
is in our case, one.
So this would be the second eigenvalue.
And actually, do you remember what the analytical result was?
So this was the first eigenvalue, which corresponds to one squared where this one is the quantum number
and then we make it to two.
We get this one.
Three.
OK, good.
But that's of course, cheating because here we know the analytical result.
But we of course, want to do it without knowing the analytical result.
So what we want to do is we want to scan the energy until we get the proper values so that the way function
returns back to zero.
And actually something that I also want to mention is we know actually that this is two third eigenvalue
because of the zeros here inside of the box.
So you remember from the analytical result, the eigen level of four and equal one had no zero for an
equal to we had one zero and four and equal three.
We had two zeros, as you can see here.
And this is true in every single example where we have a bound state in the potential like X Square
or such a particle in the box.
So that's always true.
So we know that there is no other eigenvalue between the one, the values that we have determined when
we just check the zeros.
OK, but if we are now scan our energy and increase the energy just by small amounts, there's also
no difficulty in finding these eigenvalues.
So we don't really have a problem here.
And actually scanning the ion energy is exactly what we are going to do next.
So we use this auger rhythm here, which works quite well.
Now we can delete this one, and now we are going to modify this rhythm.
So as I told you already, we are going to scan the energy.
So what we will do here is we will actually start with, um yeah, let's see energy equal to zero.
And now we will use another loop over this loop.
So let's add another loop here, another while loop.
And this time we have a condition which is actually, let's say psi is so we should end when psi is
equal to zero.
So how are we going to do this?
We will set the absolute value of psi should be smaller than, let's say, zero zero one some value.
We have to test this maybe if it doesn't work.
So this means he keeps on doing the loop as long as this value is larger than this.
So it stops when it's smaller and this is exactly what we want.
OK, now you have caused this, we don't need here.
So we we start from equal to zero and now we increase our energy in increments of Delta E and that's
that's put Delta.
Maybe not too small, because then it will take forever.
Because remember, um, the computer will do this this loop for many, many times.
So just from going from zero to five, he will do it now 500 times, so it could take a while.
So we don't want to do it too small.
Now what we also need here now is we need to define these two things.
So
let's do this before we change the energy, because then we can first do it for equals zero.
And then the next time we do it for D e um, then I would say we don't actually need all of these lists.
So so we don't need to store all the size and all the excess.
We only need to store it for the correct wave function where we have the eigen function and the eigenvalue.
So I will put it inside of the loop so that it will be overwritten every time the result was not good.
And then in the end, we can only access the last time this was written here.
So this means for the case where the EIGEN system was actually determined.
So this is why I'm putting it inside of the loop here.
OK, what else do we need?
We need to go back to zero.
So, yeah, just put it here.
OK.
Um, yeah, we have this one here.
That looks good.
And, OK, now we could test if it works.
I'm not really sure if it does, but let's test.
OK, maybe let us not put this in the while loop.
Let's put it outside and also let's plot the energy.
OK, cool.
OK, now it's the energy is equal to zero, which means it stops to loop right away because the passive
function is actually zero.
That's probably because we start here with PSI function, which is zero because we have previously solved
this case.
So let's just put it to some random value and then it will be redefined inside of the loop.
OK.
Yeah.
OK.
So now it says energy is equal to 4.9.
That's actually very close to what we had determined here.
That was, yeah, there was this one.
OK.
So we have now four point nine three and this is the corresponding wave function.
Now, that's pretty good, because now we have automatically determined the first eigenvalue, and now
we can also determined to next eigenvalues.
And for this, we will again copy of a working algorithm.
And you guessed it, we will add another loop.
This time the loop will be again a while loop and we will have some, some counter which we will increase
whenever we have found an eigen energy.
And let's say we were to find some and Maxwell U, which let's let's use three for the beginning.
And OK, now this one we will need here inside of the loop, actually.
Um.
OK, what else do we need?
We OK, this one, we can leave here with this when we can leave here.
OK, we need a counter, so let's say a counter will be starting with.
With one, OK, yeah.
And let's not forget this one, you and.
Now, after we have done these loops.
We will increase the counter counter will be counter +1.
OK, now what we have is we start with a counter off of one counter counter.
Um, then we will search for the first eigenvalue.
We will have to save it in some way, which is not included yet.
And then we will increase to counter by one.
Suzanne Counter will be two and at some point when the counter is large, it and and max, then he will
stop.
And then we have determined three eigenvalues and eigen functions.
OK.
As you noticed, we also have to do is we will have to save our eigen function.
So we will have a list of functions.
So let's define this list
of functions.
Let's make it just an empty list.
And here we use again our append function and we will add the list of the corresponding eigenvalue.
So basically this one here?
No, I think 40 x value, we don't necessarily have to do it because it will always be the same x value.
But OK, let's let's let's do it anyway.
Um.
So I can Functions X list.
Let's put it like this next list is Append X list.
And then we also need to save our icon energies, I think, and and or GS.
So.
Let's if I can again and urges dont append.
And then we have here our value, exactly.
OK, now let's test the code.
OK.
Let's see, I get and or chiefs.
And and they're just OK, so we have no.
OK.
Yeah, that's that's that's that's unfortunate.
So basically, we have not determined in indeed three eigenvalues.
We have four point nine and we have nineteen point seven, which is actually true because we can use
here nineteen point seven.
OK.
That's actually our second eigenvalue, because here the system also determined another eigenvalue,
which is very close to this one here.
This is because the true eigenvalue would probably somewhere between these two values.
But since we had our condition, you too large, it determined both of them.
So now we have two solutions for this.
We could either decrease this, this value here to make the position higher, but actually this would
then take much longer for the system to compute.
But instead, what I'm going to try is I will use this one here.
Let's say, OK, maybe we could do anything.
So what this does is once we have determined the eigen energy, we will say OK as a next step and just
increase the energy by some large enough factor so that you don't get the same eigenvalue twice.
The only problem that could arise here is that we would not be able to register another eigenvalue in
this range.
So if two eigenvalues would be very close, we could not determine them.
But since we know what our solution looks like, and yeah, because here is just an educational example,
I will use it like this.
So we are not missing out on anything.
So I hope now this should work.
OK, so we have this one, this one, and this we can test.
OK, let's use forty four point three.
OK, very good.
So let's see.
Could we go higher and Max Equal five?
Actually, it's pretty fast.
I know it's not some seconds.
OK, let's let's try this one.
What does it look like?
OK.
Nice.
So this is our fifth eigenvalue and I can function.
So it should have five zeros.
Should have four zeros.
One two three four.
OK.
So we have now determined our first five I can energies and I can functions automatically.
So what we could do now is we could plot the ideal functions.
So I will use that using a loop.
So just plodding down on top of each other.
So we know we have and max eigenvalues, which in our case is five.
So people use plot and then we have here our next list.
Um, I think and functions.
OK.
This is a bit bit of a difficult syntax in Python, I think so
it's a bit hard to follow along, I admit.
But OK, it's not so important is just for just for plotting counter.
We have to, of course, increase our counter.
And now it should.
OK.
Yeah.
So now we have here in blue the first iron function, which has no zero apart from these boundaries.
Then we have second and orange, then we have the green one, the red one and the purple one.
And also what you can see is that all of these functions here have the same slope at the beginning.
This is because we have always defined deep side is equal to one at a position zero.
So we have strictly enforced that the slope is equal to one at this position because of course not true.
It does not give us to correct eigen functions because as you can tell, the absolute square of this
blue function will be much, much larger when you integrate over the whole box compared to the other
functions.
So this is what I mentioned at the very beginning.
These functions are not normalized yet.
We have to normalize these functions now.
So I think now you have already learned what this shooting method is all about, and I think it's quite
impressive.
We have determined the eigen energies and also the principle, the principle shape of the wave function.
So what was following now is the normalization of these wave functions and we will report them.
So this is actually not so important.
But still, I want to show you how you can do it using Python.
But I think that's a bit just tedious work because of some, maybe some syntax
problems.
But I have, of course, done it already before, so I know we're now here.
What are the difficulties, for example, using these indices here, these lists?
So what I've shown you here is we are actually calculating to some over the absolute square of the wave
function and we multiply it by our increment.
So what this actually is is the integral over the absolute square of our wave function.
And so we have here just index number two.
So since Python is starting from zero, this is actually for the third wave function one our norm.
OK, now something went wrong.
I can function.
OK, I can functions.
OK, so this is now our norm for the third, I can function.
So now we have to divide our function by the individual norm.
So let's do this in the next step.
So again, we need a loop with a counter looping over our way functions.
So first of all, we have to calculate the norm for every individual wave function.
So since we are in the loop now, we are starting with the first wave function.
And here we need this one.
And here as the index, we need to counter.
And since starting to count from zero, we have to write this minus one here and here.
OK, so this is now norm off the wave function and we are looking at at the moment inside of the loop.
And now we have to determine what we have to divide the EIGEN function by does norm.
So let's use again counter minus one.
And this zero is just to get rid of some brackets in the list.
Otherwise, it would not work, I have noticed.
So we can do it like this.
So if you are a Python expert, you will probably even find much more elegant ways to do this, but
I think this is a bit more instructive.
So now we are dividing every single element in the list or in the eigen function that we are currently
looking at by its respective norm.
So, OK, I guess that's it.
Oh, OK.
And you must not forget to increase the counter by one.
OK, so we have determined the norm we have.
We are looking here at basically every single element in the list that basically holds information about
this.
I can function and we are looking now at every element and dividing by the square root of the norm.
OK, I think that's good.
Now we have manipulated this, I can function.
So basically, I think we can now just plot again.
So just copy this one.
OK, now good.
Now, every wave function has the same maximum, and this is something that is not generally true.
So when you have a general potential, the way functions do not have to have the same maximum and minimum.
But for this particle in the infinitely potential box, it's actually true.
And we have learned this also in the analytical lecture where we have determined is Prefect Capital
Way, which was something like square root of I don't remember too over a or a over two or something
like that.
So all of the way function of the same prefecture and this we can see also here.
Now let's check again if our if our norm is now correct.
Yeah, OK.
It's equal to one.
But also we could have maybe estimated this.
We have here something like, yeah, we have your length of one and a height of actually the square
root of two.
And yeah, so this if you if you draw a triangle, here it is, has approximately integrale of one.
So that's definitely true.
OK, now what we can do next is we can do something that I've also done in the analytical case, a different
way of plotting a whole wave function because you can see here we have all of the wave functions that
overlap each other.
So instead, we could plot the individual energy levels and then plot the wave functions on top of this
energy level.
So this is something that I will do now.
And so that's pretty similar to actually to determining the norm.
So we will again loop over every individual wave function using this counter.
So norm, we don't need we have done this already.
And now what we are doing here for every individual element is we take the element, which is called
acts here and we will add the eigen energies this time and we need to correct one.
So, OK, you should go like this.
Let's plot again.
OK.
Yeah, cool.
So as you can see, or as you remember, our first eigenvalue was something like five actually is what
it was.
We can look at it again.
I get it and or cheese was 4.9 three.
So was this blue one here, then the next one, approximately 20 that we have forty four, seventy eight
and one hundred twenty three.
And on top of this, we have some wave functions that have an amplitude of square root of two, which
is of approximately one point four.
So we can almost not see this punctuation anymore.
Of course, we could now reshape the way function, but I think it is really the correct way of plotting
it.
And when you have followed along and you have programmed this yourself, you can really be proud of
yourself that you have solved now also numerically your first quantum mechanical example.