LeastSquares - Maple Help

Student[LinearAlgebra]

 LeastSquares
 compute a least squares solution to a set of equations

 Calling Sequence LeastSquares(A, B, options)

Parameters

 A - Matrix or set B - column Vector or set of variables options - (optional) parameters; for a complete list, see LinearAlgebra[LeastSquares]

Description

 • For Matrix A and Vector B, the LeastSquares(A, B) command returns a Vector that best satisfies the condition $A·x$ is approximately equal to B, in the least squares sense. The result that is returned is the Vector x which minimizes Norm(A . x - B, 2).
 • Parameter A can also be a set of equations that describe the linear least squares problem. In this case, B is the set of variables in which the equations in A occur.

Examples

 > $\mathrm{with}\left(\mathrm{Student}\left[\mathrm{LinearAlgebra}\right]\right):$
 > $A≔⟨⟨3,0,4⟩|⟨-2,3,4⟩⟩:$
 > $b≔⟨1,2,4⟩:$
 > $X≔\mathrm{LeastSquares}\left(A,b\right)$
 ${X}{≔}\left[\begin{array}{c}\frac{{351}}{{625}}\\ \frac{{62}}{{125}}\end{array}\right]$ (1)
 > $\mathrm{Norm}\left(A·X-b\right)$
 $\frac{{16}}{{25}}$ (2)
 > $E≔\left\{2x-y+2=0,mx+ny-3=0\right\}:$
 > $V≔\left\{x,y\right\}:$
 > $\mathrm{LeastSquares}\left(E,V\right)$
 $\left\{{x}{=}{-}\frac{{2}{}{n}{-}{3}}{{m}{+}{2}{}{n}}{,}{y}{=}\frac{{2}{}\left({m}{+}{3}\right)}{{m}{+}{2}{}{n}}\right\}$ (3)