Here's the question:
Employ nonlinear regression and the following set of pressure-volume data to find the best possible virial constants (A1 and A2) for the equation of state shown below. R = 82.05 mL atm/gmol K and T = 303 K.
Now, I'm currently trying to use the Gauss-Newton method, which uses this equation:
Now, I've reiterated the given formula to:
$P=RT/V+ A1/V^2+A2/V^3$
So, P will act as the y-axes, and V will act as the x-axes. I've also defined the Z matrix, filling it with $\frac{\partial P}{\partial A1}$ as the first column and $\frac{\partial P}{\partial A2}$ as the second column. Here is the snippet of the code in MATLAB:
Now, I'm confused as to how do I fill the D matrix. Based on Chapra's Numerical Methods book, I found this formula from an example:
Now it's written in the book that the D matrix is filled with the difference between measurements and the model prediction. Now my confusion lies in how can $\frac{\partial f}{\partial a0}$ serve as the model prediction?
To sum up, here are my questions:
- How can $\frac{\partial f}{\partial a0}$ serve as the model prediction?
- Am I on the right track in finding the constants for A1 and A2 by using the Gauss-Newton nonlinear regression method?
Thanks in advance.


No, you are not since $$P=\frac {RT}V+\frac{A_1}{V^2}+\frac{A_2}{V^3}$$ is linear with respect to $(A_1,A_2)$.
You just face a linear regression writing $$V^3\left(P-\frac {RT}V \right)=A_1\,V+A_2$$ This can be done by hand (I did it with my phone).