# Bungee code¶

This is the solution to the bungee problems in Skydiving 2. We recommend that you try to solve the problems before you look at this solution.

As before, we begin by importing Pylab and declaring all the parameters we need.

We define the “cord force” as a function of x and use an $$\verb+if+$$-test to check if x is above or below zero

We define the acceleration as a function of both position, $$\verb+x+$$, and velocity, $$\verb+v+$$.

We define $$\Delta t = 0.01$$, $$T=60$$ and $$n=T/dt$$

We declare three arrays, one for the velocity $$v$$ , one for the position $$x$$ and one for the time $$t$$. We want the arrays to be empty and have room for n+1 elements, so we use the $$\verb+zeros+$$ command.

We set the first element in the x-array to be $$x_0$$ and the first element in the v-array to be $$v_0$$

We declare one array for the g-forces

We use range to create a $$\verb+for+$$ loop that iterates over $$n = 0,1,2,..,N$$. Inside the loop, we use the formulas from the tutorial to calculate $$\verb!t[n+1]!$$, $$\verb!v[n+1]!$$, $$\verb!x[n+1]!$$ and $$\verb!gforces[i]!$$

We plot the position vs. time

We plot the g-forces vs. time