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

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 β. Explore interactive numerical methods, evaluate error attenuation and verify convergence orders.

COMPUTE · CONVERGE · ANALYSE

Your virtual mathematics laboratory.

FITTED MODEL OUTPUT READING—
COMPUTATION STATUS

Ready to execute Step = 1.

1 step
Objective optimization: Minimize residual sum of squares S(β) = ||y - Xβ||₂² = ∑ (y_i - f(x_i; β))²

Adjust Step, then execute computation.

Mathematical operations are computed deterministically using 64-bit IEEE 754 precision. Residuals reflect ordinary least-squares regression across successive observations.

Numerical assumptions and limits

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.

Computational tools & numerical modules.

Noisy Data Synthesizer

Generates simulated experimental observation pairs (x_i, y_i) corrupted by controlled Gaussian white noise ε_i ~ N(0, σ²).

Vandermonde Design Matrix Assembler

Constructs the M × p design matrix X with column vectors corresponding to basis functions 1, x, x².

Gram Matrix Builder (Xᵀ X)

Evaluates the symmetric positive semi-definite Gram matrix and right-hand moment vector Xᵀ y.

Cholesky Normal Solver

Factors Xᵀ X = L Lᵀ and executes forward/backward substitution to solve for optimal regression weights β.

Residual Variance Analyzer

Computes the residual vector r = y - Xβ, sum of squared errors SSE, and coefficient of determination R².

Conditioning Monitor

Monitors the condition number κ(Xᵀ X) = (κ(X))² to assess roundoff amplification as polynomial degree increases.

FOLLOW THE METHOD

A reason behind every step.

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 β. Standardized input settings: 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 step.

01

Ingest Observation Data Cloud

Load M = 100 observation points generated by the underlying physical law y = 2.500 x + 1.200 + ε.

02

Construct the Design Matrix X

Assemble the M × 2 Vandermonde matrix with row entries [1, x_i] for each observation point.

03

Formulate the Normal Equations

Compute the matrix product Xᵀ X and right-hand projection vector Xᵀ y using double precision accumulators.

04

Solve for Optimal Coefficients β

Solve the symmetric positive definite 2 × 2 normal system via Cholesky factorization or direct Cramer elimination.

05

Analyze Residual Orthogonality

Verify that the residual vector r = y - Xβ is strictly orthogonal to the column space of X (Xᵀ r = 0).

06

Record Output Metric & Confirm Target

Log the fitted parameter response across observation settings k = 1 to 6 and perform linear regression to confirm the target β = 2.500.

YOUR NOTEBOOK · 0 OBSERVATIONS

Turn measurements into mathematical insight.

See a complete example report ↗

Points are your recorded observations. The solid regression line validates Least-Squares Curve Fitting mathematical scaling.

LINEAR ASYMPTOTIC FIT · y = mx + b
y = β · k + b
#Observation Setting (k) (step)Fitted Model Output Reading (reading)Observation Setting Index kModel Response y = β · kRemove

No readings yet. Execute a computation and record it.

Calculate it yourself.

CHECK YOUR UNDERSTANDING

Explain what the mathematical metrics mean.

What geometric relationship must hold between the residual vector r = y - Xβ and the column space of design matrix X in least-squares?

If the design matrix X has condition number κ(X) = 10⁴, what is the condition number of the normal equations matrix Xᵀ X?

Which matrix decomposition solves the linear least-squares problem stably without computing Xᵀ X?

Under the Gauss-Markov theorem, what property characterizes the ordinary least-squares estimator β?