This is by no means a reasoned explanation, but this works and should allow you to make progress in your work
ScriptEngine fScriptEngine = fScriptManager.getEngineByExtension("m");
try {
String evaledResult = (String) fScriptEngine.eval("D[x^2,x]");
System.out.println(evaledResult);
} catch (Exception e) {
e.printStackTrace();
}
Result: 2*x
The documentation for this API is pretty weak. I had to read through their JUnit tests to put this together...
The expression I used also works with EvalUtils
, though it returns a slightly different result.
Result: Times[2, x]