New and Enhanced Packages

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


New Packages



CodeGeneration


•

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.

2.

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

3.

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

4.

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

5.

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

6.

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.



LargeExpressions


•

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.



LibraryTools


•

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.



Maplets


•

The Maplets package provides a Maple and Maplestyle 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.



MatrixPolynomialAlgebra


•

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.



ScientificConstants


•

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.

>

with(ScientificConstants):

>

evalf( Constant( c, units ) );

 (1) 
>

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

 (2) 

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.



SNAP


•

The SNAP (SymbolicNumeric 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.



SoftwareMetrics


•

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;
count;
end proc:

>

CyclomaticComplexity('sieve');

 (3) 
>

HalsteadMetrics('sieve');

 (4) 
>

NestingMetrics('sieve');

 (5) 


Student


•

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 singlevariable calculus course.


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


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



SumTools[Hypergeometric]


•

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:



TypeTools


•

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');

 (6) 
>

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

 (7) 
>

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

 (8) 


VariationalCalculus


•

The VariationalCalculus package allows you to perform typical computations from calculus of variations, including finding the EulerLagrange 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 EulerLagrange 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.



VectorCalculus


•

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 3dimensional 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.



Worksheet


•

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 XMLbased 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



combinat



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

>

combinat[setpartition]([1,2,3,4],2);

 (9) 
>

combinat[setpartition]([1,1,2,3],2);

 (10) 


combstruct



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.



Example


•

A Dyck path is a collection of unit steps on a grid in the upleft direction (U), or the downleft 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}:

>

area:= {Area(Path)=Sequence(Area(Mountain)),
Area(Mountain)=Prod(0,Area(Path),0)+size(Mountain)1}:


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

 (11) 
>

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

 (12) 

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]]);

 (13) 
>

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

 (14) 
 (15) 

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




CurveFitting


•

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.


Spline


•

The Spline function in the CurveFitting package allows you to specify different boundary conditions using the new endpoints option. Natural, notaknot, 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,
endpoints='periodic');

 (16) 



LinearAlgebra



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 integervalued Matrix with entries in the range 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 halfword size integer with maximum modulus 2^161 on 32bit platforms, the other is a halffloat size integer with maximum modulus 2^251 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.

>

with(LinearAlgebra:Modular);

 (17) 


BezoutMatrix


•

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.



CompanionMatrix


•

The LinearAlgebra[CompanionMatrix] routine has been improved to handle nonmonic 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 nonmonic case.



EigenConditionNumbers


•

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 floatingpoint problems.



HermiteForm


•

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

>

use LinearAlgebra in
A := RandomMatrix(6,2);
HermiteForm(A,output=['U'],method=integer);
HermiteForm(A,output=['U'],method=integer[reduced]);
end use;

 (18) 


LeastSquares


•

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



MatrixInverse


•

The MatrixInverse routine in the LinearAlgebra package now contains a scheme to compute the MoorePenrose pseudoinverse for floatingpoint and exact Matrices. By default, nonsquare Matrices use this scheme.

>

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

 (19) 
>

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;

 (20) 


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.




networks



The new routine networks[draw3d] draws a graph in 3dimensional 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,

>

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



numtheory


•

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.



plots



graphplot3d


•

The graphplot3d routine draws a graph G=(V,E) in 3dimensional 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) coordinates (e2[j], e3[j], e4[j]). This construction recovers symmetric spatial arrangements for graphs in R^3 from the adjacency information only. For example,

>

with(plots,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



plotcompare


•

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 2D plots return. Otherwise, four 3D 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.

>

with(plots,plotcompare);

 (21) 
>

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));

 (22) 

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


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

>

plotcompare(eq) assuming z::real;

>

plotcompare(eq) assuming z::imaginary;




process


•

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



Slode



mhypergeom_formal_sol


•

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 , it is able to solve an equation of the form where the differential operator L is a right divisor of M.

>

L:=x*y(x)+(2*x+1)*x*diff(y(x),x)+(1/2*x+1)*x^2*diff(y(x),x,x):

>

Slode[mhypergeom_formal_sol](M,y(x));

 (23) 



Sockets



HostInfo


•

The new HostInfo command in the Sockets package provides access to hostspecific information.

>

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

 (24) 



SolveTools



CancelInverses


•

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
CancelInverses(exp(2*LambertW(ln(x))));
CancelInverses(arcsin(sin(x)));
end use;

 (25) 


Combine


•

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

>

use SolveTools in
Combine(3*exp(x)*exp(y));
Combine(4*x*ln(a)+5*x*ln(b));
Combine((x^a)^5);
end use;

 (26) 


Linear


•

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({xy=5,x+3*y=10},{x,y});
Linear({x+RootOf(_Z^2s)*y=11, x*RootOf(_Z^2t)+3*y=10*RootOf(_Z^3s)},
{x,y},method=AlgebraicFunction);
Linear({xyz=5,x*z+3*y=10},{x,y}, method=Polynomial);
end use;

 (27) 



StringTools



FormatTime


•

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;

 (28) 

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;

 (29) 

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 .


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;

 (30) 

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.




