Algebraic.toString - Maple Programming Help

Online Help

All Products    Maple    MapleSim

Home : Support : Online Help : Programming : OpenMaple : Java Application Programming Interface : Algebraic Class : OpenMaple/Java/Algebraic/toString


convert an Algebraic expression to a string


Calling Sequence



Calling Sequence

String toString() throws MapleException



The toString function returns a Java String representation of the Algebraic expression.


The format of the returned String is compatible with Maple syntax.  The string may be used as, or to form, an evaluatable statement.


Some care should be taken when using toString to form a statement.  The returned String does not protect the atomic nature of the Algebraic with parenthesis; therefore, the order of operations may cause unexpected results.


For example, evaluating the string "2*"+algeb.toString()+";" does not return twice the value of algeb.  In particular if algeb.toString() returns "x+y", then the string is "2*x+y;", which evaluates to 2x+y, not 2x+2y.


import com.maplesoft.openmaple.*;

import com.maplesoft.externalcall.MapleException;

class Example


    public static void main( String notused[] ) throws MapleException


        String mapleArgs[];

        Engine engine;

        Algebraic a1;

        mapleArgs = new String[1];

        mapleArgs[0] = "java";

        engine = new Engine( mapleArgs, new EngineCallBacksDefault(),

                null, null );

        a1 = engine.evaluate( "int( x^x, x ):" );

        System.out.println( "("+a1.toString()+")" );

        a1 = engine.evaluate( "\Maple likes strings\:" );

        System.out.println( "("+a1+")" );

        a1 = engine.evaluate( "Randpoly(10,x) mod 7:" );

        System.out.println( "("+a1+")" );



Executing this code should produce the following output.


("Maple likes strings")


See Also







Download Help Document

Was this information helpful?

Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam