So let's begin and let's implement these equations.
And of course, first of all, we must implement all three of those.
And we write death and then we can use the same method as before.
So you see, this is pretty, pretty powerful and universal methods.
And we just write everybody.
And then we could have just roads T and R.
And what I write then is just for simplicity.
X y z is equal to ALM.
So this means that three individual components will be stored in the variables called X, Y and Z.
And the first derivative of X I call X one is equal to eight times Y means X and then Y one is equal
to X times in brackets B minus C minus Y and z one is equal to x times y minus z c times z.
And then we return everything and we return x1, y1, Z1.
So you see, it's the same logic or the same methods or methodology behind it, where we return three
individual values, which are the right hand side of these equations.
And all of this is just to make it look nicer and to name these things.
But we could have just wrote here, for example, here we could have written eight times our brackets,
one minus our brackets zero.
So we could have implemented this thing here in just a single line of code.
And now we have this function.
Sorry, first, I must run this and then this, and now we can look at some solutions.
And as I told you, the system has chaotic and non chaotic solutions.
And it turns out you can investigate this in more detail.
It turns out that this constant be here is determining if it is chaotic or non chaotic.
We will start with a chaotic solution.
So let's continue and let's define the parameters for the function so we can right here.
For example, a is equal to then a typical set of parameters would be 10.
And then something larger than 24 Dot seven four.
So, for example, 50 and see, I just used a typical value that is used everywhere in literature that
gives a nice butterfly, which would be eight over three.
But you can play it with the parameters here and now I want to show you a nice trick.
So you see, we want to later on change these parameters.
So this means later on we would have to change these values and then redefine the function.
But we can also do it in a different way.
So I paste them here and then we must right here a b c as parameters or as our input values here for
the function itself.
And then we just have to change one thing when we call the the command from this Typekit module dot
integrate.
So let me show you how this works.
So we right solution is equal to and like before the right integrate thought, so underscore IVP.
Then first the function, then the times which would be t start come off t end.
So this would be t start equal to zero T and equal to 50, for example.
Then we continue to rewrite x zero y zero zero.
So this would be the starting positions.
So let's just use some values here.
And they made a typo here.
Yup.
So now it looks good.
And the methods we want to use once again, the cutoff 45 methods, then we want to give it the time
values.
So of course, this is not really necessary to do, but to generate nice plots and to know everything
about the intermediate time between zero and 50.
It's always helpful to have this trial in space from teh start to T and then the number of steps, for
example, like this.
And now comes the difference.
So if it would run this now, it would not work because in our function, we have to find several inputs
here.
And the integrated solve underscore IVP only knows how to handle functions with the arguments T.
And then here are our can be in the right.
But then it doesn't know what is ABC, so we must specify that ABC are parametres that do not change.
So we write.
This arcs is equal to in brackets, a comma, become a C.
No, it uses these values that we have to find here and treats them as arguments in the function f o
d e.
And of course, they have to be called exactly like here.
So now if I run this and if I run this, oh no, I get a problem here because I made a typo and T and
not a typo.
Yes.
No, it works.
Sorry for the two typos, and then we can continue and plot the trajectory.
So the right plot trajectory, this will be the name of our plot peel dot axes.
And first of all, since it's three dimensional system, we must activate the 3D option and then we
can go ahead and write plot trajectory
is equal to.
No, that's not correct.
Plot trajectory dot plot three and then we must adhere the X, Y and Z coordinates.
So this will be a solution.
Thought why X component will be the first component with the index zero one two, and then we can change
into line with to make this plot look a bit nicer.
For example, like this.
So you see here is our butterfly.
We start from this particular point, which I think corresponds to one zero zero, and then it moves
around these two points in space.
And I've written already before here, that's too repulsive.
Points exist.
And so these are here, these centers.
So the trajectory of the particle will move on a trajectory around these around these repulsive points.
And now we want to check if this is really a chaotic solution.
So let me add here.
Another calculation was I just copied this line of code and call it solution two, and I would just
briefly change the starting conditions, so just multiply the X zero by 1.1
and oops, sorry, 1.1 times x zero.
And now we can add here and other plots so we can just copy and write solution to solution two, solution
two.
And now we see here two of these trajectories on top of each other.
And you see at the starting position you see really hit blue and an orange line almost perfectly on
top of each other.
And then at a later point of time, you see here these two lines, they don't agree with each other
anymore, and the position at the end of time is then totally different, of course.
So we can compare just by writing solution dots y and then all of the coordinates at the last point
of time that we have calculated would be this one and would be this one.
So you see quite different, even though in the beginning they were just positioned at one zero zero
and 1.1 zero zero.
And this is what is meant when people say that this is a chaotic system and that a butterfly effect
exists where if you don't exactly and precisely know the starting conditions, you don't anymore know
about the end positions, even though the system is of course, deterministic and it's not a quantum
system, it's really a classical, deterministic system, but it behaves chaotic.
So now I just want to analyze this in a bit more detail.
The first thing is that we have here such a bad resolution, so it's really hard to see anything.
So what we can do is we can save it.
So let's safe fig and then we give it a name.
For example, Lauren's trying to read thoughts PMG and to increase the resolution.
Oops.
Sorry.
You're right.
DPI dots per inch and then quite a high number, for example, three hundreds.
And now I can open this.
So file open.
And here it is.
So you see here, you can really much better see, you know, the trajectory, and at the beginning,
the two lines orange and blue are really on top of each other.
And then the keep on top of each other.
But then it's, of course, a bit hard to see here because you cannot follow all of the trajectory.
But, you know, at some point, the two trajectories will be independent of each other.
And then the really just the chaotic behavior winds over the over the deterministic behavior.
All right.
So
we have also figured this out by looking at the coordinates that are here totally different, especially
X and Y.
And this is really the indication of this chaotic behavior.
The last thing that we can do is before I will zoom in on the last thing that we can do is analyzing
the coordinates.
And for this, we can just write Peel T dot plot and then we plot the solution dots T versus just one
of the coordinates, for example, the X coordinate like this.
And so you see how there are so many sign changes here.
So the X coordinate over time changes from negative to positive over and over again.
And this is whenever a particle is closer to this one or to this one.
Of course, we could also analyze hit y coordinate, and it's the same thing, basically.
And for the Z coordinate, it's different because you see both of the wings of this butterfly, they
are at positive values.
So it really makes more sense to use here X or Y as the coordinates that we want to analyze.
All right.
So we have now figured out what this chaotic behavior means, and we have seen that we can really propagate
this differential equation and that we can solve such differential equations in three dimensions that
depend on each other.
So here the coordinates X, Y and Z are not independent of each other as before.
But here really, we have three couples differential equations.
But still, it was no problem we could have.
We could use the same methods, which is to find a function, return the three right hand sides of the
equations.
And then we just call, integrate, dot, solve, underscore IVP and then plot the solution and analyze
it.