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: Derive the Equations of Motion
---
The Lagrange points are the Solar System's favorite parking spots. Named for Italian mathematician Joseph Louis Lagrange, Lagrange points are locations where a small object can rotate synchronously with a moon or planet as that object rotates around another object like a planet or the Sun. In the Earth-Sun system, for example, the Lagrange points are locations where NASA can put a telescope like the [James Web Space Telescope](https://en.wikipedia.org/wiki/James_Webb_Space_Telescope) and it will orbit the Sun but at exactly the same rate as the Earth orbits the Sun.
For simplicity we will assume that the Earth orbits the Sun in a circular orbit with exactly 1 AU between their centers of mass. It turns out that this assumption is not actually necessary, but it does make things conceptually simpler.
To find the Lagrange points we need to define a coordinate system with the origin at the center of mass of the Earth-Sun system. Place the Sun along the $-\hat{x}$ axis at $x = - R_\odot$ and the Earth along the $+\hat{x}$ axis at $x = R_E$. Using Newton's Law of Gravitation, show that the acceleration experienced by a small mass located at $(x, y)$ is given by
$$ a_x (x, y) = - \frac{G M_\odot (x + R_\odot)}{((x + R_\odot)^2 + y^2 )^{3/2}} - \frac{G M_E (x - R_E)}{((x - R_E)^2 + y^2 )^{3/2}} $$
$$ a_y (x, y) = - \frac{G M_\odot y}{((x + R_\odot)^2 + y^2 )^{3/2}} - \frac{G M_E y}{((x - R_E)^2 + y^2 )^{3/2}} $$
To rotate synchronously with the Earth an object would need to have an acceleration at the Lagrange point $\left[ x_L, y_L \right]$ such that
$$\vec{a} (x_L, y_L) = \left[ - \omega^2 x, - \omega^2 y \right] $$
Combine these to show that the Lagrange points are found when
$$ 0 = - \frac{G M_\odot (x + R_\odot)}{((x + R_\odot)^2 + y^2 )^{3/2}} - \frac{G M_E (x - R_E)}{((x - R_E)^2 + y^2 )^{3/2}} + \omega^2 x $$
$$ 0 = - \frac{G M_\odot y}{((x + R_\odot)^2 + y^2 )^{3/2}} - \frac{G M_E y}{((x - R_E)^2 + y^2 )^{3/2}} + \omega^2 y $$
are satisfied.
#Exercise 2: Plot the Right-Hand Side of the Equations of Motion
---
It is often useful when looking for solutions of nonlinear equations to move all the terms to one side (usually the right-hand side) and then look for places where the right-hand side equals zero. Finding zeros of nonlinear equations can be done using iterative methods such as Newton's method, but these require an initial guess.
To get some idea of where to guess it is often useful to plot the expressions which we wish would equal zero - the right-hand sides. This gives us "the lay of the land". Using an appropriate 2D plotting routine create plots of the right hand sides for interesting regions where you might go looking for Lagrange points.
#Exercise 3: Find the First Three Lagrange Points
---
The first three Lagrange points can be found by making an intelligent guess, namely that a good place to look is along the x-axis where $y = 0$. S
how that this satisfies the y equation and simplifies the x equation. With this simplified single equation, use Newton's method along with some good guesses from Exercise 2 to find L1, L2, and L3.
#Exercise 4: Find L4 and L5
---
The fourth and fifth Lagrange points do not lie along the x-axis, so we need to bring back the y equation we threw out in the Exercise 3. This will require the use of the generalized version of Newton's method for systems of equations. Use your new version of Newton's method to find L4 and L5.
#Exercise 5: Use an Optimized Library to Find the Lagrange Points Faster
---
Newton's method is roughly 400 years old, so it should come as no surprise to you that we can do better. For example, Newton's method requires us to be able to take analytical derivatives, which is not always possible and/or easy. Newton's method fails if the Jacobian matrix becomes singular, and it has a tendency to be very picky about the initial conditions it is given. It also shouldn't surprise you that your implementation of Newton's method isn't using your computer as efficiently as it could.
To solve this find an improved root-finding algorithm in a suitable computational library for your programming language. For examples, look at SciPy.Optimize for Python, the Optimization package in Matlab, MINPACK in Fortran, the GNU Scientific Library in C/C++, or the Intel Math Kernel Library for both C/C++ and Fortran. Using the online documentation find an appropriate routine, figure out how to feed in your problem, and interpret the output. Measure how much faster the new routine is than your implementation of Newton's method.
#Exercise 6: Are the Lagrange Points Stable or Unstable Equilibria?
---
Once you have found the Lagrange points, you know that if an object is placed exactly at each of those points the object will stay there relative to the Sun and Earth. But what if they aren't perfectly at the Lagrange point? Are those locations stable equilbria such that an object will oscillate back and forth around the Lagrange point, or are they unstable such that the object will accelerate away from the Lagrange point over time? To check this we need to compute the eigenvalues of the Jacobian at each Lagrange point. Take the eigenvalues of the Jacobian and characterize each of the Lagrange points as stable or unstable.