LinearAlgebra - Maple Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Mathematics : Linear Algebra : LinearAlgebra Package : Solvers : LinearAlgebra/LeastSquares

LinearAlgebra

  

LeastSquares

  

least-squares solution to equations

 

Calling Sequence

Parameters

Description

Examples

Calling Sequence

LeastSquares(A, B, opt, t, c, options, meth)

Parameters

A

-

Matrix, list, or set

B

-

Matrix, column Vector or set of variables

opt

-

(optional) BooleanOpt(optimize); specifies whether to optimize a parametrized solution

t

-

(optional) equation of the form free = name; base name to use for free variables in parametrized solutions

c

-

(optional) BooleanOpt(conjugate); specifies whether to use the Hermitian transpose in the case of non-floating-point data

options

-

(optional); constructor options for the result object

meth

-

(optional) equation of the form method = name where name is one of QR or SVD; floating-point method to use

Description

• 

For Matrix A and Vector B, the LeastSquares(A, B) function returns a Vector that best satisfies the equation A . x is approximately equal to B, in the least squares sense. The result that is returned is the Vector x which minimizes NormA.xB,2.

  

If B is a Matrix, then a Matrix is returned where its ith column is the least squares solution to A.x=Bi, where Bi is the ith column of the Matrix B.

• 

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.

• 

The optimize option (opt) determines how the result is returned in the case when the coefficient Matrix is not full rank (so that there are an infinite number of solutions).  If given as optimize=true, the solution with the minimal 2-norm is returned.

  

If the optimize option is omitted (or is given as optimize=false) then in the case of rational data a parametrized solution is returned if the coefficient Matrix is not full rank. In this case, the parametrization uses names based on the symbol given by the option t. If the option t is not provided then an unassigned symbol _t is generated.

  

The condition optimize=true can be abbreviated as optimize.

• 

The conjugate option (c) specifies whether to use HermitianTranspose instead of Transpose for problems without a complex data type. The default is true. The condition conjugate=true can be abbreviated as conjugate.

• 

For floating-point numeric Matrices a solution is computed by using a singular value decomposition (SVD) method by default.

• 

For nonnumeric data the solution is computed by default using the normal equations. If the method option is supplied as QR then the default method is overridden.

• 

If A is a list, then the elements of the list are taken as the Matrix factors of the Matrix A, due to some prefactorization. These factors are interpreted, uniquely, as follows:

  

*   A list of Matrix, Vector[column] items, [QR, tau], is interpreted as the result of calling QRDecomposition with the output='NAG' option (the factors must contain data for a row-dominant Matrix).

  

*   A list of Matrix, Matrix items, [Q, R], is interpreted as the result of calling QRDecomposition with the output=['Q', 'R'] option (the factors must contain data for a row-dominant Matrix).

  

*   A list of Matrix, Vector[column], Matrix items, [U, S, Vt], is interpreted as the result of calling SingularValues with the output=['U', 'S', 'Vt'] option.

• 

The constructor options provide additional information (readonly, shape, storage, order, datatype, and attributes) to the Vector constructor that builds the result. These options may also be provided in the form outputoptions=[...], where [...] represents a Maple list.  If a constructor option is provided in both the calling sequence directly and in an outputoptions option, the latter takes precedence (regardless of the order).

• 

This function is part of the LinearAlgebra package, and so it can be used in the form LeastSquares(..) only after executing the command with(LinearAlgebra). However, it can always be accessed through the long form of the command by using LinearAlgebra[LeastSquares](..).

Examples

withLinearAlgebra:

A3,0,4|2,3,4:

b1,2,4:

XLeastSquaresA,b

X:=35162562125

(1)

VectorNormA.Xb

64125

(2)

AfMatrixA,datatype=float:

bfVectorb,datatype=float:

QR,τQRDecompositionAf,output='NAG':

XfLeastSquaresQR,τ,bf

Xf:=0.5616000000000000.496000000000000

(3)

Emx+ny3=0,2xy+2=0:

Vx,y:

LeastSquaresE,V

x=2n3m+2n,y=2m+3m+2n

(4)

F1+I,43I,I|3,I,1I:

G0,2I,5|3+4I,0,1+I:

LeastSquaresF,G

69331+137331I8933126331I176331+115331I190331+348331I

(5)

FtHermitianTransposeF:

GtHermitianTransposeG:

LeastSquaresFt,Gt,optimize

243331349331I3633118331I43331+8331I62331+109331I7433192331I263331198331I30331185331I183312331I4833144331I

(6)

N1,2,3|3,4,5|5,6,7:

z1,2,3:

MLeastSquaresN,z,free=c

M:=1+c32c3c3

(7)

N.M

123

(8)

LeastSquaresN,z,optimize

561316

(9)

NfMatrixN,datatype=float:

zfVectorz,datatype=float:

LeastSquaresNf,zf,method='SVD'

0.8333333333333340.3333333333333330.166666666666667

(10)

U,S,VtSingularValuesNf,output='U','S','Vt'

U,S,Vt:=0.4461721604067700.7964067657995430.4082482904638630.5686269049445290.09998388023345910.8164965809277260.6910816494822890.5964390053326260.408248290463863,13.15934799669310.9118992827771996.2772020961853010-17,0.2778762990128090.5371415324061760.7964067657995440.8695505136449970.2116891766191130.4461721604067700.4082482904638630.8164965809277260.408248290463863

(11)

LeastSquaresU,S,Vt,zf

0.8333333333333340.3333333333333330.166666666666667

(12)

See Also

LinearAlgebra[LinearSolve]

LinearAlgebra[Norm]

LinearAlgebra[QRDecomposition]

Matrix

type[BooleanOpt]

Vector

 


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam