Lab Parts: Evaluating Spring Constants with the Least Squares Method of Data Fitting
Student Researched Lab Experiment to evaluate Spring Constants
Introduction
In this experiment we evaluated Hooke’s law by measuring the stretch of a spring with incremental masses. A motion detector provided position measurements and the masses were added 100 grams at a time. To calculate the spring constant we utilized the least squares method of data fitting on a Force by distance graph.
Sample Calculations
Line of Best Fit: f(x) = 0.202x + 16.5
xi-mean height, yi-force of gravity
(1) Mean Height (cm): 10th cell
(Heightup + Heightdown)/2 = (35.4+35.6)/2 = 35.5 cm
(2) Forceg (N): 2nd cell
Fg = ma = 0.150(kg ) x 9.81(m/s2) = 1.47 (N)
(3) xiyi (cJ): 2nd cell
xiyi = 74.5(cm) x 1.47(N) = 110 (cJ)
(4) (xi)2 (cm2): 1st cell
(xi)2 = 77.3(cm) x 77.3(cm) = 6000 (cm2)
(5) f(xi) (N): 3rd cell
f(xi) = f(0.250) = -0.202(0.250) + 16.5 = 2.50 (N)
(6) [yi-(f(xi)]2 (N): 3rd cell
[yi-(f(xi)]2 = [2.45-2.50]2 = 0.210 (N)
(7) [yi-ybar]2 (N): 10th cell
[yi-ybar]2 = (y10-[SUM(y1:y11)/11])2 = (10.30-5.40) = 24.1 (N)
Conclusion
The experiment was highly successful with a 1.00% discrepancy for the experimental spring constant. Data was also plotted on an excel graph and the r2 values differed by 0.20%. The least squares method provided an r2 value of 0.9978. It seems the experimental spring constant is highly accurate and perhaps a better representation than the accepted value of 0.200.
Editor’s note (October 21, 2026): Several of the sample calculations above have arithmetic or notation slips. The student’s measurements, fitted line and conclusion are left as written. This is what the numbers shown actually give:
- Sign of the slope. The line of best fit is written as f(x) = 0.202x + 16.5, but step 5 uses −0.202. The force goes up as the measured height goes down (77.3 cm at the 1st cell, 35.5 cm at the 10th), so the slope of force against height has to be negative: f(x) = −0.202x + 16.5. The spring constant is the size of that slope, 0.202 N/cm (20.2 N/m). Measured against the accepted 0.200 N/cm, that is the 1.00% discrepancy reported in the Conclusion.
- Step 4. 77.3 × 77.3 = 5,975.29 cm², or about 5,980 cm² to three significant figures. The “6000” shown is rounded to two.
- Step 5. The line is evaluated at 0.250, which is the 3rd cell’s mass in kilograms, not its mean height in centimeters. As written, −0.202(0.250) + 16.5 = 16.45 N, not 2.50 N. On this line, a force of 2.50 N corresponds to a height of about 69.3 cm. The post doesn’t list the 3rd cell’s height, so that can’t be checked here.
- Step 6. [2.45 − 2.50]² = (−0.05)² = 0.0025 N², not 0.210.
- Step 7. The square is missing from the middle of the line: (10.30 − 5.40) = 4.90 N, and 4.90² ≈ 24.0 N². The 24.1 shown fits a mean carried to more digits (about 5.39 N).
- Units. Steps 6 and 7 are squared forces, so their units are N², not N. Step 3’s N·cm is correctly written as cJ (1 N·cm = 0.01 J).
These slips are in the worked examples. The post doesn’t show whether the spreadsheet behind the reported fit and r² had the same problems.
Hooke’s law and the least-squares fit, briefly
An ideal spring obeys Hooke’s law, F = −kΔx: the force it exerts is proportional to how far it is stretched from its relaxed length, and k is the spring constant (OpenStax University Physics Volume 1, 7.1). When a mass hangs at rest on a vertical spring, the spring force balances the weight, k(y0 − y) = mg, where y0 is the position with no mass and y is the new position (OpenStax University Physics Volume 1, 15.1). Plotting the weight mg against the measured height y therefore gives a straight line whose slope is −k.
The least-squares method picks the straight line f(x) = a + bx that makes the sum of squared residuals, Σ[yi − f(xi)]², as small as possible. For a straight line this gives
b = Σ(xi − x̄)(yi − ȳ) / Σ(xi − x̄)² and a = ȳ − b·x̄
(NIST/SEMATECH e-Handbook of Statistical Methods, 4.4.3.1). The same slope can be worked out from running totals, b = [nΣxiyi − (Σxi)(Σyi)] / [nΣxi² − (Σxi)²], which is why the data table has xiyi and xi² columns. How well the line fits is summarized by r² = 1 − SSE/SSTO. SSE is the sum of the squared residuals [yi − f(xi)]² (step 6 is one of its terms), and SSTO is the sum of [yi − ȳ]² (step 7 is one of its terms) (Penn State STAT 462, 2.5). An r² near 1, like the 0.9978 reported here, means nearly all of the variation in force is accounted for by the straight line.