Tuesday, August 3, 2021

Linear Least-Squares Regression

Problem 14.7.


The following data were gathered to determine the relationship between pressure and temperature of a fixed volume of 1 kg of nitrogen. The volume is 10 m3.
Employ the ideal gas law pV = nRT to determine R on the basis of these data. Note that for the law, T must be expressed in kelvins. 

Solution:


Step 1: Rearrange ideal gas law with p in terms of T. 
p = (nR/V)T
Note that the above expression is a linear equation (intercept = 0, slope = nR/V).

Step 2: Apply criteria for best-fit line by minimizing the sum of squares of the residuals.
The sum of squares of the residuals can be written as:





To determine the value for a1, the above equation is differentiated with respect to the unknown:




Next, setting the derivative equal to zero will result in minimum Sr:







Therefore, 




Step 3: Set up the data given in tabular form and compute the necessary sums. 











a1 = 20601452.5/693933.5 = 29.688
Thus, the best-fit line is p (N/m2) = 29.688T (K). 

Step 4: Determine R based on the slope of best-fit line. 
First, we need to compute n (no of moles of nitrogen):
n = 1 kg / 28 kg/kmol = 0.035714 kmol
Given volume, V = 10 m3. Since nR/V = slope = 29.688, R = 29.688V/n.




R = 8.3127 J/mol.K
*Try to verify the unit.

No comments:

Post a Comment

Numerical Integration Formulas

Here are the M-files to implement composite trapezoidal rule for equally spaced data and unequally spaced data.  Composite Trapezoidal Rule ...