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: Motion of a charged particle in a uniform magnetic field
Consider a uniform magnetic field, of strength $10^{-4}$ T, in the $z$-direction. An $\alpha$-particle enters the magnetic field at initial position $(0.0,0.0,0.0)$, with an initial velocity $31000\frac{m}{s}$ in the $x$-direction.
- What do you expect the $\alpha$-particle's trajectory to be shaped like?
- Write the equations of motion for the $\alpha$-particle in the uniform magnetic field. Solve the equations analytically.
- Describe in words (or pseudocode) a procedure to numerically solve these equations of motion for the trajectory of the $\alpha$-particle.
- Now, use your numerical method or a differential equation solver to find a numerical solution to the equations of motion you wrote down. The special case of a uniform magnetic field has an analytical solution, but many cases do not. Validate your code: Does the shape of the $\alpha$-particle's trajectory match your expectation and your analytical calculation?
- How would your results be different for an $H^-$ ion that enters the magnetic field? Confirm by running the code with parameters for the $H^-$ ion with the same initial velocity that the $\alpha$-particle had. Plot the $\alpha$-particle's trajectory and the negative ion's trajectory on the same plot.
### Exercise 2: Motion of a charged particle in the magnetic field of a magnetic dipole
Now, consider the magnetic field of a *magnetic dipole*, which has a magnetic field given by
$$ \vec{B}(\vec{r}) = \frac{\mu_0}{4\pi} \left( \frac{3\vec{r}(\vec{\mu}\cdot\vec{r})}{r^5} - \frac{\vec{\mu}}{r^3} \right). $$
Let the magnetic dipole moment have a magnitude $\vert \vec{\mu}\vert = 10^4$.
An $\alpha$-particle enters the vicinity of this magnetic dipole at initial position $(0.0, -8.0, 2.0)$ with an initial velocity $100.0\frac{m}{s}$ in the $y$-direction.
- First, let the magnetic dipole moment point in the $z$ direction. Make a vector plot of the resulting magnetic field.
- Make a hypothesis about what the $\alpha$-particle's trajectory will be shaped like - describe in words, or accompany with a drawn diagram.
- Modify your code from Exercise 1 to simulate the motion of the $\alpha$-particle in this magnetic field. Plot the $\alpha$-particle's trajectory, and compare with your hypothesis. Also, compare and contrast this result with the $\alpha$-particle's trajectory in the uniform magnetic field in Exercise 1.
- Now, let the dipole moment point at a 23 $^\circ$ angle with respect to the $z$-direction, and simulate the $\alpha$-particle's motion in this magnetic field. Start the alpha particle with initial position $(0.0, -8.0, 0.0)$. Plot the $\alpha$-particle's trajectory - compare and contrast this result with your previous results.
### Exercise 3: Motion of a charged particle in a 'magnetic bottle'
In the previous exercises, you should have observed that the charged particles can be confined in a given region of space by a magnetic field. This serves a variety of purposes in experiments such as mass measurements and in applications such as magnetic-confinement fusion.
One interesting configuration is the "magnetic bottle". Experimentally, a magnetic bottle can be constructed with a pair of coils that have electric current running through them. We will model this setup with a pair of magnetic dipoles.
- Place one magnetic dipole at $z=10.0$, and the other at $z=-10.0$. Let both dipole moments point in the positive $z$-direction, with equal magnitude $10^4$. Make a vector plot of the resulting magnetic field, and describe your plot.
- Make a hypothesis about what the charged particle's trajectory will be shaped like. Based on your vector plot and your physics knowledge, do you predict that the particle will be successfully confined? Why or why not?
- Modify your code from the previous Exercises to simulate the motion of the $\alpha$-particle in this magnetic field. Start the $\alpha$-particle at position $(-5.0, 0.0, 0.0)$, with initial velocity $100.0\frac{m}{s}$ in the $z$-direction. Plot the $\alpha$-particle's trajectory, and compare with your hypothesis. Also, compare and contrast this result with the $\alpha$-particle's trajectory in the uniform magnetic field in Exercise 1 and the dipole magnetic field in Exercise 2.
- For further insight into the charged particle's trajectory, make a plot of the particle's $z$-coordinate vs. time. What does this plot tell you about the particle's motion? Is the particle successfully confined, or do you think it will eventually escape?