@Override public SymbolNode createSymbol(final String symbolName) { return createSymbol(symbolName, ""); }
/** * * @param node * @param var * @return */ public ASTNode derivative(final ASTNode node, String var) { SymbolNode sym = fASTFactory.createSymbol(var); return derivative(node, sym); }
private ASTNode getDerivativeResult(ASTNode arg1Derived, FunctionNode fun) { if (!arg1Derived.equals(new DoubleNode(1.0))) { FunctionNode res = new FunctionNode(fASTFactory.createSymbol("Times")); res.add(arg1Derived); res.add(fun); return res; } return fun; }
ASTNode arg1Derived = derivative(f.getNode(1), var); if (isSymbol(head, "Exp")) { FunctionNode fun = new FunctionNode(fASTFactory.createSymbol("Exp")); fun.add(f.getNode(1)); return getDerivativeResult(arg1Derived, fun); FunctionNode fun = new FunctionNode(fASTFactory.createSymbol("Times")); fun.add(new DoubleNode(-1.0)); fun.add(new FunctionNode(fASTFactory.createSymbol("Cos"), f.getNode(1))); return getDerivativeResult(arg1Derived, fun); FunctionNode fun = new FunctionNode(fASTFactory.createSymbol("Cos")); fun.add(f.getNode(1)); return getDerivativeResult(arg1Derived, fun); FunctionNode exponent = fASTFactory.createFunction(fASTFactory.createSymbol("Plus"), new DoubleNode(-1.0), f.get(2)); FunctionNode fun = fASTFactory.createFunction(fASTFactory.createSymbol("Times"), f.get(2), fASTFactory.createFunction(fASTFactory.createSymbol("Power"), f.get(1), exponent)); return getDerivativeResult(arg1Derived, fun); FunctionNode fun = fASTFactory.createFunction(fASTFactory.createSymbol("Times"), fASTFactory.createFunction(fASTFactory.createSymbol("Log"), f.get(1)), f); return getDerivativeResult(arg2Derived, fun); FunctionNode plusResult = new FunctionNode(fASTFactory.createSymbol("Plus")); for (int i = 1; i < f.size(); i++) { FunctionNode timesResult = new FunctionNode(f.getNode(0));