Student Numerical Analysis - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


The Student[NumericalAnalysis] Package

The Student[NumericalAnalysis] package contains commands that can be used to learn and understand numerical analysis concepts. The areas of numerical analysis that the package covers are: initial-value problems, interpolation, numerical linear algebra, numerical quadrature, and root finding. This worksheet demonstrates how to use some of the commands and how to launch the interactive tutors.

Getting Started

While any command in the package can be referred to using the long form, for example, Student[NumericalAnalysis][Euler], it is often easier to load the package and then use the short form command names.

restart;

withStudentNumericalAnalysis:

Initial-Value Problems

The Student[NumericalAnalysis] package contains several commands that can numerically approximate the solution to an initial-value problem. A standard suite of approximation methods are available, including the Adams-Bashforth explicit, Adams-Moulton implicit, Adams-Bashforth-Moulton predictor-corrector, Euler, Runge-Kutta, and Taylor methods. In particular, difference formulae of various orders are available from the Adams and Runge-Kutta families of methods.

DE1ⅆⅆ t yt=yt2t

DE1ⅆⅆtyt=yt2t

(2.1)

InitialValueProblemDE1, y0=0.4,t=4,method= adamsbashforth,output=solution;

−3.933

(2.2)

InitialValueProblemDE1, y0=0.4,t=4,method= adamsbashforth,output=solution, Error;

−3.933,2.002

(2.3)

The InitialValueProblem command can also return a plot of the exact and approximated solution, using the output=plot option.

InitialValueProblemDE1, y0=0.4,t=4,method=rungekutta,submethod=rk4,output=plot;

The comparewith option allows the student to compare different approximation methods and the exact solution. The comparewith option can be used with the output=plot and output=information options.

InitialValueProblemDE1, y0=0.4,t=4,method=rungekutta,submethod=rk4,comparewith=euler, adamsbashforth,step2, output=plot;

InitialValueProblemDE1, y0=0.4,t=4,method=rungekutta,submethod=rk4,comparewith=euler,taylor,5, output=information;

tMaple's numeric solutionR-K 4th Ord.ErrorEulerError5th-Ord. TaylorError0.0.40.40.0.40.0.40.0.80000.18420.19070.0065400.52800.34380.17790.00631.6000.68290.67320.0097280.11100.79390.65720.02572.4001.3551.3110.044121.1590.19591.3810.0263.2001.6931.6180.075032.0040.31131.6920.0014.1.9311.8190.11181.3510.58041.9310.

(2.4)

Interpolation

The Student[NumericalAnalysis] package contains several commands that allow students to perform polynomial and cubic spline interpolations on data points. The available methods of interpolation include Lagrange, Newton, Hermite, Neville, and cubic spline interpolation. The interpolation is computed by either the PolynomialInterpolation command or the CubicSpline command. These commands return a POLYINTERP data structure which can then be passed to different Student[NumericalAnalysis] commands to retrieve information.

data1  0.422,1.023,3.533,2.533,4.022,6.342,5.002,8.333,6.003,9.000

data10.422,1.023,3.533,2.533,4.022,6.342,5.002,8.333,6.003,9.000

(3.1)

Use the PolynomialInterpolation command to perform the interpolation and store all information.

p1PolynomialInterpolationdata1, method=newton, function=expx,independentvar=x,errorboundvar=ξ:

Extract the interpolant from the POLYINTERP structure using the Interpolant command.

Interpolantp1

0.8181719704+0.4853744777x+2.028886549x0.422x3.5331.298772557x0.422x3.533x4.022+0.4670460951x0.422x3.533x4.022x5.002

(3.2)

Extract the function using the Function command.

Functionp1

ⅇx

(3.3)

Extract the remainder term using the RemainderTerm command.

RemainderTermp1

ⅇξx0.422x3.533x4.022x5.002x6.003120&where0.422ξ6.003

(3.4)

Use the Draw command to plot the basis functions from the Newton interpolation.

Drawp1,objects=BasisFunctions

Perform a cubic spline interpolation using the CubicSpline command.

p2CubicSplinedata1,independentvar=x:

Use the Draw command to plot the interpolating polynomial.

Drawp2

Numerical Linear Algebra

The Student[NumericalAnalysis] package contains several commands that allow students to explore numerical linear algebra. Matrix decomposition and iterative approximation methods are the two main focuses of the numerical linear algebra commands in the Student[NumericalAnalysis] package. The available iterative approximation techniques include the Gauss-Seidel, Jacobi, and Successive Over-Relaxation methods.

M1Matrix4.2,2.2,0.2,1.0,5.3,2.1,0.3,3.2,6.3

4.22.20.21.05.32.10.33.26.3

(4.1)

Factor the matrix.

P1,L1,U1MatrixDecompositionM1, method=PLU

P1,L1,U1100010001,1000.2380952381100.071428571430.63708873391,4.22.20.204.7761904762.052380952004.978165504

(4.2)

Check if the matrix is strictly diagonally dominant.

IsMatrixShapeM1, strictlydiagonallydominant

true

(4.3)

Approximate the solution to a system of equations using the Successive Over-Relaxation method.

V1  Vector1.5,4.3,3.2

1.54.33.2

(4.4)

LinearSolveM1,V1,method=SOR1.25

0.054573766920.77538756110.1166895821

(4.5)

Numerical Quadrature

The Student[NumericalAnalysis] package contains several commands that allow students to numerically approximate integrals using different methods. The available quadrature methods include the complete family of Newton-Cotes formulae (open or closed, with a user-specified order), Gaussian Quadrature, and Romberg Integration. Some of these methods can be used with the adaptive=true option in the Quadrature command or with the AdaptiveQuadrature command. The results of the approximate integration can be returned as a sum, value, plot, animation, or as printed information about the computation.

fxsinx

fxsinx

(5.1)

int11+ⅆⅆ x fx2

int11+cosx2

(5.2)

Use the Boole method to numerically approximate the value of 1141+cosx2ⅆx.

Quadratureint1, x=1..14,method=boole,output=value

15.74194117

(5.3)

The output=plot option can be used to display a plot of the approximation.

Quadratureint1, x=1..14, method=boole,output=plot

Adaptive quadrature is also available using the adaptive=true option in the Quadrature command or the AdaptiveQuadrature command.

AdaptiveQuadratureint1,x=1..14,method=newtoncotes4

15.74186755

(5.4)

Use the output=information option to print a record of the adaptations performed during the approximation.

AdaptiveQuadratureint1,x=1..14,method=newtoncotes4,output=information

INTEGRAL: Int((1+cos(x)^2)^(1/2),x=1..14) = 15.7418533       
APPROXIMATION METHOD: Adaptive Bode's Rule
---------------------------------- INFORMATION TABLE ----------------------------------
    Approximate Value         Absolute Error         Relative Error
          15.7418676               1.426e-05         9.059e-05 %
---------------------------------- ITERATION HISTORY ---------------------------------------
   Interval           Status         Present Stack
      1..14            fail           EMPTY
      1..15/2          fail           [15/2, 14]
      1..17/4          fail           [[1], [17/4, 15/2]]
      1..21/8          PASS           [[2], [21/8, 17/4]]
   21/8..17/4          PASS           [[1], [17/4, 15/2]]
   17/4..15/2          fail           [15/2, 14]
   17/4..47/8          PASS           [[1], [47/8, 15/2]]
   47/8..15/2          PASS           [15/2, 14]
   15/2..14            fail           EMPTY
   15/2..43/4          fail           [43/4, 14]
   15/2..73/8          PASS           [[1], [73/8, 43/4]]
   73/8..43/4          PASS           [43/4, 14]
   43/4..14            fail           EMPTY
   43/4..99/8          PASS           [99/8, 14]
   99/8..14            PASS           EMPTY
--------------------------------------------------------------------------------------------
Number of Function Evaluations:     65

Root Finding

The Student[NumericalAnalysis] package contains commands that allow students to numerically approximate the roots of an expression. A suite of basic numerical root-finding methods are available, including Newton-Raphson, Modified Newton-Raphson, Bisection, Secant, Fixed-Point Iteration, False-Position, and Steffensen.

fln1x+cos1x

fln1x+cos1+x

(6.1)

Try the Bisection method.

Rootsf,x=0,1,method=bisection

0.6022644043

(6.2)

Try the Newton-Raphson method and use the output=plot option to display the approximation.

Rootsf,x=.4,stoppingcriterion=absolute,method=newton,output=plot

Tutors

The Student[NumericalAnalysis] package contains four interactive tutors to assist students with solving numerical analysis problems: EulerTutor, InitialValueProblemTutor, IterativeFormulaTutor, and MatrixDecompositionTutor. The tutors can be accessed via the menu path Tools > Tutors > Numerical Analysis or by invoking the tutor in a worksheet as shown below.

IterativeFormulaTutor

See Also

Student[NumericalAnalysis]

Return to Index for Example Worksheets