Calculating the acceleration due to gravity using linear regression method.

Using a simple pendulum, the relation between the periodic time and the length of the wire:

 

T^2=4pi^2*L/g 







Where g is constant, then:
Thus, a plot of T^2 versus L will yield a straight line with slope = 4pi^2/g and passes through the origin.
An experimental data is shown in the table:

Using polynomial linear regression model to represent the data and determine the acceleration:

A plot of T^2 versus L is shown in the figure:


Now, what is the polynomial order "n" for the best fit regression? In other words would the increase in the order be more representative?
The relation between T^2 and L is linear, so only a first order polynomial (line) represent the relation. Choosing another polynomial order will yield an improper representation of the data, even if the curve will approach the points and the value of R^2 will increase.

T^2 = const * L  y = a1 x + a0

You must have noticed that a0 in the equation equals to zero (the line passes through the origin), and we will calculate only the value of a1 which equals 4pi^2/g.

If we used the known derived equation for a1 and a0:


This will yield an error because the previous equation is derived from the two partial derivatives of the equation of the regression error:


Now, we will drive our new equation of a1:


 Using matlab to calculate and plot the first order polynomial linear regression and calculate the acceleration:

 L = [20 30 40 50 60 70 80];

T = [.767 .934 1.11 1.31 1.53 1.72 2.05];

T2 = T.^2;
scatter (L, T2, 'b');
plot(L, T2, 'g')

%1. What is the the polynomial order "n" for the "best fit"
%   linear regression?
%scatter (L, T2, 'b')
%lsline;
%polyfit(L, T2,1)


%2. Would any line represent the data properly?
%y   = a1 x + a0
%T^2 = a1 L + 0
%a0 = 0
%Only the line that passes through the origin


sum_x = sum(L);
sum_x2 = sum(L.^2);
sum_y = sum(T2);
sum_xy = sum(L.*T2);
n = numel(L);

a1 = sum_xy / sum_x2;
g = 4*pi^2/a1;

x = [0, 1];
y = [0, a1];

%scatter(L, T2, 'b', '*')
%hold on
%plot(x, y, 'rx:')
%lsline



Ordinary linear regression using the incorrect derivatives.
Correct linear regression.

a1 = 0.0422
g = 935.3902 cm^2/sec



No comments:

Post a Comment