Student[LinearAlgebra] - Maple Programming Help

Online Help

All Products    Maple    MapleSim

Home : Support : Online Help : Education : Student Package : Linear Algebra : Visualization : Student/LinearAlgebra/LeastSquaresPlot





plot 2-D or 3-D points and a least squares fit to those points


Calling Sequence




Calling Sequence

LeastSquaresPlot(L, var, opts)

LeastSquaresPlot(Lx, Ly, var, opts)

LeastSquaresPlot(Lx, Ly, Lz, var, opts)




list of lists of pairs or list of triples of algebraic values

Lx, Ly, Lz


lists of algebraic values



(optional) name or list of 1 name (2-D case); list of 2 names (3-D case)



plotting options or equation(s) of the form option=value where option is one of showboxes, boxoptions, showcurve or showsurface, curveoptions or surfaceoptions, showpoints, pointoptions, curve or surface, or Student[plot options]; specify options for the plot



The LeastSquaresPlot(L) command plots the points specified by L, the least squares fit curve or surface, and the errors associated with this fit.  Errors are represented as squares (2-D) or rectangular solids (3-D). The area or volume of these boxes is equal to the square of the error between the approximating curve or surface and the data point to which the box is attached.


The points can be given as either a list of lists of 2- or 3-element points, or as two lists representing the components of 2-D points, or three lists representing the components of 3-D points.


Note: This command takes a slightly different approach to solving the least squares problem than does the LeastSquares command.  The latter command solves a linear system, as represented by a Matrix and a right-hand side Vector, in the least squares sense.  The relation between the two approaches is that the Matrix and Vector arguments to the LeastSquares command are obtained by evaluating the model curve or surface (as specified by the curve or surface argument) at each of the points given in the list argument(s) to this command.


The names of the independent variables can be given as an optional argument var.  Otherwise the variables x, or x and y are used.  If the curve or surface option is given, the variable name(s) must also be explicitly given.


The opts argument can contain any of the Student plot options or any of the following equations that set plot options.




showboxes = true or false


Select whether the boxes representing the errors are plotted.  [Default: true]




boxoptions = list


A list of options for the plot of the boxes representing the errors. For more information on plot options, see plot/options. [Default: solid blue squares or rectangular solids]




showcurve = true or false or showsurface = true or false


Select whether the fitting curve or surface is plotted.  [Default: true]




curveoptions = list or surfaceoptions = list


A list of options for the plot of the fitting curve or surface. For more information on plot options, see plot/options. [Default: red curve (2-D), red wire frame (3-D)]




showpoints = true or false


Select whether the points being fitted are plotted.  [Default: true]




pointoptions = list


A list of options for plotting the points being fitted. For more information on plot options, see plot/options. [Default: black circles]




curve = algebraic or surface = algebraic


An expression in the variables that specifies the curve or surface to which to fit the data. This curve or surface must be linear in the unknown parameter(s), and the variable names must be given in the var parameter.  For example, the curve a*x^2+b*x*y+c is acceptable because it is linear in the parameters a, b, and c. [Default: ax+b (2-D), ax+by+c (3-D)]




caption = anything


A caption for the plot.


The default caption is constructed from the parameters and the command options. caption = "" disables the default caption. For more information about specifying a caption, see plot/typesetting.


These are the commands to create the plots in the Plotting Guide.





Fitting curve: -.3148+.7556*x
Least squares error: .4979
Maximum error: .3708

Compare the use of the LeastSquaresPlot command with that of the LeastSquares command, which solves a linear system in the least-squares sense.



A:= 13 x 4 MatrixData Type: anythingStorage: rectangularOrder: Fortran_order



B:= 1 .. 13 VectorcolumnData Type: anythingStorage: rectangularOrder: Fortran_order






Fitting surface: .3113-.1089*x+.5662*y-.4173*x*y
Least squares error: .3848
Maximum error: .2300

See Also




Student plot options




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