Symbolic Math Toolbox    

Procedure Example

The following example shows how you can access a Maple procedure through the Extended Symbolic Math Toolbox. The example computes either symbolic or variable-precision numeric approximations to , using a method derived by Richard Brent based from the arithmetic-geometric mean algorithm of Gauss. Here is the Maple source code:

Assume the source code for this Maple procedure is stored in the file pie.src. Using the Extended Symbolic Math Toolbox, the MATLAB statement

reads the specified file, deletes comments and newline characters, and sends the resulting string to Maple. (The MATLAB ans variable then contains a string representation of the pie.src file.)

You can use the pie function, using the maple function. The statement

returns a string representing the solution that begins and ends with

You can use the SYM command to convert the string to a symbolic object. It is interesting to change the computation from symbolic to numeric. The assignment to the variable b in the second executable line is key. If the assignment statement is simply

the entire computation is done symbolically. But if the assignment statement is modified to include decimal points

the entire computation uses variable-precision arithmetic at the current setting of digits. If this change is made, then

produces a 100-digit result:

The last 16 digits differ from those of because, with five iterations, the algorithm gives only 84 digits.

Note that you can define your own MATLAB M-file that accesses a Maple procedure:


  Packages of Library Functions Precompiled Maple Procedures