Student[NumericalAnalysis] - Maple Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Education : Student Package : Numerical Analysis : Visualization : Student/NumericalAnalysis/IterativeApproximate

Student[NumericalAnalysis]

  

IterativeApproximate

  

numerically approximate the solution to a linear system

 

Calling Sequence

Parameters

Options

Description

Notes

Examples

Calling Sequence

IterativeApproximate(A, b, opts)

IterativeApproximate(A, opts)

Parameters

A

-

Matrix; a square nxn matrix or an augmented (A|b) nxm matrix, where m=n+1

b

-

(optional) Vector; a vector of length n

opts

-

equations of the form keyword=value, where keyword is one of distanceplotoptions, initialapprox, maxiterations, method, output, plotoptions, showsteps, stoppingcriterion, tolerance; the options for numerically approximating the solution to Ax=b

Options

• 

distanceplotoptions = [list]

  

The plot options for the  column graph of distances when output=plotdistance.

• 

initialapprox = Vector

  

Initial approximation vector with which to begin the iteration; this vector must be numeric. This is a required keyword parameter.

• 

maxiterations = posint

  

The maximum number of iterations to perform while approximating the solution to A.x=b.  If the maximum number of iterations is reached and the solution is not within the specified tolerance, a plot of distances can still be returned. This is a required keyword parameter.

• 

method = gaussseidel, jacobi, SOR(numeric)

  

The method to be used when approximating the solution to A.x=b. See the Notes section below for some of the sufficient conditions for convergence.

– 

gaussseidel = Gauss-Seidel method

– 

jacobi = Jacobi method

– 

SOR(numeric) = successive over-relaxation (SOR) method

  

Note that the SOR method is specified by the symbol SOR followed by the relaxation factor in parentheses.  The relaxation factor must be strictly between 0 and 2; otherwise, the generated sequence will diverge. For the purpose of demonstrating this divergence, however, values of the relaxation factor outside this range are still accepted by this procedure.

  

By default, method=gaussseidel.

• 

output = solution, approximates, distances, plotdistance, plotsolution, or list

  

The return value of the function.  The default is solution. For more than one output, specify a list of the output in the order desired.

– 

output=solution returns the final approximation of x.

– 

output=approximates returns the approximation at each iteration in a list.

– 

output=distances returns the error at each iteration in a list.

– 

output=plotdistance returns a column graph of the errors at each iteration.

– 

output=plotsolution returns a 3-D plot of the path of the approximations of x. This output is only available when A and b are 3-dimensional.

• 

plotoptions=list

  

The plot options for the 3-D plot when output=plotsolution.

• 

showsteps = true or false

  

Whether to print helpful messages in the interface as the IterativeApproximate command executes.

• 

stoppingcriterion = function

  

The stopping criterion for the approximation of x in the form stoppingcriterion=distance(norm), where distance is either relative or absolute and norm is one of: posint, infinity (), or Euclidean. By default, stoppingcriterion=relative(infinity).

  

The stopping criterion for the approximation of x in the form stoppingcriterion=distance(norm), where distance is either relative or absolute and norm is one of: posint, infinity, or Euclidean. By default, stoppingcriterion=relative(infinity).

• 

tolerance = positive

  

The tolerance of the approximation. The tolerance must be provided.

Description

• 

The IterativeApproximate command numerically approximates the solution to the linear system A.x=b, using one of these iterative methods: Gauss-Seidel, Jacobi, and successive over-relaxation.

• 

It is possible to return both the approximation and the error at each iteration with this command; see the output and stoppingcriterion options under the Options section for more details.

• 

It is also possible to view a column graph of the distances (errors) at each step, showing whether convergence is achieved.

• 

When A and b are 3-dimensional, it is possible to obtain a plot tracing the path of the approximation sequence.

• 

The entries of A and b must be expressions that can be evaluated to floating-point numbers.

Notes

• 

The initialapprox, tolerance and maxiterations are all required keyword parameters; they must be given when the IterativeApproximate command is used.

• 

If A is positive definite or strictly diagonally dominant, then A is invertible, and so the system A.x = b has a unique solution. Use IsMatrixShape to check if a matrix has one of these properties.

• 

If the matrix A is strictly diagonally dominant, both the Jacobi and Gauss-Seidel methods produce a sequence of approximation vectors converging to the solution, for any initial approximation vector.

• 

If A is positive definite, the Gauss-Seidel method produces a sequence converging to the solution, for any initial approximation vector; the same holds for the successive over-relaxation method, provided that the relaxation factor w is strictly between 0 and 2.

• 

In general, if A gives rise to an iteration matrix T such that the spectral radius of T is strictly less than 1, the resulting sequence is guaranteed to converge to a solution, for any initial approximation vector.

• 

This procedure operates numerically; that is, if the inputs are not already numeric, they are first evaluated to floating-point quantities before computations proceed. The outputs will be numeric as well. Note that exact rationals are considered numeric and are preserved whenever possible throughout the computation; therefore, one must specify floating-point inputs instead of exact rationals to obtain floating-point outputs.

Examples

withStudent[NumericalAnalysis]:

AMatrix10,1,2,0,1,11,1,3,2,1,10,1,0,3,1,8:

bVector6,25,11,15:

View the approximate solution using the Jacobi method.

IterativeApproximateA,b,initialapprox=Vector0.,0.,0.,0.,tolerance=103,maxiterations=20,stoppingcriterion=relative∞,method=jacobi

0.99967414522.0004476721.0003691581.000619190

(1)

View the approximate solution with the error at each iteration.

IterativeApproximateA,b,initialapprox=Vector0.,0.,0.,0.,tolerance=103,maxiterations=20,stoppingcriterion=relative∞,method=jacobi,output=approximates,distances

0.0.0.0.,0.60000000002.2727272731.1000000001.875000000,1.0472727271.7159090910.80522727270.8852272726,0.93263636362.0533057851.0493409091.130880682,1.0151987601.9536957650.96810862600.9738427170,0.98899130172.0114147251.0102859041.021350510,1.0031986531.9922412610.99452173680.9944337401,0.99812847352.0023068821.0019722301.003594310,1.0006251341.9986703010.99903557550.9988883905,0.99967414522.0004476721.0003691581.000619190,1.000000000,0.5768211921,0.1643187763,0.08037994851,0.02869570322,0.01351079833,0.005027012138,0.002354525155,0.0008884866247

(2)

View the approximate solution with the error at each iteration as a column graph.

IterativeApproximateA,b,initialapprox=Vector0.,0.,0.,0.,tolerance=103,maxiterations=20,stoppingcriterion=relative∞,method=jacobi,output=plotdistance

The linear system may be input as an augmented matrix

AMatrix3.32,1.43,4.01,2.03,5.93,2.03

A:=3.321.434.012.035.932.03

(3)

IterativeApproximateA,initialapprox=Vector0.,0.,tolerance=105,maxiterations=20,method=SOR1.25

1.2437719520.08345160693

(4)

See Also

Student[NumericalAnalysis]

Student[NumericalAnalysis][IterativeFormula]

Student[NumericalAnalysis][VisualizationOverview]

 


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