symja: quadratic inequation and modulus

106 views Asked by At
public static void solveInequalitiesEquationSymja(){
    EvalUtilities util = new EvalUtilities(false, true);
    IExpr result = util.evaluate("x^2<x");
    IExpr result2 = Solve(result,x);
    System.out.println("################## Inequalities equation ##################");
    System.out.println(result);
    System.out.println(result2);
}

result is x^2 < x

result2 is Solve(x^2< x,x)

public static void solveModuleEquationSymja() {
ExprEvaluator util = new ExprEvaluator();

Parser parser = new Parser();
ASTNode exprNode = parser.parse("Sqrt[x^2] == 7");
AST2Expr ast2Expr = new AST2Expr();
IExpr ast = ast2Expr.convert(exprNode);

IAST function = Solve(ast, x);
IExpr result = util.evaluate(function);

System.out.println("################## Module equation ##################");
System.out.println(result);

}

{{x->-7},{x->7}} Is there any solution not to use sqrt(x^2),but directly modulus(x) ?

Thank you in advance

1

There are 1 answers

0
axelclk On

At the moment inequalities aren't supported in Solve().

Did you mean something like "x^2==49"?

public static void solveModuleEquationSymja() {
    ExprEvaluator util = new ExprEvaluator();
    IExpr result = util.evaluate("Solve(x^2 == 49,x)");
    System.out.println("################## Module equation ##################");
    System.out.println(result);
}