In theory
Like the fit for a Lorentzian, the idea here is also to apply the least squares method. However, we now have a simpler equation:
(1)\[y = a_0 + a_1 x\]
The objective is therefore to find the combination \({a_0, a_1}\) so as to minimise the following coefficients.
(2)\[E(a_0,a_1) = \sum_{i=1}^{N} W_i (a_1 x_i + a_0 - y_i)^2\]
The rest of the development is therefore very similar to that done to fit the Lorentzian. To find a minimum, we look for the points where the derivative cancels, which gives us:
(3)\[\begin{split}\begin{cases}
E_{a_0}' &= 0 \\
E_{a_1}' &= 0
\end{cases}
\rightarrow
\begin{cases}
\sum_{i=1}^N W_i 2(a_1 x_i + a_0 - y_i) &= 0 \\
\sum_{i=1}^N W_i 2(a_1 x_i + a_0 - y_i) x_i &= 0
\end{cases}\end{split}\]
Which when decomposed gives us:
(4)\[\begin{split}\begin{cases}
a_1 \sum_{i=1}^N W_i x_i + a_0 \sum_{i=1}^N W_i &= \sum_{i=1}^N W_i y_i \\
a_1 \sum_{i=1}^N W_i x_i^2 + a_0 \sum_{i=1}^N W_i x_i &= \sum_{i=1}^N W_i y_i x_i
\end{cases}\end{split}\]
If we divide everything by \(N\), we get the average of all terms:
(5)\[\begin{split}\begin{cases}
a_1 \langle W \rangle \langle x \rangle &+ a_0 \langle W \rangle &= \langle W \rangle \langle y \rangle \\
a_1 \langle W \rangle \langle x^2 \rangle &+ a_0 \langle W \rangle \langle x \rangle &= \langle W \rangle \langle y x \rangle
\end{cases}\end{split}\]
Thus, we can divide everything by \(\langle W \rangle\) and write this system as a matrix equation:
(6)\[\begin{split}\begin{pmatrix}
1 & \langle x \rangle \\
\langle x \rangle & \langle x^2 \rangle
\end{pmatrix}.
\begin{pmatrix}
a_0 \\
a_1
\end{pmatrix}=
\begin{pmatrix}
\langle y \rangle \\
\langle y x \rangle
\end{pmatrix}\end{split}\]
We can therefore determine the coefficients \(a_0, a_1\)
(7)\[\begin{split}a_0 = \frac{
\begin{vmatrix}
\langle y \rangle & \langle x \rangle \\
\langle yx \rangle & \langle x^2 \rangle
\end{vmatrix}
}{
\begin{vmatrix}
1 & \langle x \rangle \\
\langle x \rangle & \langle x^2 \rangle
\end{vmatrix}
}\end{split}\]
(8)\[a_0 = \frac { \langle y \rangle \langle x^2 \rangle - \langle yx \rangle \langle x \rangle }
{ \langle x^2 \rangle - \langle x \rangle }\]
(9)\[ \begin{align}\begin{aligned}\begin{split}a_1 &= \frac{
\begin{vmatrix}
1 & \langle y \rangle \\
\langle x \rangle & \langle yx \rangle
\end{vmatrix}
}{
\begin{vmatrix}
1 & \langle x \rangle \\
\langle x \rangle & \langle x^2 \rangle
\end{vmatrix}
}\end{split}\\&\end{aligned}\end{align} \]
(10)\[a_1 = \frac { \langle yx \rangle - \langle x \rangle \langle y \rangle }
{ \langle x^2 \rangle - \langle x \rangle }\]
In practice
The program reads a file containing on each line a value of \(\omega(P)\). We know that the values of P are, respectively for each line: \([1,3,6,10,15]\)
Here we do not need to modify the data because the function \(\omega(P)\) is already in the form of a polynomial of type \(y = a_0 + a_1x\)
We then directly calculate the sums of the different elements (\(\omega\), \(P\) but also their square etc.). Here, we calculate the sum and not the average in order to minimise the number of lines of code, but the principle and the result are the same.
Once this step is done, we can now calculate the coefficients \(a_0\), \(a_1\), which give us directly the expression of our line.
We thus obtain a line of expression
\[\omega = 0.145 * P + 2282.498\]
\(2282.498`\) thus corresponds to the minimum intensity generated by the rotation of the gas molecules.