2014-01-19 21 views
2

有沒有人知道如何解決Symja中的一個簡單的不平等?如何用Symja解決不平等問題?

我嘗試這樣的:

EvalUtilities solver = new EvalUtilities(); 

myExpresion = "Solve[Less[{2*x + 4},{10}],{x}]"; 

IExpr result = solver.evaluate(myExpresion); 

但是,這是行不通的。如何解決一個簡單的不平等?

回答

1

您可以輸入這種不平等直接的:

package org.matheclipse.core.examples; 

import static org.matheclipse.core.expression.F.*; 

import org.matheclipse.core.eval.EvalUtilities; 
import org.matheclipse.core.interfaces.IAST; 
import org.matheclipse.core.interfaces.IExpr; 
import org.matheclipse.parser.client.SyntaxError; 
import org.matheclipse.parser.client.math.MathException; 

public class InEqualityExample { 
    public static void main(String[] args) { 
    try { 
     EvalUtilities util = new EvalUtilities(false, true); 
     IExpr result = util.evaluate("2*x + 4 < 10"); 
     // print: x < 3 
     System.out.println(result.toString()); 

     // Create an expression with F.* static methods: 
     IAST function = Less(Plus(Times(integer(2), x), integer(4)), integer(10)); 
     result = util.evaluate(function); 
     // print: x < 3 
     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(); 
    } 
    } 
} 
+0

我使用symja-2014-10-03.jar,我應該包括什麼都做此代碼的工作? –

+1

你還應該在你的類路徑中包含log4j-1.2.11.jar – axelclk