Doubt in derivation of pressure exerted by ideal gas In books the derivation of pressure exerted by a gas on a closed container is derived for a cubical geometry, but since it contains number of molecules per volume (denote it by $n$) the books say it's independent of geometry. My question is how they say it's independent of geometry because we get this $n$ for cube only, how can we be so sure that this holds for any super complicated and distorted volume?
 A: Here is a version of a derivation given by J H Jeans. It doesn't consider any specific shape of box, but concentrates on the molecules that are about to hit a small patch of wall.
Consider the molecules that will hit a small area, $A$, of wall of a container of any shape in time $\Delta t$. Those with a velocity component $u_n$ perpendicular to the wall and towards the wall will be contained in a volume $Au_n\Delta t$. So the total momentum normal to the wall brought up to this area in this time is
$$\delta p = \sum_{n=1}^N (mu_n) \times Au_n \nu_n\ \Delta t\ \ \ =\ \ mA\Delta t\sum_{n=1}^N  \nu_nu_n^2$$
in which  $\nu_n$ is the number of molecules per unit volume with the velocity component $u_n$. The summation is over positive values of $u_n$.
Now the mean momentum carried by molecules reflected at the wall will be equal and opposite to those approaching, and so will be
$$-mA\Delta t\sum_{n=1}^N  \nu_nu_n^2$$
in which the summation is over negative values of $u_n$.
So the total momentum change will be
$$\delta p =  mA\Delta t\sum_{n=1}^N  \nu_nu_n^2\ \ \ =\ \ mA\Delta t\ \nu \overline {u^2}$$
in which the summation is over $all$ values of $u_n$. $\overline {u^2}$ is the mean square velocity component normal to the local wall area and $\nu$ is the total number of molecules per unit volume, in other words, $\nu=N/V$.
It is straightforward to show using isotropy that
$$\overline {u^2}=\tfrac 13 \overline {c^2}$$
in which $\overline {c^2}$ is the mean square speed of the molecules.
So we find that the pressure is given by
$$p=\frac {1}{A \Delta t}mA\Delta t\ \nu \overline {u^2}\ \ \ = \tfrac13 \tfrac NV m \overline{c^2}$$
Note 1 The isotropy assumption allowed us to choose any orientation of surface patch to evaluate the pressure, and to claim that the pressure is independent of surface orientation. This is equivalent to saying that the pressure is independent of the shape of the container, for a given container volume. So you could – though it wouldn't be very elegant – establish the pressure equation for a cubical box, and then conclude that it holds for any shape of box.
Note 2 It is not essential to think of gas pressure in terms of an interaction between the gas and the walls of a container. We can instead think of a small surface, orientated however we like, in the middle of the gas. We can then define pressure in terms of momentum transfers to and from this surface. Clearly exactly the same arguments apply as if the surface were part of the container walls. And of course, we can just imagine the surface. So we are led to think of pressure as (1) a bulk property of the gas (as opposed to one that makes sense only at the container wall), and (2) a property that is independent of direction (because no direction is special – isotropy).
I suspect that this is somewhere near Cyberax's viewpoint. No doubt I'll be told if I'm wrong here.
A: You said it yourself , it depends on the number of molecules per volume not the total number of molecules. And by saying so it means you are only considering about the density of gas contained in the closed objest whatever it may be. And also density of gas will not change by changing the shape of container.also the main formula for net pressure has total mass and volume as final factors which can change depending on the shape of the container.
