Deriving pressure from particle velocity: missing 1/3 factor
Let us assume we have a perfect gas, isotropic, homogeneous, inside a cube of side a.
We want to calculate the pressure as a function of the velocities of the particles inside.
We must find the total force this particles impart as a function of their speed. We know $$Fdt = mdv \rightarrow F = m*dv/dt$$.
$$p = \frac{F}{S}$$
Let me discuss a single particle only in the x axis because the system is isotropic:
From a hit of a wall and the hit of the opposite wall it passes
$$v = ds/dt = a / dt \rightarrow dt=a/v \rightarrow 1/dt = v/a$$
So in an arbitrary time $dT$ we have $dT/dt$ collisions.
A single particle considering only the x axis transfers this much quantity of motion in a time $$dT \rightarrow Q_x = 2mv_x * dT/dt$$
$$Q_x = 2mv_x$$ for a single collision because v changes sign but not magnitude (elastic collision)
So in the given time a particle inflicts on the wall a force of:
$$F_x = Q/dT = 2mv_x * dT/dt / dT = 2mv_x / dt = 2mv_x * v_x / a = 2m*v_x^2 /a$$
summing all the particles (there are N of them, m is the same for all of them, avg is short for average, $\rho$ is density, S=2a the two opposite vertical walls):
$$F_{x_{tot}} = \sum 2m*v_x^2/a = 2m \sum v_x^2 /a= 2mN * avg(v_x^2)/a$$
$$p_x = \frac{F{x_tot}}{S} = 2mN * avg(v_x^2)/2a*a^2 = \rho * avg(v_x^2)$$
Given that pressure is a scalar to get total pressure I sum all the pressures, (x,y,z) and they are all the same because the system is isotropic.
$$p = \rho * avg(v_x^2) + \rho * avg(v_y^2) + \rho * avg(v_z^2) = \rho * avg(v^2)$$
But while the physical values are correct I am missing a factor of 1/3 in the final equation, what is the correct way to sum the components of the pressure? Did I make other errors? Also given that pressures is a scalar how am I allowed to use $p_x$? What does it mean? 512