So we know that the solution for the eigenvalues of the Matrix eight are these three values here and
now I will show you my solution and how we can program such a routine ourself.
So if you want to first have a hint, you can look at these equations here.
So this is actually how you would do it analytically.
So we have to solve this equation.
Zero is equal to the determinant of a minus lambda times the identity matrix.
And so this means we have to solve this equation here.
And first of all, you have to calculate the determinant of just three three make matrix, which is
maybe not so easy if you don't remember how to do it from math.
So there are several ways to do it, but one of them would be to take this factor here to mine has alarmed
at times determinant of this matrix, which I've written down here, minus this factor here, minus
one times two determinant of this matrix, which would be this one here and then plus zero times the
determinant of this matrix.
But since it's zero, we can leave it.
And then you calculate these determinants, which would be this time this this minus those times.
This so would be two minus lambda squared minus minus one squared.
If we multiply it with two minus lambda, we get to minus the two the power of three minus one times
two minus lambda.
And from here we get minus minus one.
That's +1, and then here minus one times two minus lambda, minus zero times minus one, which is zero.
So we just get the single term.
Then we have to calculate here the cube, which would be two to the power of three, which is eight.
Then we have two squared times minus Lambda Times three, which is minus 12 lambda.
Then we have three times two times lambda squared, which is this one here, six squared and we have
minus lambda two the power of three, which is this one.
And then we have here more terms.
Yeah, basically these ones here that you see.
And then we have to just cancel these terms and this will in the end, be the polynomial for which we
have to calculate the roots, the zeros.
So this is what you have to program.
And now my solution would be first to find a function called determined.
First of all, the Terminal three, hey, where is the matrix?
And we have now, as I told you, the three terms term one is a zero zero times a 1:1, times a two
to minus a one to a two one.
So that would be a zero zero, and this would be the determinant of this matrix here.
So it would be this times, this minus this times, this, then we have term two and this November,
similar, of course, this would be a one zero times.
Now let me copy this and just fixed the indices.
So would be zero one two two zero two two one.
And then now we can copy this one more time and fixed the indices.
And of course, now we have here eight to zero, which would be this element.
So in our case, this would not contribute.
But of course, we will program it anyway because we want to want it to be correct for all other matrices
as well.
So we fixed the indices and I think.
This is what we have now.
Yeah.
OK.
So I hope this is correct.
Maybe I have a typo, but yeah, I think it looks good.
Yeah.
Let's see if it gets the correct value because we know that this is correct.
So in the end, if it gives the correct value, then probably we did everything right.
So now we must define the so-called characteristic polynomial, which would be this one.
So I just write a definition characteristic
polynomial x would be return determinant.
Three of a minus x times and P taught identity.
Three.
So this would now be the determinant of a minus lambda times one matrix, which should give us this
one here.
Just one more thing I see I forgot to write the return, which is, of course, then term one minus
term two.
This is how the determinant is calculated.
Plus term three.
OK.
So redefine it.
Define this one.
And now we can try to find the root.
First of all, let me see if we get any arrows.
So let's just hold this for some random value X gives us minus one.
And by the way, we know what the correct solutions are.
For example, two is one of the solutions, so it should give us zero now.
Yes, it goes zero.
So it seems to be correct.
And we can also test the other one, which is looks like two plus square root of two to parse and Peter's
Square root of two.
OK, yeah.
Gives also zero.
So it seems as we are on the right track.
Of course, this is a bit cheating to compare it with the correct results.
But yeah, it's just a practice.
And now we can define another routine to find the root.
And here we need, of course, our function, which will be characteristic polynomial.
Then we need the number of routes.
Since it's a polynomial, it has three routes which could be imaginary or complex, but here they are
real.
So we don't have to be that careful here.
So yeah, we will just do it in a bit of a quick and dirty way here.
Then we should specify some range in which the program is looking for the zeros and we have to go in
steps.
So I will add here parameter for the step, size.
And yeah, let's just name these function than we have and number of.
Roots than we have explained to S-Max is the range in.
Which the roots are expected to be.
And then we have start step, you know, starting value for the step size.
Okay, so the idea of this routine is to basically scan through the range.
So we start from examine and then we go in steps, which will in the beginning be step size two x max.
And then we look if the function F has changed at the sign.
So what we specify is a starting value for X.
This will, of course, be X-Men.
And also we will change the accuracy.
So of course, we could just say whenever the function changes that sign, then one of the two values
where it changes design is the route.
This would be reasonable, but the accuracy would be kind of bad.
So we will tune the step size during this routine during this process.
So in the beginning, it will just be start step, but later on it can be adapted.
So of course, in your solution, you don't have to do it exactly as I did.
As long as you get the correct result, it's just fine.
This is just my suggestion on how I would do it in a bit of a quick and dirty way.
So then I told you that we will always compare to neighboring points and we will compare designs.
So we need something like sign and sign B. And Sign A would be and P Dot sign off half of X.
And in the beginning, sign of me will be the same thing.
But we will, of course, then always go to the next point.
So this is just like a starting value for this.
And then we must also store the roots somewhere.
So I make just an empty list for the roots.
And now we will just make a loop.
And first of all, we will, of course, loop until we have found three routes.
But this is something we could add later on.
Or maybe let me let me just write it here that we don't forget it.
So while the length of route is still smaller than and so this means if we didn't have found already
all three routes that we will specify here, then we will keep on looping.
And so basically, this will loop three times until we have found all of the routes.
And now comes the actual code.
We will find each of these loops.
So this would be while the accuracy is still large.
So here we have to define just some small value.
The smaller the value, the better the accuracy, but also the longer it will take.
So maybe, for example, we could do this one, and now we will compare the sign of neighboring points.
So here we will, right.
While the sign of a.
Is equal to the sign of peace, then we will keep looping them, basically, nothing happens because
this means one sign off and sign off, be two neighboring points is still the same.
Then we didn't encounter any route.
So then we will basically do nothing and just go to the next point.
So we will do the following sign eight is equal to sign B. Then we will make the Step X is X plus D
and sign B will then be recalculated will be the and P dot sign of the new point.
So now you see, in the beginning, both of them are the same.
So this one gives us a true.
So we will now enter this loop and we will keep on looping here.
And what will happen then is we will basically go to the next point and calculate the sign.
Now we have two different values for A and B, and now it keeps looping.
So here it will always compare is to sign of a equal to be.
If yes, then basically you go to the next point and shift the sign and sign B..
OK, and when it's false, does means sign and sign B are different.
This means a route must be between these two values of X and X plus d.
So we will then decrease D whenever the sign changes until the desired accuracy is breached.
So what we will do then, is when this is true, then we know that that between these two points X and
X plus d must be a zero must be a root.
So we go one step back and one step back.
So we will decrease by D.
Then we will reset, sign and sign P to the previous value and people to sign f off X minus D and sign
B will be.
And P dot sign f x.
And we will decrease the value of D.
For example, we could divide it by two or we could also just decrease it by one order of magnitude.
Of course, it has differences in terms of performance, but yeah, I think it doesn't really matter
that much.
By the way, I just noticed that I forgot to make here a tab, so we have to fix.
Of course, all of this now, otherwise it's not really in the loop.
OK.
Like this?
And so this means now this is true.
So we still loop.
And then at one point, it will be false.
So then the loop will end and then we will do this one here.
And so then we will decrease the D value, which is in the beginning, start step and then we will basically
loop here.
So we will repeat this process until we have done this, maybe like two or three or four times.
And then the D value is pretty, pretty small.
So basically, we have encountered here arranged between X and X plus d where the route is.
Then we go back to X minus D and decrease the accuracy and then search into small range once again with
much smaller steps.
And then we repeat this over and over until we have approximated the route by such an accuracy here.
So now, if all of these loops have ended, we have found our route and we will then of course, store
the route.
So Store X in route.
So it will just be route dots append x, then we will reset D to find the next route.
So we will to D is equal to start step and then we will go to the next X and reset the signs.
So X will be X plus de Signy will be around p dot sign f of X.
And the same for same beat.
So it is essentially the same as here.
And then the last thing will, of course, be return the route.
So last thing here is pretty easy.
This is just after we have found a route.
We will store it.
Then we would go just a step here to the right.
Reset the D sign a of is basically the same thing is here.
And then we repeat the process until we have found all of the routes.
Now I have a syntax arrow because I forgot.
Here it is.
Two dots.
Let's see again.
OK, now looks good and now we can test what we find.
So I write find route.
Car wreck terrorists take polynomial, MR Function, then we want to have three routes, then we know
already the range for our routes would be this one here, so we will search it in the range of zero
to four and then our starting step size.
I don't know yet.
We could try to follow it.
And now we get an error because here I have a typo here.
And now we run it again.
And these are the solutions that we get, we get zero point five eight five seven, which is this one
that we get to two and then we get three points for one, for just this one.
Yeah.
So you see, it really works.
And of course, we could increase the accuracy by we could also cut this one.
Here is another parameter which we could call goal accuracy.
So, for example, if they adhere to zeros, then the accuracy will be even better.
OK, so this was just a nice exercise, I think, for thinking about the routines.
How could you find a loop and then also programming these functions here and how to calculate the determinant?
So I hope you like this practice, even though it was, of course, a bit difficult in a technical sense.
But I think, yeah, it wasn't really that difficult from the physical point of view, because in the
end, it was just math and calculating routes and calculating determinants.
So now after this exercise, we can finally continue and talk more about physics and what these eigenvalues
actually mean.