#119: Solve( (k*Q*q)/r^2==E, r) throws arithmetic exception: invalid exponent -2

Issue #119 resolved
Stanton Parham created an issue

I used your online demo applications and was able to use "solve( (kQq)/r^2==E, r )", but when I try to do the same thing in Java, the console tells me that I have an "invalid exponent -2".

import org.matheclipse.core.basic.Config;
import org.matheclipse.core.eval.ExprEvaluator;
import org.matheclipse.core.interfaces.IExpr;
import org.matheclipse.parser.client.SyntaxError;
import org.matheclipse.parser.client.math.MathException;

/**
 * A test for the Symja Library
 * 
 * @author Stanton Parham (stanton8parham8@gmail.com)
 */
public class TEST_SYMJA {
    public static void main(String[] args) {
        try {
            // don't distinguish between lower- and uppercase identifiers
            Config.PARSER_USE_LOWERCASE_SYMBOLS = true;

            ExprEvaluator util = new ExprEvaluator(false, 100);

            IExpr result = util.evaluate("Solve((k*Q*q)/r^2==E,r)");
            // print: r == Sqrt((k*Q*q)/E)
            System.out.println(result.toString());

        } catch (SyntaxError e) {
            // catch Symja parser errors here
            System.out.println(e.getMessage());
        } catch (MathException me) {
            // catch Symja math errors here
            System.out.println(me.getMessage());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

Comments (2)

  1. Log in to comment