Sympy provide rewrite function to rewrite expression in terms of other functions.
Rewrites expression containing applications of functions
of one kind in terms of functions of different kind. For
example you can rewrite trigonometric functions as complex
exponentials or combinatorial functions as gamma function.
This function can do something like following:
In [8]: atan(x).rewrite(asin)
Out[8]: (-asin(1/sqrt(x**2 + 1)) + pi/2)*sqrt(x**2)/x
In [9]: atan(x).rewrite(asec)
Out[9]: sqrt(x**2)*asec(sqrt(x**2 + 1))/x
For trigonometric function, here is a related question: How to express trigonometric equation in terms of of given trigonometric function?
P.S.: Sympy actually writing these rewrite rules into the definition of the function.
SimplifyorFullSimplifywith a customizedComplexityFunction. These surely know the rules you are interested in, but applying them in the desired fashion can be a bit tricky at times.FunctionExpand,ExpToTrig/TrigToExp,ComplexExpandcan be useful in this to get a reasonable starting point offering many possibilities for simplification in the desired way. – Oleksandr R. May 29 '15 at 03:19SimplifywithComplexityFunctioncan do this kind of job automatically. For exampleFullSimplify[TrigToExp@ArcTan[x], ComplexityFunction -> (LeafCount[#] + 100 Count[#, _ArcTan, Infinity] &)]returnsArcTan[x]as well. – Kattern May 29 '15 at 03:30TrigToExp[], and "combinatorial functions as gamma functions" is done byFunctionExpand[]. – J. M.'s missing motivation May 29 '15 at 03:32Gammais also tricky.Assuming[n \[Element] Integers && n > 1, FullSimplify[Gamma[n], ComplexityFunction -> (LeafCount[#] + 100 Count[#, _Gamma, Infinity] &)]]returnsGamma[n]. Same code forGamma[n + 1]returnsn!. Here is a related question. – Kattern May 29 '15 at 04:01FullSimplify[]; not so much withFunctionExpand[]. – J. M.'s missing motivation May 29 '15 at 04:27