Mathematics / Least-Squares Curve Fitting
FREE TO EXPLORE
LABORATORY 25 · MATHEMATICS

Least-Squares Curve Fitting lab report

A worked least-squares curve fitting lab report with iteration data tables, logarithmic graphs, calculations, uncertainty and conclusions.

WORKED EXAMPLE · BENCHMARK OBSERVATIONS

A complete example laboratory report.

Simulated demonstration data.

This report illustrates formal numerical analysis, iteration tracking, and convergence rate extraction. Replace its observations with your own computational telemetry when preparing a practical submission.

Student: __________________Student ID: __________________Course: __________________Date: __________________Partner: __________________Instructor: __________________

1. Title and aim

Least-Squares Polynomial Approximation & Normal Equations. Formulate the linear least-squares regression problem for noisy discrete data, construct the Vandermonde design matrix, assemble and solve the normal equations (Xᵀ X) β = Xᵀ y, and quantitatively determine the optimal regression coefficient β.

2. Abstract

Six computational trials were executed across standardized inputs Step = 1.0 to Step = 6.0 for Least-Squares Polynomial Approximation & Normal Equations. An ordinary least-squares regression yielded an empirical Optimal Regression Coefficient (β) of 2.500 coefficient (difference from theoretical reference = 0.0000%). The empirical telemetry conclusively validates the theoretical model and complexity scaling with R² = 1.000000.

3. Apparatus and fixed settings

4. Theory and graph choice

When analyzing physical experiments, engineering measurements, or observational data, recorded values are inevitably contaminated by stochastic noise and instrumental uncertainties. In such settings, forcing a mathematical model to pass exactly through every point via interpolation is counterproductive, amplifying noise and creating spurious oscillations. The method of least squares, developed independently by Carl Friedrich Gauss and Adrien-Marie Legendre, seeks a model that minimizes the cumulative squared deviation between observations and predictions. In this laboratory, we construct the Vandermonde design matrix, assemble the normal equations, investigate the condition number squaring effect, and extract the optimal regression parameter β = 2.500.

y = β · k + b

The mathematical regression linearizes the relationship into the form y = mx + b. Here, the independent variable x represents Observation Setting Index k, and the dependent variable y represents Model Response y = β · k. The slope m directly extracts Optimal Regression Coefficient (β), while the intercept b accounts for residual baseline offsets.

5. Method

  1. Load M = 100 observation points generated by the underlying physical law y = 2.500 x + 1.200 + ε.
  2. Assemble the M × 2 Vandermonde matrix with row entries [1, x_i] for each observation point.
  3. Compute the matrix product Xᵀ X and right-hand projection vector Xᵀ y using double precision accumulators.
  4. Solve the symmetric positive definite 2 × 2 normal system via Cholesky factorization or direct Cramer elimination.
  5. Verify that the residual vector r = y - Xβ is strictly orthogonal to the column space of X (Xᵀ r = 0).
  6. Log the fitted parameter response across observation settings k = 1 to 6 and perform linear regression to confirm the target β = 2.500.

6. Observations and calculation table

All iterative observations use strictly controlled 64-bit IEEE 754 precision buffers. Residuals are computed relative to the ordinary least-squares regression line.

Table 1. Six simulated observations; x and y represent transformed mathematical metrics.
No.Observation Setting (k) (step)Fitted Model Output Reading (reading)Observation Setting Index kModel Response y = β · kFitted yResidual
11.02.51.00002.50002.50000.0000
22.05.02.00005.00005.00000.0000
33.07.53.00007.50007.50000.0000
44.010.04.000010.000010.00000.0000
55.012.55.000012.500012.50000.0000
66.015.06.000015.000015.00000.0000

Download the sample observations (CSV) ↓

7. Worked calculation for one observation

For step k = 1.0: Current coordinate x = 1.0000. Mathematical model response y = 2.5000. Output reading: 2.5000.

8. Graph, gradient and final calculation

0.620.404.691.958.753.5012.815.0516.886.60Observation Setting Index kModel Response y = β · k

Circular markers represent empirical computational observations. The solid line represents the ordinary least-squares linear fit.

x̄ = 3.50000; ȳ = 8.75000
Σ(x − x̄)² = 17.50000
Σ(x − x̄)(y − ȳ) = 43.75000
m = Σ(x − x̄)(y − ȳ) / Σ(x − x̄)² = 2.50000000
b = ȳ − mx̄ = 0.00000000
y = 2.5000 · k + 0.0000 ⟹ Target = 2.500 (theoretical = 2.5)

9. Uncertainty and comparison

Percentage difference = |estimate − theoretical value| / |theoretical value| × 100 = 0.0000%.

For n = 6 observations, Σresidual² = 0.00000; s² = Σresidual²/(n − 2). Gradient standard error = √[s²/Σ(x − x̄)²] = 0.00000. Intercept standard error = √[s²(1/n + x̄²/Σ(x − x̄)²)] = 0.00000.

Propagating the fit parameters yields a fit standard error of 1.0000e-04 coefficient, with an ideal coefficient of determination R² = 1.000000.

In computational mathematics and numerical analysis, errors arise from algorithmic discretization, finite precision IEEE 754 floating-point arithmetic (machine epsilon ε_mach ≈ 2.22 × 10⁻¹⁶ for 64-bit double precision), and condition number propagation. The ordinary least-squares fit across n = 6 standardized observations provides standard errors for the gradient and intercept. Because the mathematical recurrence is evaluated with high numerical precision, the residual sum of squares is vanishingly small, yielding a coefficient of determination R² ≥ 0.999999 and confirming the theoretical mathematical model.

10. Result and discussion

Optimal Regression Coefficient (β) = 2.500 coefficient
Theoretical reference value: 2.500 coefficient

The empirical benchmark observations provide rigorous quantitative verification of Least-Squares Polynomial Approximation & Normal Equations. In numerical analysis, scientific computing, and computational mathematics, algorithms are characterized by their asymptotic operational scaling, stability, and convergence rates. Across all six observations, the empirical slope m = 2.5000 confirms the theoretical model with near-zero residual variance. Furthermore, comparison with alternative algorithmic paradigms underscores critical trade-offs between memory footprint, condition number sensitivity, and operational throughput. The algorithm's behavior confirms the mathematical predictions established by numerical analysis literature.

11. Precautions and limitations

Ordinary least squares is sensitive to rogue outliers because squaring residuals gives disproportionate weight to extreme deviations. The simulation executes linear least-squares regression over standardized data series across settings k = 1 to 6. The linear regression fit of the response y = β · k confirms the optimal regression parameter β = 2.500 with R² = 1.000000.

12. Conclusion

This computational laboratory investigation quantitatively verified the mathematical formulation and asymptotic scaling of Least-Squares Polynomial Approximation & Normal Equations. Through rigorous tracking across six observation points, we confirmed an empirical Optimal Regression Coefficient (β) of 2.500 coefficient matching the theoretical reference 2.500 coefficient within 0.0000% error. The investigation demonstrates why this method serves as an indispensable tool in modern computational science.