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

Online Help

All Products    Maple    MapleSim

New and Enhanced Packages


Maple 8 contains many new packages and enhancements to existing packages.


New Packages


Enhanced Packages


New Packages

Enhanced Packages

New Packages



The CodeGeneration package provides translation of Maple code to various target languages.  Currently, translation to ANSI C, Fortran 77, and Java [TM] is available.  For more information, see the help pages for the exports: C, Fortran, and Java.


The CodeGeneration package does not replace the codegen package.  However, the CodeGeneration[C] and CodeGeneration[Fortran] functions provide most of the functionality currently available in codegen[C] and codegen[fortran]. Consequently, future support for codegen[C] and codegen[fortran] will be limited.


The CodeGeneration exports recognize and translate a subset of the Maple language. For more information about the type of input that can be translated and behavior of the translators, see CodeGeneration.


The following list describes the most significant differences between the CodeGeneration language translators and the codegen language translators.


Translation to Java [TM] code is now available by using the CodeGeneration[Java] function.


Translation to ``Kernighan and Ritchie'' C is not available in CodeGeneration.  The only form of C that is produced is ANSI C.


There are several options to give the user greater control over how analysis and translation of types are performed.  For more information, see CodeGenerationOptions.


CodeGeneration recognizes and translates implicit returns in a greater number of cases.


CodeGeneration recognizes and translates nested lists into multidimensional arrays in the target language.


There are a number of improvements in translation to Fortran in particular, including increased support for rtables, translation of arrays with ranges not starting at 1, and the renaming of identifiers which do not satisfy the Fortran 77 standard.



The LargeExpressions package introduces tools that help you work with large expressions. Using the Veil and Unveil commands, you can introduce, in a controlled way, subexpression labels that aid in understanding the structure of a given expression.



The LibraryTools package provides a set of functions to help create and maintain libraries (repositories). It helps convert directories of .m files to libraries. The LibraryTools package includes procedures that build, update, and add to libraries from directories containing .m files. It also has procedures that add variables to specified libraries and delete from specified libraries.



The Maplets package provides a Maple and Maple-style interface to Maplet applications.  Maplet applications are analogous to applets that Web browsers use. By using the Maplets class library, you can create interactive, graphical user interfaces for your Maple programs. Maplet applications are constructed from Swing user interface components, which are part of Sun Microsystems' Java [TM] platform.


The Maplets package provides an interface to the Maplets class library functionality.  By using the Maplets package, you can construct Maplet applications that run within a Maple session, using the command line version or the graphical user interface version of Maple. In Windows, the Maplet Application Viewer facility launches a Maplet application outside a Maple session.


Changes to the Maplets package since the initial version was released on MaplePrimes are listed on the Maplets/updates page.



The MatrixPolynomialAlgebra package provides a set of tools for the algebraic manipulation of matrix polynomials. In particular, there are tools that perform basic polynomial operations, such as determining degrees and coefficients; perform algebraic operations, such as matrix polynomial left and right division, and determining greatest common divisors and least common multiples; convert to special forms of matrix polynomials, such as normal forms and reduced forms; and determine bases (as mathematical modules) for the kernel of a matrix polynomial.


For more information, see MatrixPolynomialAlgebra[Degree], MatrixPolynomialAlgebra[MatrixGCRD], MatrixPolynomialAlgebra[HermiteForm], and MatrixPolynomialAlgebra[MahlerSystem].



The ScientificConstants package provides access to the values of various constant physical quantities that occur in fields such as chemistry and physics. For example, the velocity of light, or the melting point of sodium as shown in the following example.


evalf( Constant( c, units ) );



evalf( Element( Na, meltingpoint, units ) );



You can express the values of ScientificConstants objects in any compatible system of units that the Units package recognizes.


The ScientificConstants package contains an initial dataset of fundamental physical constants and properties of the elements (and their isotopes) of the Periodic Table.  You can maintain this dataset. In particular, you can modify existing values or add values of special interest.


Changes to the ScientificConstants package since the initial version was released on MaplePrimes are listed on the ScientificConstants/updates page.



The SNAP (Symbolic-Numeric Algorithms for Polynomials) package provides a set of tools for the algebraic manipulation of numerical polynomials in a numerically reliable way.


The tools in the package include support for operations such as quotient, remainder, and various numeric GCDs. Additional operations include numerical computations which return the last numerically stable Euclidean reduction and an approximation to the distance of a closest common root of two relatively prime numeric polynomials.



The SoftwareMetrics package contains a collection of functions which analyze the code complexity of a Maple module or procedure. The metrics in this package include McCabe's cyclomatic complexity metric, Halstead's software science metrics, and metrics which provide detail about nesting depth.


For example, use SoftwareMetrics to analyze this procedure taken from the Maple 8 Introductory Programming Guide.


sieve := proc(n::integer)
    local i, k, flags, count, twice_i;
    count := 0;
    for i from 2 to n do flags[i] := true end do;
    for i from 2 to n do
        if flags[i] then
            twice_i := 2*i;
            for k from twice_i by i to n do flags[k] := false end do;
            count := count+1;
        end if;
    end do;
end proc:


Cyclomatic Complexitysieve5



Halstead's MetricsOperator/Operand Count[n,N,V,D,L,E][[n1,N1],[n2,N2]]sieve131970.308354621.80000000021.70010945126.55503833,7,10,12







The Student package is a collection of subpackages covering basic undergraduate mathematics courses.  Maple 8 includes the Calculus1 subpackage which covers the material of a standard single-variable calculus course.


The Calculus1 package includes commands for visualizing the important concepts, theorems and computations of single-variable calculus. It also has a powerful facility that enables a calculus teacher or student to work through limit, differentiation, and integration problems in a step-by-step manner.


The Calculus1 package supersedes most of the functionality available in the student package and provides additional functionality.



The SumTools[Hypergeometric] submodule provides various tools for finding closed forms of definite and indefinite sums of hypergeometric type. You can also certify and prove combinatorial identities using this submodule.


The submodule consists of three main components:


Normal forms of rational functions and of hypergeometric terms CanonicalRepresentation, MultiplicativeDecomposition, PolynomialNormalForm, RationalCanonicalForm, and SumDecomposition.


Algorithms for definite and indefinite sums of hypergeometric type AccurateSummation, ExtendedGosper, Gosper, IsZApplicable, Zeilberger, ZeilbergerRecurrence, and ZpairDirect.


Applications DefiniteSum, IndefiniteSum, and WZMethod.


Other auxiliary functions include AreSimilar, IsHolonomic, IsHypergeometricTerm, IsProperHypergeometricTerm, and Verify.



Use the TypeTools package to extend the set of types that Maple recognizes. If you add a new kind of object to Maple, this package allows you to define a type for this new object. Consider the following example for FooBar().

TypeTools:-AddType('FooBar', t->type(t,'specfunc(anything,FooBar)') and nops(t)=1 and type(op(1,t),'integer') );

type( FooBar(42), 'FooBar');



type( FooBar([a,b]), 'FooBar');



hastype( a*FooBar(1)+b, 'FooBar');





The VariationalCalculus package allows you to perform typical computations from calculus of variations, including finding the Euler-Lagrange equations and some of its first integrals for the extremal (maximum, minimum, or saddle) of a functional given by a classical integral form.  Further, there are commands to test certain conditions that are sufficient to guarantee that the solution of the Euler-Lagrange equations is a true minimum. The simplest of these is a test for convexity of the functional defining the minimum. This test relies on the LinearAlgebra routine IsDefinite. Other useful tests include the Weierstrass excess function and Jacobi's conjugate points.


With the power of dsolve, the VariationalCalculus package provides useful methods to solve classical calculus of variations problems.



Building on the LinearAlgebra package introduced in Maple 6, Maple now has a new package VectorCalculus for carrying out multivariate and vector calculus computations.  The package includes a full suite of routines for working in 2- and 3-dimensional spaces, and additionally supports many computations in higher dimensions.  A wide range of coordinate systems is provided, and there are facilities for adding and working with further coordinate systems.


This package and the LinearAlgebra package together replace, and significantly modernize and enhance, the older linalg package.



The Worksheet package provides programmatic access to XML document representations of Maple worksheets.  The package includes a parser for the worksheet native format that returns an XML tree representation of the parsed worksheet, a worksheet formatter that writes an XML tree representation in worksheet native format, and a validator for XML tree representations of worksheets.


The package also includes an XML DTD for the worksheet XML representation. This allows you to make use of third party XML-based tools to edit or process worksheets.


In addition, it is possible to programmatically display a worksheet within Maple user interfaces that support the worksheet file format. You can save worksheets as XML and import them from their XML representations stored on hard disk or other media.

Enhanced Packages



The combinat package has a new command setpartition. This routine partitions a set of n objects into ordered subsets of size k.  For example,








Combinatorial Attributes and Attribute Grammars


An attribute can be the value of a function, for example, the internal path length of a tree.


It can be the cost of an algorithm when run over a certain type of data structure, for example, differentiation of an algebraic expression.


It can be a simple weighting, for example, the left child of a node counts for twice that of a right child.


It can be the output of a finite state machine transition function.


An attribute grammar is a precise, recursive way to define such a property on a combinatorial structure.

Enhancements to Combinatorial Expressive Power


The combinatorial expressive power of Maple increases with this release. The package combstruct now contains routines to handle attribute grammars for combinatorial structures.

New Tools


Combstruct now provides the user with multivariate generating function tools for structures and their attributes. Examples of such tools are formal series development and sets of functional equations satisfied by a generating function. These equations, with the aid of other tools, can be manipulated to give information like the average value of an attribute over all structures of size n, for arbitrary n. The variance and higher moments are equally accessible for additional statistical information.


This addition marks a notable increase in the kind of combinatorial problems suited to analysis within Maple.



A Dyck path is a collection of unit steps on a grid in the up-left direction (U), or the down-left direction (D) such that the path never dips below the horizon and finishes exactly at the horizon. For example, UUDUDDUD describes such a path. Put another way, it is a word w made from an equal number of Us and Ds such that any prefix of w has at least as many Us as Ds.


It can be decomposed as a sequences of smaller paths, each of which touch the horizon exactly once. Represent this with the following combstruct grammar.

dpaths:= {Path=Sequence(Mountain), Mountain=Prod(Up, Path, Down),
    Up=Atom, Down=Atom}:


Dyck paths are counted by Catalan numbers and have some surprising properties. There may be interest in the area underneath the path when viewed on a grid. For example, AreaUD=1, AreaUUDD=3, AreaUDUD=2, ...  This property can be expressed as an attribute. If you refer to the combstruct description, for example, the area of a Path is the sum of the areas of the mountains. The area of a mountain is the size of its base plus the area of the raised part. The size of its base is the number of leftward moves it has made minus one for the half endpoints. Represent this in combstruct as the following.

area:= {Area(Path)=Sequence(Area(Mountain)),


From this point, you can view the multivariate generating series.





Path(z,u) = agfseries(dpaths, area, unlabelled, z, [[u, Area]])[Path(z,u)];



This can be decoded as: "there is one empty path of no area, one path of length two with area one, two paths of length six with area 5, and so on."


You can determine the generating function relationships.

eqns:=agfeqns(dpaths, area, unlabelled, z, [[u, Area]]);



You can determine that the generating function Path2z that has the property that the coefficient of zn in Path2z is the total area for all paths of size n.

subs(agfmomentsolve(eqns, 1), Path[2](z));






From this, you can deduce the average area of a Dyck path of length 6, is 29/5.


In certain cases, you can solve for the general value or at least determine the asymptotic value.  For more information, see Attribute Grammars and Combinatorics.



The CurveFitting[PolynomialInterpolation] routine now has an option to express the resulting polynomial interpolant in either the standard monomial basis or the Newton interpolation basis.



The Spline function in the CurveFitting package allows you to specify different boundary conditions using the new endpoints option.  Natural, not-a-knot, periodic, clamped, and generalized boundary conditions are available. For more details, see SplineConditions.

CurveFitting[Spline]([[0,0],[1,5],[2,-1],[3,0]], v, degree=2,



DEtools and PDEtools


The DEtools package contains new commands as well as significant enhancements to existing commands for exact and numeric solutions. For more details, see updates,Maple8,differential_equations and updates,Maple8,symbolic.


Modular Subpackage


The LinearAlgebra package has a new subpackage, Modular, which performs linear algebra operations modulo a prime or composite over the positive range.  The subpackage is designed as a programmer package. Thus, it performs minimal or no data checking on the input, but operations are very fast.  For example, calling a routine expecting an integer-valued Matrix with entries in the range 0..p1 gives an incorrect answer if any entries are outside that range.


The core of the package is a number of basic operations in an compiled external library. There are two hardware datatypes available for use in the package which must be referenced explicitly. One is the standard half-word size integer with maximum modulus 2^16-1 on 32-bit platforms, the other is a half-float size integer with maximum modulus 2^25-1 for all platforms.


For completeness, there are also routines for working with larger moduli using Maple integers, but these are naturally slower than their hardware counterparts.


Routines are available for computing mod, an equivalent to mod(Eval(...)), basic operations like matrix addition, matrix multiplication, scalar multiplication, basic data operations such as copy, fill, transpose, as well as routines for Gauss row reduction, LU decomposition, determinant, inverse, adjoint, and basis. The complete set of functions is described in LinearAlgebra[Modular], and the following is a list of commands available in the subpackage.






The LinearAlgebra[BezoutMatrix] routine has been improved to allow a symmetric Bezout matrix to be returned.  This is more useful in some contexts due to improved null space stability. However, it can be more complicated in other contexts.  Thus, the form of the Bezout matrix used in versions of Maple prior to Maple 8, remains the default.



The LinearAlgebra[CompanionMatrix] routine has been improved to handle non-monic polynomials, Matrix polynomials, and polynomials expressed in more bases than just the standard monomial basis.  The bases can be orthogonal polynomials such as the Chebyshev polynomials, or nonorthogonal bases such as the Lagrange or Newton interpolation bases. The routine now returns a matrix pencil in the non-monic case.



The LinearAlgebra package also contains a new EigenConditionNumbers routine.  This computes any of the eigenvalues, eigenvectors, condition numbers of the eigenvalues, or the condition numbers of the eigenvectors for real or complex, generalized or nongeneralized problems.  This scheme works for both hardware and software floating-point problems.



The HermiteForm routine now includes a new option method=integer[reduced] to compute a reduced transforming matrix.

use LinearAlgebra in
   A := RandomMatrix(6,2);
end use;







The LeastSquares routine in the LinearAlgebra package now contains an indirect sparse real solver for floating-point problems with more rows than columns. Matrices created with the storage=sparse option specified which are of type numeric with at least one floating-point entry automatically use this solving scheme.  This scheme works for hardware and software floating-point problems.



The MatrixInverse routine in the LinearAlgebra package now contains a scheme to compute the Moore-Penrose pseudo-inverse for floating-point and exact Matrices.  By default, nonsquare Matrices use this scheme.

A := Matrix(2,3,[[1,-3,2],[4,7,-3]]);



use LinearAlgebra in
   X := MatrixInverse(A);
   Norm( A . X . A - A );
   Norm( X . A . X - X );
   Norm( HermitianTranspose( A . X ) - A . X );
   Norm( HermitianTranspose( X . A ) - X . A );
end use;







Orthogonal Polynomial Representation


Prior to Maple 8, the simple orthogonal polynomials of index 0 such as ChebyshevT(0, x) automatically simplified to 1. This behavior has been changed for consistency. If you want to use ChebyshevT representations, that representation will not be changed unless it is requested via expand.



The new routine networks[draw3d] draws a graph G=V&comma;E in 3-dimensional space.  The algorithm used is the same as that described for plots[graphplot3d].  The networks[draw3d] and plots[graphplot3d] functions are identical except they accept different forms of graph input. For example,


G := dodecahedron():

draw3d(G,title="A dodecahedron");



The numtheory package contains a new routine migcdex for computing the minimum magnitude solution to a special version of the extended Euclidean problem for integers.



The plots package contains two new commands: graphplot3d and plotcompare.



The graphplot3d routine draws a graph G=(V,E) in 3-dimensional space.  It computes the eigenvectors e1, e2, e3, e4,... of the adjacency matrix of the graph G and locates the vertices of G in R^3 by locating the jth vertex in G at (x, y, z) co-ordinates (e2[j], e3[j], e4[j]).  This construction recovers symmetric spatial arrangements for graphs in R^3 from the adjacency information only. For example,


Error, (in with) package plots does not export graphplot3d

cube := Matrix(8,8,shape=symmetric):

cube[1,2] := 1: cube[2,3] := 1: cube[3,4] := 1: cube[1,4] := 1: # front

cube[5,6] := 1: cube[6,7] := 1: cube[7,8] := 1: cube[5,8] := 1: # back

cube[1,5] := 1: cube[2,6] := 1: cube[3,7] := 1: cube[4,8] := 1: # join




Given two functions f(z) and g(z), the plotcompare command outputs four plots corresponding to the real and imaginary parts of the functions. The plots are displayed as a 2 x 2 table of plots. You can see visually where they are the same and where they differ. The default domain for z is the complex unit box. If the domain is purely real or purely imaginary, four 2-D plots return. Otherwise, four 3-D plots return.

Example 1


In Maple, the value of (-8)^(1/3) is not -2, it is a complex number because Maple uses the principal branch when computing x^(1/3).  You can use surd(x, 3) or signum(x)*abs(x)^(1/3) to obtain the real branch.  These four plots illustrate the difference.




plotcompare( x^(1/3), signum(x)*abs(x)^(1/3), x=-2..2 );

Example 2


Consider this identity as shown in Abramowitz and Stegun and other textbooks.

eq := AiryAi(z) = 1/3*3^(1/2)*z^(1/2)/Pi*BesselK(1/3,2/3*z^(3/2));



The following plot of both sides of the equation shows that this relation is not valid over the whole complex plane.

plotcompare( eq );


To visualize the regions where the equality holds and those where it does not, you can plot 2-D projections by using plotcompare with assuming.

plotcompare(eq) assuming z::real;

plotcompare(eq) assuming z::imaginary;



The PolynomialTools package includes three new routines, PolynomialTools[CoefficientList], PolynomialTools[CoefficientVector], and PolynomialTools[Hurwitz].  The last routine gives conditions under which all roots of an input polynomial lie in the left half plane.



The process package contains a new command launch. Use the launch command to execute another program in the background.




The Slode package procedure Slode[mhypergeom_formal_sol] has many improvements. It can now construct "nice" formal solutions of differential equations when the series coefficients satisfy homogeneous or inhomogeneous recurrences with more than two terms. That is, if it can solve an equation Lyx=0, it is able to solve an equation of the form Myx=0 where the differential operator L is a right divisor of M.









The new HostInfo command in the Sockets package provides access to host-specific information.

use Sockets in
   HostInfo( 'domainname' );
   HostInfo( 'hostname' );
   HostInfo( 'platform' );
end use;








The new CancelInverses command in the SolveTools package allows you to simplify expressions by canceling functions that are inverse to each other.

use SolveTools in
end use;






The new Combine command in the SolveTools package allows combine parts of expressions containing logarithms, exponentials, and powers.

use SolveTools in
end use;







The new Linear command in the SolveTools package solves systems of linear equations with various coefficients. It replaces the internal procedure `solve/linear` and makes it available to users.


Use the SolveTools[Linear] command when solving symbolic equations rather than LinearAlgebra[LinearSolve], since the latter calls SolveTools[Linear]. Also, if the coefficients are known, specify the method option, saving on type checking, which leads to significant efficiency gains especially for large systems.

use SolveTools in
   Linear({x+RootOf(_Z^2-s)*y=11, x*RootOf(_Z^2-t)+3*y=10*RootOf(_Z^3-s)},
   Linear({x-y-z=5,x*z+3*y=10},{x,y}, method=Polynomial);
end use;








The StringTools package includes a new FormatTime routine. Use this routine to generate strings with formatted date and time information.

use StringTools in
   FormatTime(); # today
   FormatTime( "%T" ); # current time
   FormatTime( "%Y-%m-%d", -60*60*24 ) # yesterday
end use;





The StringBuffer constructor efficiently builds long strings in pieces by appending the pieces one at a time.

use StringTools in b := StringBuffer() end:

for ch in "Canada!" do
   b:-append( ch );
   b:-append( " " )
end do:
use StringTools in TrimRight( b:-value() ) end;

C a n a d a !


By using the new ToByteArray and FromByteArray routines, you can convert Maple strings to and from byte arrays.. A ``byte array'' is an Array with datatype equal to integer1.


By using the new Encode procedure, you can process strings by subjecting them to text encodings. The results may be decoded by using Decode.

use StringTools in
   s := Encode( "An encoding test.\n", 'encoding' = 'base64' );
   Decode( s, 'encoding' = 'base64' )
end use;


An encoding test.


The base 64 encoding is useful for processing the content of Maple worksheets in XML format.


Other new utilities in the StringTools package include Escape, Fill, and Iota. For more information, see the corresponding help page.



The XMLTools package includes several new utilities and a validating XML parser. New routines include ApplyElement, AttributeTable, DocumentIterator, GetChildByName, IsElement, ReplaceChild, and Validate.