These exercises are not tied to a specific programming language. Example implementations are provided under the Code tab, but the Exercises can be implemented in whatever platform you wish to use (e.g., Excel, Python, MATLAB, etc.).

**EXCERCISE 1:**
Write the function gravAccel(totalmass, position) that takes the mass of the object exerting the gravitational force, and the position relative to it as parameters, and returns the resultant gravitational acceleration. Make the function take the direction of the force into account. A positive position corresponds to being above the object, and a negative position corresponds to being below the object.
___
**EXERCISE 2:**
Use the Earth's total mass and radius to calculate the density of a uniform Earth.
Using this density, write the function sphereMass(distance) that takes the distance from the center of the Earth as an argument, and returns the mass of a sphere with that distance as radius, and with the same density as the uniform Earth. (This sphere will be the equivelant of the red area in the figure above.) Why was it specified that the function takes distance as an argument, and not position?
earthMass = 5.972 * 10**24 #The Earth's total mass in kg
earthRadius = 6.371 * 10**6 #The Earth's radius in metres
___
**EXERCISE 3:**
Using the gravAccel function, the sphereMass function, and the implications of the Shell Theorem, write the function uniformGravityAccel(position) that calculates the gravitational acceleration at any position relative to the center of a uniform Earth.
___
**EXERCISE 4:**
Do the Euler-Cromer calculation of a fall through a uniform Earth with the initial conditions from above, and an acceleration given by the uniformGravityAccel function. (The current position during the loop will in this case be position[i])
Here is a template for how the Euler-Cromer method can look:
for i in range(n-1):
acceleration[i] = function(arguments)
velocity[i+1] = velocity[i] + acceleration[i] * dt
position[i+1] = position[i] + velocity[i+1] * dt
acceleration[n-1] = function(arguments) #This last line simply lets the final acceleration value be filled in for plotting, although it is not used for the calculation
___
**EXERCISE 5:**
**a)** Run the above code so that position, velocity and acceleration are plotted side by side.
**b)** Find the time it takes to fall through the uniform Earth.
**c)** Find the maximum velocity along the way.
**d)** Comment on the results. Why do the graphs look the way they do? And specifically:
* Why are the plots for position and acceleration so similar? (look at acceleration as a function of position, and the properties of the derivative of sine waves)
___
**EXERCISE 6:**
As you start falling, from the right of the graph, the acceleration will first stay nearly constant before increasing slightly until about 3500km from the center. Why is this? Where in the Earth's structure is gravity the strongest?
___
**EXERCISE 7:**
Be careful to not give your arrays and variables the same names as previous ones.
**a)** Define the lists or arrays that will hold the positions, velocities and accelerations at any given time during the fall. Use a time step of 1 second, and 5000 iterations in your loop.
**b)** Make the starting distance from the center equal to the radius of the Earth, and make the starting velocity 0 m/s.
**c)** Define a list or array that holds all of the different times, for plotting.
___
**EXERCISE 8:**
Do the Euler-Cromer calculation of a fall through a uniform Earth with the initial conditions from exercise 7, and an acceleration given by the realGravityAccel function.
___
**EXERCISE 9:**
Plot your results from exercise 8 (position, velocity and acceleration as a function of time).
___
**EXERCISE 10:**
**a)**
Explain why these graphs look so different to the ones in the uniform case:
How and why are the acceleration graphs different?
How and why are the velocity graphs different?
How and why are the position graphs different?
**b)**
Find the time it takes to fall through the non-uniform Earth.
Why would it take less/more time to fall through the non-uniform Earth when the Earth's total mass is the same in both cases?
**c)**
Find the maximum velocity along the way. When is this velocity reached?
Why was it higher/lower when the Earth's total mass is the same in both cases?
Some optional brain teasers:
* If you started in the center, how fast would you need to go to reach the surface?
* What would eventually happen if you included air resistance in your model?
* Could the Earth's rotation affect the fall in any way?
* Why is it extremely difficult to dig a tunnel through the Earth?