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

OpenMaple Application Program Interface (API) for Python

 OpenMaple for Python provides an interface between the Maple evaluation engine and a Python program.  This is implemented using Python classes and standard interfaces.

Overview

 To use the Maple API for Python, start by importing the library maple. This implicitly launches a Maple session.

 import maple

maple Package

 • The maple package has the following commands:

 • To access Maple variables and predefined functions and commands, you can use the symbol or symbols function or import the maple.namespace interface:
 – The symbol function returns an Expression object.
 – The symbols function returns a tuple of Expression objects.
 – The namespace subpackage offers general access to any Maple name or function.
 – The range function returns an Expression object corresponding to a Maple range.

maple.namespace Subpackage

 • The maple.namespace subpackage allows any Maple name or function to be accessed with a simple prefix. This prefix is arbitrary, but for consistency in these examples we will assume the subpackage was assigned the name mpl after being imported with the following command.

 import maple.namespace as mpl

 • Global names or commands may be referenced as mpl.sin, mpl.solve, etc.
 • Commands in Maple packages or subpackages may be referenced using the chosen prefix and replacing instances of the Maple member selection operator (:-) in the Maple qualified name with a period (.). For example, LinearAlgebra:-Determinant would become mpl.LinearAlgebra.Determinant.

Classes

 • Every OpenMaple object created in a Python session is an Expression object.
 • Depending on the type of the underlying Maple expression, the object may also be an instance of a subclass of Expression, such as ComplexNumeric or List.

Class Listing

Expression

 • The Expression class is the parent class of all the classes that represent Maple objects.  Its member functions provide access to all the basic functions that can be performed on a Maple expression.

ComplexNumeric

 • The ComplexNumeric class represents complex numbers.  Conceptually, a ComplexNumeric object contains two RealNumeric objects: its real part and its imaginary part.
 • Inherits from Expression.

RealNumeric

 • The RealNumeric class represents numeric literals. Note that Maple integers and fractions appearing in output from OpenMaple computations are represented as Python integers and Fractions.fraction objects, so this class is effectively only used for floating-point numbers.
 • Inherits from ComplexNumeric.

Name

 • The Name class represents a Maple symbol. This includes both global symbols and names defined in Maple packages.
 • Inherits from Expression.

Indexable

 • The Indexable class is the parent class of all the classes that represent Maple collections.  Its member functions provide access to the basic functions that can be performed on a collection, such as querying its size and testing for membership.
 • Inherits from Expression.

ExpressionSequence

 • The ExpressionSequence class represents a Maple expression sequence.
 • Inherits from Indexable.

List

 • The List class represents a Maple list.
 • Inherits from Indexable.

RTable

 • The RTable class represents an rtable (rectangular table), a Maple data structure for storing homogenous data of arbitrary dimension.
 • Inherits from Indexable.

Set

 • The Set class represents a Maple set.
 • Inherits from Indexable.

Table

 • The Table class represents a table.  Data can be inserted and removed from the table and a table can be searched for a particular element.
 • Inherits from Indexable.