Weighing the Atmosphere:
Atmospheric Mass
Andy Long
Calculus I

According to the National Center for Atmospheric Research, “The total mean mass of the atmosphere is 5.1480 ×(10^18) kg....” 

Let’s see if we can show that. Notice the strange scale for the mass density:

M=∫dM

That mass density function (in blue) looks linear, but the scale along the left looks funny. The power of 10 decreases linearly as you scan down the y-axis. So if we model the power of 10 as a function of altitude as a linear function, we have to pass a line through two points -- perhaps (0,-3) and (150,-12)

(* use slope intercept form for the power: *)
power[r_]:=-3+(-3/50)r
ρ[r_]:=10^power[r] (* in units of gm/cm^3 *)
ρ[r]
Plot[power[r],{r,0,150}] (* this should look like the straight line density above *)
(* Notice that r is the height above the surface of the Earth *)

Spherical shells of atmosphere out r km above the radius of the Earth have volumes ΔV=4π(R+r)^2Δr, 
where R is the radius of the Earth (approximately 6360 km), and 
ΔM=ρ[r] ΔV
so in the end, 
M=(∫_0^160)ρ[r]4((π(R+r) )^2)dr

unitConversion= (10^5)^3 (* (cm/km)^3 *) * (10^-3) (* kg/g *) * 1.0
Integrate[ρ[r] 4π (r+6360)^2, {r, 0, 160}] * unitConversion

(* not much advantage in going further out: the air is too thin! *)
Integrate[ρ[r] 4π (r+6360)^2, {r, 0,  Infinity}] * unitConversion