## Contents

### Maple componentsEdit

Maple has three main components: user interface, kernel and library.

Recent versions of Maple include three user interface executables (for most operating systems), two graphical user interfaces (GUI): Standard GUI and Classic GUI, and a command-line (character-based) interface.

The Standard GUI is a Java application, while the Classic GUI is a native application.

The kernel (interpreter) deals with Maple's basic features (e.g. elementary data structures, input/output, integer and rational arithmetic, simple polynomial calculations and elementary simplification). It is written in C and C++. It is loaded in its entirety when a Maple session is initiated.

The Library contains most of the routines of the system. It is written in the Maple high-level programming language. This is an interpreted language. It is not compiled. Its routines are stored in the .mla archives. Library routines are loaded into the system as required. The modularity of this design allows users to consume computer resources proportional to the algebraic facilities actually used.

Some numerics are also inplemented in C and C++ and accessed on the fly by Library routines using Maple's external calling mechanism.

With the exception of the builtin functions, the Maple source code for each routine may be displayed.

Maple has a comprehensive on-line help facility.

### OperationEdit

Maple appears to the user as an "interactive calculator".

Input to the Maple system consists of a sequence of statements separated by the statement separators (semicolon *;* and colon *:*). The system operates in an interactive mode, executing statements as they are entered.

The main program reads input, calls the parser, and then calls the statement evaluator for each complete statement encountered.

There are eight types of statements in Maple: assignment statement, expression, read statement, save statement, selection statement, repetition statement, empty statement and quit statement.

Maple will read an infinite number of statements; its normal conclusion is achieved by the evaluation (not the parsing) of the quit statement.

The parser and some basic internal functions are responsible for building all the data structures used internally by Maple.

### Maple LanguageEdit

The Maple language was designed to be used interactively.

A unifying point of view is that all variables in Maple are programming variables. The ones that are used as mathematical symbols have as their value their own name; those used as programming variables have something else assigned as their value.

The Maple character set consists of letters, digits, and special characters.

The tokens consist of keywords, programming-language operators, strings, natural integers, and punctuation marks.

Numbers, strings, and names are the simplest objects in Maple.

A natural integer is any sequence of one or more digits. The numeric constants in Maple (integers, rational numbers, and floating-point numbers) are formed from natural integers using programming-language operators. The length of a natural integer, and hence the length of integers, rational numbers, and floating point numbers, is arbitrary (that is, the length limit is system dependent but generally much larger than users will encounter).

#### Names and stringsEdit

A name is a sequence of characters that can be assigned a value, hence it represents a variable. Any expression can be assigned to a name. If no value has been assigned to the name, then it stands for itself.

The simplest instance of a name is a letter (a-z, A-Z) followed by zero or more letters, digits (0-9), and underscores (_). Ie. Maple distinguishes between upper and lower case letters. Thus the names *pvar*, *Pvar*, *PVAR*, *pVaR* all refer to different variables. The maximum length of a name is system dependent. On 32-bit platforms, it is 524,271 characters; on 64-bit platforms, it is 34,359,738,335 characters. On 16-bits was 499 characters?

Another instance of a name is the underscore followed by zero or more letters, digits, and underscores. Such names are used as global variable names by Maple and are effectively reserved for use by library code. The exception are names beginning with *_Env*, considered environment variables.

Some other names are already defined by Maple, either as keywords (e.g. *if*, *then*, *else*, *do*, *quit*), as command names (e.g. *sin*, *cos*, *ln*, *diff*, *int*), environment variables (e.g. *Digits*, *UseHardwareFloats*, *printlevel*, *Rounding*) or as predefined mathematical constants (e.g. *Pi*, *I*, *GAMMA*).

Therefore such names should be avoided by the users.

A name may also be formed by enclosing any sequence of characters in a pair of backquote characters (left single quotes) (` `). For example:

>`This is a name`;

A string is a sequence of characters that has itself as a fixed value (it cannot be assigned any other value). The maximum length of a string is system-dependent. On 32-bit platforms, it is 268,435,439 characters; on 64-bit platforms, it is 34,359,738,335 characters.

A string is written by enclosing any sequence of characters within a pair of double quote characters (" "). For example:

>"This is a string";

#### ExpressionsEdit

Expressions are the fundamental entities in the Maple language.

Every Maple expression is kept in a data structure.

A set is a non-ordered collection of expressions. Any valid Maple expression can be contained in a set.

#### Types and PropertiesEdit

Each object in Maple has a type associated with it.

A type is defined by a domain or a subdomain of computation.

Unassigned names in Maple, since there are no declarations, can represent any data type.

In Maple, a type is any expression which is recognized by the type function and causes it to return true from some set of expressions and false otherwise.

A type can be a simple type or a structured type. They can be predefined within Maple or defined by the user. A simple type is one which is identified by a single name, while structured types can be composed from simple types or other structured types. Structured types can also be defined recursively.

Keep in mind that while you can always query the type of an object, there is no way in Maple to stipulate that a certain variable will always be of a certain type.

In general, Maple tries to preserve the type of data.

There is a fundamental difference in Maple between the type of an object, which generally deals with the kind of data structure the object actually is, and the properties, which deal with the kind of mathematical object it can stand for.

There is a distinction between types and properties. An *object* *has* types inherent to its nature -- it cannot be given or "assigned" or declared to be a type.

A name or symbol can be given properties. Some objects which are more complicated than symbols can also be given such properties. Many properties have names that are the same as types. "float" is a property and a type. A symbol could never be of type float, integer, etc., but it can be assigned that property.

#### OperatorsEdit

There are three types of programming-language operators, namely the binary, unary, and nullary operators.

The Concatenation or *||* Operator (formerly dot operator) is a name-forming operator in Maple -- it produces global names.

The ditto operator, *%* , which recalls the last result, is local to procedures but Maple evaluates it fully.

*@* is the function composition operator.

*@@* is the repeated function composition operator

#### EvaluationEdit

In Maple, statements are normally evaluated as far as possible in the current enviroment.

Evaluation of an expression in Maple is normally performed in a full, recursive evaluation mode.

Whether within a procedure or at the interactive level, Maple always applies the same evaluation rules to global variables. It evaluates all global names fully, except when (*) the value (*) of such variable is a table or a procedure, in which case, Maple halts its evaluation at the last name in the chain of assignments. This evaluation rule is called last-name evaluation.

(*) full evaluation (*)

The main exceptions to the rule of full evaluation are special data structures like tables, matrices, and procedures, and the behavior of local variables inside a procedure.

Put simply, enclosing an expression in forward quotes delays evaluation of that expression for one trip through Maple's parser.

Quoting an expression delays evaluation, but does not prevent automatic simplifications and arithmetic.

Concatenation generally follows the full evaluation rule except that the leftmost symbol is not evaluated.

The evaluation of Boolean expressions in Maple uses three-valued logic.

### Internal RepresentationEdit

In Maple, there is only one instance of each object in memory.

Internally, Maple breaks down each object into logical subobjects, which are then again broken down into even smaller subobjects, until basic elements are reached.

Every expression in Maple is represented internally by an expression tree where each node is a particular data type.

Every structure in Maple is made up of individual parts, or operands, strung together by various operators.

The structure of an expression can be modeled after a tree. These tree models are also known as "directed acyclic graphs" or DAGs.

Maple's overall performance is in part achieved by the use of table-based algorithms for critical functions. Tables are used within the maple kernel in both evaluation and simplification, as well as less crucial functions. For simplification, Maple keeps a single copy of each expression or subexpression within an entire session.

By far, the most important table maintained by the Maple kernel is the simplification table. The main purpose of this table is to ensure that simplified expressions have a unique instance in memory. Every expression, which is entered into Maple or generated internally, is checked against the simplification table, and if found, the new expression is discarded and the old one is used.

Every expression is entered in the simplification table using its signature as a key. The signature of an expression is a hashing function itself, with one very important attribute: signatures of trivially equivalent expressions are equal. If two expressions disagree then the expressions cannot be equal at the basic level of simplification.

If the signature is found then a full comparison is performed to verify that it is the same expression.

Also, since the relative order of live objects is preserved during garbage collection, this means that sequences of objects can be ordered by machine address.

It is possible to store Maple objects in a sequential file using a fast-loading internal format.

Arrays and tables are implemented using Maple's internal hash tables. Because of this, sparse arrays are equally as efficient as dense arrays.

### PackagesEdit

A package in Maple is a collection of related functions stored together in the Maple library.

A package is really a table of functions, and the table-lookup syntaxes invokes a procedure in the package directly.

A package is simply a table in which the entries are procedures and the indices are "short forms" for the names of the procedures.

The concept of a package in Maple permits the user to define an entire collection of new functions with just one Maple command, namely the *with* command.

Maple packages load very quickly because, in effect, loading a package requires nothing more than defining the locations of the new functions in the library. No code is loaded, but each of the member functions of the package becomes readlib-defined. (update)

#### Build you own Maple packageEdit

To build a Maple package, start with module,with option package

modu:=module();

option package; ........... ........... .............. end module;

type(modu, package);

true