use of org.matheclipse.core.visit.VisitorReplaceAllDFS in project symja_android_library by axkr.
the class TrigToExp method evaluate.
/**
* Exponential definitions for trigonometric functions
*
* <p>
* See <a href=
* "http://en.wikipedia.org/wiki/List_of_trigonometric_identities#Exponential_definitions"> List
* of trigonometric identities - Exponential definitions</a>,<br>
* <a href="http://en.wikipedia.org/wiki/Hyperbolic_function">Hyperbolic function</a>
*/
@Override
public IExpr evaluate(final IAST ast, EvalEngine engine) {
IExpr temp = StructureFunctions.threadLogicEquationOperators(ast.arg1(), ast, 1);
if (temp.isPresent()) {
return temp;
}
IExpr arg1 = ast.arg1();
Function<IExpr, IExpr> fun = x -> {
IExpr t = x.rewrite(ID.Exp);
if (!t.isPresent()) {
return x.rewrite(ID.Log);
}
return t.rewrite(ID.Log).orElse(t);
};
VisitorReplaceAllDFS dfs = new VisitorReplaceAllDFS(fun, 1);
return arg1.accept(dfs).orElse(arg1);
}
Aggregations