How Many Earths?

The forthcoming solar eclipse got me thinking about how astronomically large our sun is compared to our home planet. It can be hard to wrap our heads around some of these numbers, so it’s generally helpful to think about these things relatively. If we were to fill the Sun with Earths, or fill Jupiter with Earths, then how many Earths could we fit inside of each?

We can model each astronomical object as a sphere which has a volume of,

\[V = \frac{4}{3}\pi R^3 \ .\]

In order to determine the volume of the Earth, the Sun, and Jupiter, we’ll need to find the radius, \(R\), for each. A little Googling and I was able to determine:

We’ll create some constants to store these values.

const r_earth = 6.371e6
const r_jupiter = 69.911e6
const r_sol = 696.34e6

I’ll also make a little helper function to compute the volume of a sphere. We’ll have our function accept any sort of subtype of the reals, \(\mathbb{R}\), so integers, floats, etc. and we’ll use it to map over a vector of our constants to compute each volume.

volsphere(r::T) where {T<:Real} = 4/3 * pi * r^3
(v_earth, v_jupiter, v_sol) = map(volsphere, [r_earth, r_jupiter, r_sol])

Finally, we just need to divide v_jupiter and v_sol by v_earth to determine how many Earths will fit inside of each object.

for vol in [v_jupiter, v_sol]
    @show vol / v_earth
end

>  vol / v_earth = 1321.3373996052212
>  vol / v_earth = 1.3056934161616967e6

Wow! We could fit approximately \(1,321\) Earths inside of Jupiter and approximately a whopping \(1,305,693\) Earths inside of the Sun! How incredible is that?