# How to derive the compressibility factor for a van der Waals gas?

So as far as I know, $$Z=\frac{p_\mathrm{r}V_\mathrm{r}}{nRT},$$ where $$\mathrm{r}$$ denotes the subscript for real.

Solving it for a van der Waals gas gave me the following result, $$Z=1+\frac{p_\mathrm{r} b}{RT}-\frac{an}{VRT}+\frac{an^2b}{V^2RT},$$ where $$V$$ is the volume of the container.

This doesn't quite tally with the form I see in the textbooks. Where am I going wrong?

• What the textbooks say ? BTW, why the new question ? Better would be to elaborate the original one. – Poutnik Apr 13 '19 at 5:47
• Provide the procedure how you have achieved the result. – Poutnik Apr 13 '19 at 5:51
• – Poutnik Apr 13 '19 at 6:50
• I have trouble typing it out in that mathy way. As you can guess, I don't know latex and i do not plan to learn it anytime soon – user226375 Apr 16 '19 at 17:05
• I did not know it a month ago either. Basics are very easy. But the point is not in the formatting itself, but in elaborated effort presented in the question. – Poutnik Apr 16 '19 at 17:07