-
Hello, ExprEvaluator util = new ExprEvaluator();
util.defineVariable("F1", 10);
util.defineVariable("F2", 20);
IExpr exp = util.evaluate("(F1+F2)*0.2"); |
Beta Was this translation helpful? Give feedback.
Answered by
axkr
Oct 4, 2021
Replies: 1 comment 4 replies
-
Don't know, if I understand exactly, but the 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 GithubIssue294 {
public static void main(String[] args) {
try {
ExprEvaluator util = new ExprEvaluator();
IExpr f1 = util.eval("f1=10");
// print: 10
System.out.println(f1.toString());
IExpr f2 = util.eval("f2=20");
// print: 20
System.out.println(f2.toString());
IExpr result = util.eval("(f1+f2)*0.2");
// print: 6.0
System.out.println(result.toString());
IExpr exp = util.eval("Solve(f3==(x+f2)*0.2,x)");
// print: {{x->-20.0+5.0*f3}}
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.
4 replies
Answer selected by
axkr
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Don't know, if I understand exactly, but the
Solve
function can probably be used: