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.).
#### Exercise 1
Create an object which moves across the screen at some defined angle $\theta$. If using Glowscript, attach one arrow which points in the direction of motion and one which points perpendicularly.
#### Exercise 2
Create a function $y(x)$ in code which returns the result of an arbitrary mathematical function $y(x)$ for a given $x$. For example, if the function were defined as $y(x) = x^3$, then the code
```
y(4)
```
should return the value $4^3 = 64$. Next, create a function $dy(x)$ which numerically calculates and returns the first derivative $y' = dy/dx$ of a function for a given $x$ using the finite difference method. (This removes the need to analytically calculate derivatives for each new function tried.) Using $y(x) = x^3$,
```
dy(4)
```
should return the value $3(4)^2 = 48$. Next, create a function $d2y(x)$ which numerically calculates and returns the second derivative $y^{\prime\prime} = d^2y/dx^2$ of a function using the finite difference method. Using $y(x) = x^3$,
```
d2y(4)
```
should return the value $6(4) = 24$. Finally, recognizing that the angle of a function at any point is related to $y'$, create a variable $\theta$ that calculates this angle from $y'$. Using $y(x) = x^3$,
```
atan(dy(4))
```
should return the value $\tan^{-1}(48) \approx 1.55 \text{ rad}$.
#### Exercise 3
Pick an interesting function over which the bead should move. The function is now a wire, and the object is a bead on the wire which begins its motion due to gravity, so choose the starting point to have a downward slope if there is no initial velocity. (Some interesting examples include $-x$, $\tanh(x)$, and $e^{-x}\cos(\pi x)$.) Draw your function on the screen for a given interval range of $x_\mathrm{i}\leq x \leq x_\mathrm{f}$ and place a small object at $(x_\mathrm{i}, y(x_\mathrm{i}))$. It will be helpful to numerically calculate and record the minimum value of the function in this range here to give a reference point for potential energy later on.
#### Exercise 4
Using the results in the **Theory** section, create a loop which repeatedly calculates the acceleration of the bead and updates its position along the wire for given friction and drag force parameters. This will require first calculating the angle of the function at the point where the bead currently sits and updating its value at each step. If your chosen function is such that the bead reverses direction at some point, have it stop at that point. Realistic ranges for constants are $0.001 \leq m \leq 0.3$ kg, $0 \leq \mu \leq 1$, and $0 \leq D \leq 0.1$ kg/m, but trying values out of that range may also yield important physical insights.
#### Exercise 5
Using the calculation of the normal force in the **Theory** section, create a graph which displays $|\vec n|$ vs. $x$, but make $|\vec n|$ negative if $n_y$ is negative. (This is an indication that the bead would fly off it weren't attached.) If using Glowscript, create an arrow that points in the direction of $\vec n$ and an arrow that points in the direction of the friction and drag forces. Finally, create a graph that displays the kinetic, potential, and total energies of the bead vs. $x$. A good check that your code is working correctly is that the total energy should remain constant if there are no friction or drag forces. When the bead has reached the end of the wire, print $|\vec v|$ and the time $t$ that has elapsed.
#### Exercise 6
Try various functions without resistive forces to see which one allows the bead to reach the endpoint in the least amount of time. Be sure to scale compared functions so that the height difference between the beginning and end of each function is the same to accurately compare the results.