-
When I encountered some problems in solving the calculation of fixed point numbers, such as the following scenario: ExprEvaluator util = new ExprEvaluator();
IExpr exp = util.eval("Solve(0==x*22337054158777049688231864282686423040-10270475816355389090971698343895989333566423039,x)");
//output {{x->3423491938785129696990566114631996444522141013/7445684719592349896077288094228807680}}
System.out.println(exp.toString()); i expect the x value is |
Beta Was this translation helpful? Give feedback.
Answered by
axkr
Oct 18, 2023
Replies: 1 comment 1 reply
-
You can use See:
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;
public class GithubIssue838 {
public static void main(String[] args) {
try {
ExprEvaluator util = new ExprEvaluator();
IExpr exp = util.eval(
"Solve(0==x*22337054158777049688231864282686423040-10270475816355389090971698343895989333566423039,x)");
// output
// {{x->3423491938785129696990566114631996444522141013/7445684719592349896077288094228807680}}
System.out.println(exp.toString());
exp = util.eval(
"NSolve(0==x*22337054158777049688231864282686423040-10270475816355389090971698343895989333566423039,x)");
// output
// {{x->4.597954476606639E8}}
System.out.println(exp.toString());
} catch (SyntaxError e) {
System.out.println(e.getMessage());
} catch (MathException me) {
System.out.println(me.getMessage());
} catch (Exception e) {
e.printStackTrace();
} catch (final StackOverflowError soe) {
System.out.println(soe.getMessage());
} catch (final OutOfMemoryError oome) {
System.out.println(oome.getMessage());
}
}
} |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
axkr
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can use
NSolve
to get the numeric result.See: