# Trouble equating two approaches to simple problem (recursion problems?)

This trouble popped up while I was deriving the simple "barometric formula". But it seems to be more of calculus (or self-referral) problem that I am having. There are two simple "known" equations.

A. P = ρg(zo-z)
P = atmospheric pressure, ρ = the density of the air, g = gravitational constant, zo = "max" altitude, z = altitude variable.​

B. ρ = PM/RT
from the ideal gas law and ρ = Mn/V, M = molar mass of air.​

To simplify the constants let H = RT/Mg ( so ρ = Pg/H). The answer at the end of this analysis is P = PoExp(-z/H).

However, this seems conditioned on the approach. For example, taking the Derivative of A then substituting in B produces

1. dP = -ρgdz (derivative of A)
2. dP = -P/Hdz (substituting in B)
Collecting variables and integrating gives the answer, P = PoExp(-z/H).

Now for the part that is weird to me, if instead we substitute first and then take the derivative then we get something that is (seemingly) impossible to reduce to the answer.

3. P = P/H(zo-z) (substituted B into A)
4. dP = 1/H d[P(zo-z)]
5. dP = 1/H (-Pdz + (zo-z)dP)
.
.

6. dP/P = -dz/(H - (zo-z))

Which is about the cleanest that I could get it, but it doesn't seem reducible to the answer above...

Both ways seem logical, but they don't seem to reconcile. Now in the first approach (which gets the right answer) we assume that ρ is independent of z in line 1. (but is it? z doesn't appear in B., but ρ depends on pressure P, which depends on z, so does that make ρ independent or dependent of z?). In the second approach, when we take the derivative (line 4.) we assume that P depends on z, forcing us to use the product rule and mess things up.

Is there a simple answer that reconciles these approaches? I.e. how can ρ be independent of z (line 1.) given equations B and A (they seem recursively dependent upon each other) and how can P be independent of z (line 4.) so that both approaches give the same answer?

Stephen Tashi
1. dP = -ρgdz (derivative of A)
I'll assume you are differentiating with respect to $z$.
if $\rho$ depends on $P$ and $P$ is a function of $z$ then you have to show a derivative of $\rho$ with respect to $z$.

Now for the part that is weird to me, if instead we substitute first and then take the derivative then we get something that is (seemingly) impossible to reduce to the answer.

3. P = P/H(zo-z) (substituted B into A)
That would imply that if $P \ne 0$ then $1 = \frac{1}{H(z0-z) }$.

Do you have a link to a page that shows the derivation of the barometric formula?

I got the answer while trying to find a good example, so thank you !!!

The reason is that the "proper" form of A. is ##P=g\int_{z}^{z_{o}}\rho(u)du ## (where u is a dummy variable for z). Instead, I had it such that the right side of A was the "integral in disguise" by assuming ρ was constant and making the integral ##=\rho z##.

So now, if we take the derivative of the proper form of A we get ##\frac{dP}{dz}=-g\rho ## (we get the minus sign from taking the derivative with respect to the lower bound)., which reduces to the answer after substitution.

Likewise, if we substitute B into A first we get ##P=\frac{1}{H}\int_{z}^{z_{o}}P(u)du##, and then taking the derivative we get ##\frac{dP}{dz}=-\frac{P}{H}##, which also leads to the answer.

So in summary, because the right side of A represents an integral (and not a simple product) when I take the derivative I get the argument back and so it doesn't matter if I substitute first then take the derivative, or take the derivative first and then substitute.