Changes to the Maple Language in Maple V Release 5
Several changes and improvements have been made to the Maple programming language and system. A brief description of these changes and improvements follows.
Lexical scoping
Strings
Multiple Assignment
:
Other Language Changes
New Functions and Types
System
Maple V Release 5 implements lexical scoping.
Please see the help page updates/R5/highlights, or the lexical example worksheet for some examples illustrating the significance of this language change.
A new feature of Maple is the ability to create strings. More information about strings is available in highlights, and examples have been provided in the strings example worksheet .
"This is a string";
This is a string
Because strings require double quotation marks, the recall operator in Maple V Release 5, formerly written as ", is now written as %. Similarly, "" and """ become %% and %%%, respectively.
a := 2;
a≔2
b := 3;
b≔3
%;
3
%%;
b := 'b':
Strings may be converted to names (or symbols) using the convert command.
convert( "A string", 'symbol' );
A string
The percent character is reserved for system-defined names. Users should not use % at the beginning of a name.
Multiple assignments can be made in a single Maple instruction in Release 5.
ll := ["a", 1, "b", 2, "c", 3, "d" ];
ll≔a,1,b,2,c,3,d
strings, numbers := select( type, ll, 'string' ), remove( type, ll, 'string' ):
strings;
a,b,c,d
numbers;
1,2,3
The typematch operator ::, used frequently to provide for automatic type checking of arguments to procedures, used to be called :.
Use of the single colon form of the typematch operator is no longer supported in Release 5. (A warning was issued in Release 4; now, it is an error.)
The exponentiation operator `^` is now a function; this affects type.
The following operators are now also functions: `<`, `<=`, `>`, `>=`, `=`, `<>`
Allow checking for the types assigned to unevaluated names.
a := 2.5;
a≔2.5
type( 'a', name( integer ) );
false
type( 'a', name( float ) );
true
Expressions of the following forms are now acceptable input.
'A'[i]
A[ 1 ] := "string";
A1≔string
'A'[ 1 ];
string
(expression)[i]
( a * b + c )[1];
2.5⁢b+c1
<a>[i]
< a >[i];
2.5i
{set}[i]
{ 1, 2, 3, 4 }[ 2 ];
2
[list][i]
[ 4, 3, 2, 1 ][ 3 ];
Functions
Several new system level procedures have been added.
The new function nprintf is like sprintf, but it returns a name instead of a string.
a := 5;
a≔5
nprintf( "The value of \"a\" is %d\n", a );
The value of "a" is 5
sprintf( "The value of \"a\" is %d\n", a );
Use the procedure timelimit to limit the amount of CPU time spent on a computation.
f := proc(n::posint) local i; for i from 1 to n do 2^i; od; end;
f:=procn::posintlocali;foritondo2^iend doend proc
timelimit( 3, f( 10^6 ) );
Error, (in f) time expired
Operating system environment variables (on platforms that have them) can be retrieved using the new procedure getenv.
getenv( "PATH" );
/u/maple/research/bin:/usr/bin:/usr/openwin/bin:/usr/ucb:/usr/local/bin
The current directory of the Maple process can be queried, or set (on platforms that support this), using the procedure currentdir.
currentdir( "/" ): # old working directory is returned
currentdir(); # print cwd
/
A new format %A has been added to printf. It is essentially the same as the %a format except that backquotes are not put around names even though they might need it to be valid maple input.
Types
The new type constructors And, Or, and Not allow you to construct new types from existing types by means of boolean combinations, or to test directly for boolean combinations of type.
type( Pi, 'And( constant, numeric )' );
type( Pi, 'And( constant, Not( numeric ) )' );
type( 3.14, 'And( constant, numeric )' );
`type/stringythingy` := 'Or( string, name )';
type/stringythingy≔string∨name
type( `foo`, 'stringythingy' );
type( "bar", 'stringythingy' );
type( 27, 'stringythingy' );
Use the new type arctrigh to test for an expression that is a call to an inverse hyperbolic function.
type( sin( x ), 'arctrigh' );
type( arcsin( x ), 'arctrigh' );
type( sinh( x ), 'arctrigh' );
type( arcsinh( x ), 'arctrigh' );
An optional additional argument allows you to check that the expression is an inverse hyperbolic function of some name.
type( arctanh( 2 * sin( x / y ) ), 'arctrigh( x )' );
type( arctanh( 2 * sin( x / y ) ), 'arctrigh( t )' );
An object is of type atomic if it is a string, fraction, integer, float, indexed or symbol. You can test for objects of type atomic as in the following examples.
type( 2, 'atomic' );
type( a[i], 'atomic' );
type( "a string", 'atomic' );
type( ( x + y ) * z, 'atomic' );
type( 2/3, 'atomic' );
If evalf returns a number of the form a + b * I, with a and b floating point numbers, or if evalf returns infinity or -infinity, then the solution is of type complex constant, called complexcons.
type( -infinity, 'complexcons' );
type( arcsinh( 1 + I ), 'And( complexcons, arctrigh )' );
Arrays of hardware floating point numbers (hfarrays) are new in Maple V Release 5. They are of type hfarray.
a := hfarray( 0..2 );
a≔Array⁡0..2,0=Float⁡undefined,1=Float⁡undefined,2=Float⁡undefined,datatype=float8,storage=rectangular,order=C_order
type( a, 'hfarray' );
type( a, 'array' );
Objects that are of type integer, fraction, float, or string are said to be of type literal. Type literal is now a valid Maple type.
type( "a short string", 'literal' );
type( 1/5, 'literal' );
type( M[2,3], 'literal' );
An integer that is not positive, nonposint, is a new Maple type introduced in this release.
type( 2, 'nonposint' );
type( 0, 'nonposint' );
type( -1, 'nonposint' );
type( -2/3, 'nonposint' );
type( -infinity, 'nonposint' );
type( infinity, 'nonposint' );
procedure -- check for a procedure
range -- check for a range
A new type constructor, Range, allows you to construct a "type" that determines whether an object lies in a specified numeric range.
type( 2, 'Range( 1, 3 )' );
type( 5, 'Range( 1, 3 )' );
A number that is algebraic and is expressed as a Maple radical or using RootOf notation is of type radalgnum.
map( type, [ 2/7, evalf( Pi ), RootOf( x^2 + 1 ), RootOf( z^2 - x, z ) ], 'radalgnum' );
true,false,true,false
You can test whether an expression is a radical algebraic function of its indeterminates, or of a specified set of indeterminates, using a type test against the type radalgfun.
The hyperbolic functions have been ascribed the Maple type trigh. The hyperbolic functions are sinh, cosh, tanh, sech, csch and coth.
type( sin( x ), 'trigh' );
type( tanh( x ), 'trigh' );
type( arcsech( coth( x ) ), 'trigh' );
Use the new Maple type symbol to test whether an object is a symbol. A symbol is a name that is not of type indexed
There are several new types associated with the new Ore_algebra and Groebner packages: OreAlgebra, ClosedIdeal, CommAlgebra, ShortTermOrder, SkewParamAlgebra, SkewAlgebra, SkewPolynomial, TermOrder. Please see the corresponding help pages, and Ore Algebra example worksheets for further information.
Debugging
Parser generated warnings now have line numbers.
Tracing of builtin functions is now fully implemented.
The tracelast command now gives line numbers (in a format that you can cut and paste to the stopat command).
The tracelast command will tell you where a computation was interrupted by the user.
New options for stoperror:
stoperror(interrupted); ,
stoperror("time expired"); ,
stoperror("assertion failed"); ,
stoperror(all); ,
stoperror("invalid argument"); .
Setting interface(warnlevel = 4) warns about lexically scoped variables.
The debugger has a where function that shows the call stack of a stopped procedure.
There is a new WARNING function that users can use to issue warnings in their own procedures.
f := proc(x::integer) if x < 0 then WARNING( sprintf( "negative argument passed to %s", procname ) ); fi; 2*x; end:
f(1);
f(0);
0
f(-2);
Warning, negative argument passed to f
−4
The new kernelopts(dagtag) option maps between internal data structure IDs and their names.
kernelopts( dagtag = PROC );
32
kernelopts( dagtag = 1 );
INTNEG
seq( kernelopts( dagtag = i ), i = 1..46 );
INTNEG,INTPOS,RATIONAL,FLOAT,STRING,NAME,TABLEREF,DCOLON,CATENATE,POWER,PROD,SERIES,SUM,FUNCTION,UNEVAL,EQUATION,INEQUAT,LESSEQ,LESSTHAN,AND,NOT,OR,EXPSEQ,LIST,LOCAL,PARAM,LEXICAL,PROC,RANGE,SET,TABLE,HFARRAY,ASSIGN,FOR,IF,READ,SAVE,STATSEQ,STOP,HASH,HASHTAB,GARBAGE,FOREIGN,CONTROL,PROMPT,DEBUG
A detailed account of the storage being used by objects of different types can be obtained using kernelopts(memusage).
The directory separator, as a string, used on the particular platform that Maple is running on, can be queried using kernelopts(dirsep).
The limits on cpu time, data and stack sizes that can be set through the command line can now be queried using kernelopts(cpulimit), kernelopts(datalimit), and kernelopts(stacklimit) respectively.
User Interface
The new interface(errorcursor) controls how errors are indicated in the TTY version of Maple
The new interface(autoassign) variable controls whether the context-sensitive menus automatically generate an assignment for the results of a menu operation, and what variable name it uses if this feature is used.
Command completion has been reenabled (see editing, and the lib/cmds file).
Maple quits on reaching end of file. Use the -F option to recover the old behavior, which allows you to continue interactively after the end of the input file has been reached.
Input files can now be specified as command line arguments of the maple command. It is no longer necessary to write maple < file, using shell redirection. (See the man page.)
The help system in the TTY version now returns near-matches if an exact match was not found.
?evalfh
No exact matches found, please try one of the following:
eval
evala
evalapply
evalb
evalc
evalf
evalfint
evalgf
evalhf
evalm
evaln
evalr
evalrC
>
An alternate initialization file may be specified on the command line, using the new -i option.
For example, if you use the Korn shell, you can use the alias alias maplev5="maplev5 -i $HOME/.maplev5.init" to ensure that your new version of Maple uses the correct initialization file.
Performance
Karatsuba's algorithm is used for multiplying large integers.
Use of hardware floating point arrays (hfarrays) improves performance dramatically in some areas (such as plotting).
Profiling of the kernel has been done, and significant performance improvements were implemented as a result of finding some bottlenecks.
Download Help Document