TrigToExp¶
Status: Stable
documented, exercised by the test suite and/or worked examples, with no known limitations recorded.
Description¶
TrigToExp[expr]
rewrites circular and hyperbolic trigonometric functions (and their inverses) in expr in terms of exponentials and logarithms.
Examples (8)¶
Every input below was run against the current Mathilda build and its output recorded.
Basic examples (3)¶
In[1]:= TrigToExp[Cos[x]]
Out[1]= 1/2 E^(-I x) + 1/2 E^(I x)
In[2]:= TrigToExp[ArcSin[x]]
Out[2]= -I Log[I x + Sqrt[1 - x^2]]
In[3]:= TrigToExp[{Sin[x], Cos[x], Tan[x]}]
Out[3]= {(-1/2*I) E^(I x) + (1/2*I) E^(-I x), 1/2 E^(-I x) + 1/2 E^(I x), -(I E^(I x))/(E^(-I x) + E^(I x)) + (I E^(-I x))/(E^(-I x) + E^(I x))}
Applications (5)¶
In[4]:= TrigToExp[Sin[x]]
Out[4]= (-1/2*I) E^(I x) + (1/2*I) E^(-I x)
In[5]:= TrigToExp[Cos[x]]
Out[5]= 1/2 E^(-I x) + 1/2 E^(I x)
In[6]:= TrigToExp[Cosh[x]]
Out[6]= 1/2 E^x + 1/2 E^(-x)
In[7]:= TrigToExp[ArcTan[x]]
Out[7]= (-1/2*I) Log[1 + I x] + (1/2*I) Log[1 - I x]
In[8]:= TrigToExp[ArcSin[x]]
Out[8]= -I Log[I x + Sqrt[1 - x^2]]
Implementation notes¶
Algorithm. builtin_trigtoexp rewrites circular, hyperbolic, and their
inverse functions into complex-exponential / logarithmic form. It applies the
trig_to_exp_rules rule list (a ReplaceAll) — e.g. Sin[x] :> I/2 E^(-I x) -
I/2 E^(I x), Cos[x] :> (E^(-I x) + E^(I x))/2, Tan/Cot/Sec/Csc,
the Sinh/Cosh/Tanh/... hyperbolic analogues, and the ArcSin :> -I Log[...]
family of inverse identities — then runs Expand to distribute the result into
a flat sum. The Times/Power-level trig canonicalizer is suppressed for the
duration (trig_canon_suppress_inc/dec) so the intermediate Sin/Cos forms
are not prematurely re-collapsed back to Tan etc. before the rule fires.
Data structures. The rules are a single parse_expression'd List of
RuleDelayeds, built once in trigsimp_init and stored in the static
trig_to_exp_rules. Results are memoized through the active FactorMemo
(keyed under a TrigToExp[arg] head) so repeated Simplify candidate-set calls
on identical subexpressions hit the cache instead of re-running ReplaceAll +
Expand, which costs 30–130 ms on Tan-rich inputs.
Listable,Protected.- Operates on both circular and hyperbolic functions, and their inverses.
- Rewrites recursively, including trig heads nested inside the argument of an
outer trig head — e.g.
TrigToExp[Sin[Cos[x]]]exponentializes the innerCos[x]as well, matching Wolfram Language semantics. - Automatically threads over lists, equations, inequalities, and logic functions.
Attributes: Listable, Protected.
References¶
- Source:
src/simp/trigsimp.c - Specification:
docs/spec/builtins/elementary-functions.md - Tests:
tests/test_cherry_ei.c - Tests:
tests/test_dsolve.c - Tests:
tests/test_simp.c - Tests:
tests/test_trigexpand.c