We can solve this problem by using conservation of energy. The potential energy stored in the compressed spring is converted into kinetic energy of the projectile as it is launched, and then into potential energy as the projectile rises to its maximum height.
The potential energy stored in the compressed spring is given by:
U = (1/2)kx^2
where k is the spring constant and x is the distance the spring is compressed. This potential energy is converted entirely into kinetic energy of the projectile when it is launched, given by:
K = (1/2)mv^2
where m is the mass of the projectile and v is its velocity. We can find v by using conservation of energy again, as the kinetic energy at launch is equal to the potential energy gained by the projectile as it rises to its maximum height:
K = U = mgh
where g is the acceleration due to gravity and h is the maximum height reached by the projectile.
Substituting the expressions for U and K and solving for x, we get:
x = sqrt(2mgh/k)
Plugging in the given values, we get:
x = sqrt(2 * 0.0209 kg * 9.81 m/s^2 * 5.0 m / 1200 N/m)
x = 0.179 m
Therefore, the spring was initially compressed by a distance of 0.179 meters.