Determination of absolute zero temperature.
According to Charles’s law for an ideal gas, at constant volume, a linear relationship exists between the pressure, p, and temperature, T. In the experiment shown in the figure, a fixed volume of gas in a sealed container is submerged in ice water (T = 0°C). The temperature of the gas is then increased in ten increments up to T = 100°C by heating the water, and the pressure of the gas is measured at each temperature. The data from the experiment is:
\begin{array}{clllllll}T\left({ }^{\circ} \mathrm{C}\right) & 0 & 10 & 20 & 30 & 40 & 50 & 60 \\ p(\mathrm{~atm} .) & 0.94 & 0.96 & 1.0 & 1.05 & 1.07 & 1.09 & 1.14 \\ T\left({ }^{\circ} \mathrm{C}\right) & 70 & 80 & 90 & 100 & & & \\ p(\mathrm{~atm} .) & 1.17 & 1.21 & 1.24 & 1.28 & & & \end{array}Extrapolate the data to determine the absolute zero temperature, T_{0}.
This can be done using the following steps:
(a) Make a plot of the data (p versus T).
(b) Use linear least-squares regression to determine a linear function in the form p=a_{1} T+a_{0} that best fits the data points. First calculate the coefficients by hand using only the four data points: 0,30,70, and 100^{\circ} \mathrm{C}. Then write a user-defined MATLAB function that calculates the coefficients of the linear function for any number of data points and use it with all the data points to determine the coefficients.
(c) Plot the function, and extend the line (extrapolate) until it crosses the horizontal (T) axis. This point is an estimate of the absolute zero temperature, T_{0}. Determine the value of T_{0} from the function.
(a) A plot (p versus T) of the data is created by MATLAB (Command Window):
>>T=0: 10: 100;
p=[latex]\left[\begin{array}{ll}0.94 0.96 1.0 1.05 1.07 1.09 1.14 1.17 1.21 1.24 1.28\end{array}\right][/latex];
>>plot t(T, p,'*r')
The plot that is obtained is shown on the right (axes titles were added using the Plot Editor). The plot shows, as expected, a nearly linear relationship between the pressure and the temperature.
(b) Hand calculation of least-squares regression of the four data points:
(0,0.94), \quad(30,1.05), \quad(70,1.17), \quad(100,1.28)
The coefficients a_{1} and a_{0} of the equation p=a_{1} T+a_{0} that best fits the data points are determined by using Eqs. (6.14). The summations, Eqs. (6.13), are calculated first.
Substituting the Ss in Eqs. (6.14) gives:
\begin{aligned} & a_1=\frac{n S_{x y}-S_x S_y}{n S_{x x}-\left(S_x\right)^2}=\frac{4 \cdot 241.4-(200 \cdot 4.44)}{4 \cdot 15800-200^2}=0.003345 \\ & a_0=\frac{S_{x x} S_y-S_{x y} S_x}{n S_{x x}-\left(S_x\right)^2}=\frac{15800 \cdot 4.44-(241.4 \cdot 200)}{4 \cdot 15800-200^2}=0.9428 \end{aligned}
From this calculation, the equation that best fits the data is: p = 0.003345 T + 0.9428.
Next, the problem is solved by writing a MATLAB user-defined function that calculates the coefficients of the linear function for any number of data points. The inputs to the function are two vectors with the coordinates of the data points. The outputs are the coefficients a_{1} and a_{0} of the linear equation, which are calculated with Eqs. (6.14).
Program 6-1: User-defined function. Linear least-squares regression.
function [a1,a0] = LinearReqression(x, y)
% LinearRegression calculates the coefficients al and aO of the linear
% equation y = a1*x + a0 that best fits n data points.
% Input variables:
% x A vector with the coordinates x of the data points.
% y A vector with the coordinates y of the data points.
% Output variables:
% a1 The coefficient a1.
% a0 The coefficient a0.
nx=lenqth(x);
ny=lenqth(y);
if nx ~ = ny
disp('ERROR: The number of elements in x must be the same as in y.')
a1='Error';
a0='Error';
else
Sx=sum(x);
Sy=sum(y);
Sxy=sum(x.*y);
Sxx=sum(x.^2);
a1=(nx*Sxy-Sx*Sy)/(nx*Sxx-Sx^2);
a0=(Sxx*Sy-Sxy*Sx)/(nx*Sxx-Sx^2);
end
The user-defined function LinearRegression is next used in Command Window for determining the best fit line to the given points in the problem.
>> T=0:10:100;
>> p=[0.94 0.96 1.0 1.05 1.07 1.09 1.14 1.17 1.21 1.24 1.28];
>> [a1, a0]=LinearReqression(T,p)
a1 =
0.0034
a0 =
0.9336
(c) The solution is done in the following script file that plots the function, the points, and calculates the value of T_0 from the function.
T=0:10:100;
p=[0.94 0.96 1.0 1.05 1.07 1.09 1.14 1.17 1.211.2 4 1.28];
Tplot=[-300 100];
pplot=0.0034*Tplot+0.9336;
plot(T,p, '*r' ,'markersize' ,12)
hold on
plot(Tplot,pplot, 'k')
xlabel('Temperature (C) ','fontsize' ,20)
ylabel('Pressure (atm)' ,'fontsize' ,20)
T0=-0.9336/0.0034
When this script file is executed, the figure shown on the right is displayed, and the value of the calculated absolute zero temperate is displayed in the Command Window, as shown below.
T0 =
-274.5882
This result is close to the handbook value of-273.15 °C.