Geometric illlustration of the least squares

> with(Student[LinearAlgebra]);

Warning, the name LeastSquares has been rebound

Warning, the protected name `.` has been redefined and unprotected

[`&x`, `.`, AddRow, AddRows, Adjoint, ApplyLinearTransformPlot, BackwardSubstitute, BandMatrix, Basis, BilinearForm, CharacteristicMatrix, CharacteristicPolynomial, ColumnDimension, ColumnSpace, Compa...[`&x`, `.`, AddRow, AddRows, Adjoint, ApplyLinearTransformPlot, BackwardSubstitute, BandMatrix, Basis, BilinearForm, CharacteristicMatrix, CharacteristicPolynomial, ColumnDimension, ColumnSpace, Compa...[`&x`, `.`, AddRow, AddRows, Adjoint, ApplyLinearTransformPlot, BackwardSubstitute, BandMatrix, Basis, BilinearForm, CharacteristicMatrix, CharacteristicPolynomial, ColumnDimension, ColumnSpace, Compa...[`&x`, `.`, AddRow, AddRows, Adjoint, ApplyLinearTransformPlot, BackwardSubstitute, BandMatrix, Basis, BilinearForm, CharacteristicMatrix, CharacteristicPolynomial, ColumnDimension, ColumnSpace, Compa...[`&x`, `.`, AddRow, AddRows, Adjoint, ApplyLinearTransformPlot, BackwardSubstitute, BandMatrix, Basis, BilinearForm, CharacteristicMatrix, CharacteristicPolynomial, ColumnDimension, ColumnSpace, Compa...[`&x`, `.`, AddRow, AddRows, Adjoint, ApplyLinearTransformPlot, BackwardSubstitute, BandMatrix, Basis, BilinearForm, CharacteristicMatrix, CharacteristicPolynomial, ColumnDimension, ColumnSpace, Compa...[`&x`, `.`, AddRow, AddRows, Adjoint, ApplyLinearTransformPlot, BackwardSubstitute, BandMatrix, Basis, BilinearForm, CharacteristicMatrix, CharacteristicPolynomial, ColumnDimension, ColumnSpace, Compa...[`&x`, `.`, AddRow, AddRows, Adjoint, ApplyLinearTransformPlot, BackwardSubstitute, BandMatrix, Basis, BilinearForm, CharacteristicMatrix, CharacteristicPolynomial, ColumnDimension, ColumnSpace, Compa...[`&x`, `.`, AddRow, AddRows, Adjoint, ApplyLinearTransformPlot, BackwardSubstitute, BandMatrix, Basis, BilinearForm, CharacteristicMatrix, CharacteristicPolynomial, ColumnDimension, ColumnSpace, Compa...

The command LeastSquaresPlot plots the squares whose total area is minimized by the best line.

> LeastSquaresPlot(pairs13);

[Plot]

> LeastSquaresPlot(pairs27);

[Plot]

There are too many points to get a nice picture. Let us reduce the dataset:

> pairs5:=pairs27[7..-17];

pairs5 := [[9.392, 4.605], [8.265, 7.798], [11.44, 12.23], [11.93, 17.72], [13.85, 12.09]]

> LeastSquaresPlot(pairs5);

[Plot]

If we set scaling=unconstrained, the squares look like rectangles but otherwise the drawing (MAYBE - remember that my dataset is "randomized") improves:

> display(LeastSquaresPlot(pairs5),scaling=unconstrained);

[Plot]

Another way of improving the drawing MAY BE to limit the view.

> display(LeastSquaresPlot(pairs5),view=[0..16, 0..19]);

[Plot]

>