
Now we come to the first problem of Unit 2. This time we're still dealing with orbits.

We have a pendulum and we want to create expressions

for the position, velocity, and acceleration.

As always, we've given you some code to help you out.

Here you can see the time set, the magnitude of the acceleration due to gravity,

and the length of the pendulum, which is just the length of the

string to which the bulb of the pendulum is attached.

What we're asking you to do is to first fill in this definition of the acceleration of the pendulum

showing how it depends on the position of the weight.

Now if you think about the way that a pendulum swings, you can imagine

that if we extend the trajectory, we would get a circle.

So position is the length of this curve path.

The next thing that you need to do is to fill in this function called symplectic Euler

in which logically you will use symplectic Euler method to calculate both distance and velocity.

To help you out a little bit, here is a refresher on what the symplectic Euler method says.

Another important piece of information if you're not supercomfortable with physics stuff

is Newton's second law right here showing the relationship between force, mass, acceleration.

So looking back at our code, you can see that we've created

empty arrays for youfor position and for velocity.

It's up to you to fill these arrays in including the initial conditions.

Remember you'll need to initialize x and v where x is zero and v is zero

equals something that you're going to figure out.

I'm going to give you a few hints thoughyou can see that we've created

this constant called num_initial condition and set it to equal to 50.

What you're really doing overall in this problem is looking at 50 different pendulums

which each have different initial values for x and v, and to give you a visual of what this looks like,

I'm going to show you the final plot that you'll get with this program.

So here's the set of graph that you should get as your final result if the program is working correctly.

You're going to ignore these top two graphs for now. Let's focus on this bottom plot.

This is showing velocity on the vertical axis and position on the horizontal axis.

If we look at the top two graphs, we can see that this green set of points right here

corresponds to what's happening at time zero.

Since green ellipse down here is showing the set of initial conditions

for the 50 different pendulums that we're looking at.

This green ellipse is kind of like a snap shot of what's happening

to all these different pendulums at time zero.

The way that I want you to figure out how to set

the values for each pendulum for x and for v is just think about this ellipse.

Now in Unit 1 you learned about orbits and you'll actually be able to use

some of that knowledge in this problem knowing that this green shape is an ellipse.

You can see that its major axis right here lies along the line v=0

and its minor axis lies along this line x=2.

Now the half length of the major axis is 0.25

so I guess actually it don't looks like the major axis here.

It's really the minor axis if these two sets of axes had the same scales applied to them.

Either way, this rightmost point on ellipse corresponds to x=2.25

and the leftmost point corresponds to x=1.75.

In terms of v, we have values ranging from 2 down here to 2 up here.

So think about what equations for x and v you'll need to create an ellipse with these dimensions.

That would be how you set the initial conditions for x and v.

I think this is a very interesting problem so I hope you enjoy doing it. Good luck.