least-squares solution of equations
set of equations or expressions
set of names
Important: The linalg package has been deprecated. Use the superseding command LinearAlgebra[LeastSquares], instead.
- For information on migrating linalg code to the new packages, see examples/LinearAlgebraMigration.
The call leastsqrs(A, b) returns the vector that best satisfies A⁢x=b in the least-squares sense. The result returned is the vector x which minimizes norm⁡A⁢x−b,2.
The call leastsqrs(S, v) finds the values for the variables in v which minimize the equations or expressions in S in the least-squares sense. The result returned is a set of equations whose left-hand sides are from v.
For the linear case, if the third optional argument is 'optimize', the routine will find the optimal least square solution (i.e. the vector x with norm⁡x,2 being the smallest). At present, the matrix entries must be rationals.
The command with(linalg,leastsqrs) allows the use of the abbreviated form of this command.
A ≔ array⁡1,1,1,1,2,4,1,0,0,1,−1,1
b ≔ array⁡3,10,3,910
S ≔ c0+c1+c2−3,c0+2⁢c1+4⁢c2−10,c0−910,c0−c1+c2−3
A ≔ array⁡1,−1,1,1,1,−2,2,0,−1:
b ≔ 124:
Download Help Document
What kind of issue would you like to report? (Optional)
Thank you for submitting feedback on this help document. Your feedback will be used
to improve Maple's help in the future.