Why do I get extra floating point numbers in Maple T.A. ?

  • administrators

    Very often people find that they seem to get extra floating point numbers in their Maple T.A. expressions.

    \[ y = 2.0 x + \mathrm{e}^{2.0 x} \]

    The reason you have the problem is because the assignment(=) operation in Maple T.A has an implicit parse that converts all numbers to floating point if the expression contains unknown values such as x. It also converts know quantities like Pi to floating point.

    To get around this problem you can add additional quotes to an expression to effectively nullify the parse.

    As an illustration see what happens with the following two examples.

    $V1="Pi/2";       # gives Pi/2
    $V1str=$V1;       # gives a floating point
    $V2="2*x";        # gives 2*x
    $V2str=$V2;       # gives 2.0*(x)

    You often see this when using the switch statement to choose a random expression. Below are two switch statements - see how the first statement results in floating point numbers because Maple T.A. parses the expressions. In the second case the implicit parse effectively just removes the double quotes and returns the expected expressions.

    $expr1=switch(rint(2),sin(3*x),cos(3*x));  # gives sin(3.0*(x)) or cos(3.0*(x))
    $expr2=switch(rint(2),"sin(3*x)","cos(3*x)");  # gives sin(3*x) or cos(3*x)