Skip to content

ExpToTrig

Status: Stable

documented, exercised by the test suite and/or worked examples, with no known limitations recorded.

Description

ExpToTrig[expr]

rewrites exponentials and logarithms in expr in terms of circular and hyperbolic trigonometric functions when possible.

Examples (7)

Every input below was run against the current Mathilda build and its output recorded.

Basic examples (3)

In[1]:= ExpToTrig[Exp[I x]]
Out[1]= Cos[x] + I Sin[x]

In[2]:= ExpToTrig[Log[1 + I x] - Log[1 - I x]]
Out[2]= (2*I) ArcTan[x]

In[3]:= ExpToTrig[Exp[I x] == -1]
Out[3]= Cos[x] + I Sin[x] == -1

Applications (4)

In[4]:= ExpToTrig[Exp[x]]
Out[4]= Cosh[x] + Sinh[x]

In[5]:= ExpToTrig[Exp[I x]]
Out[5]= Cos[x] + I Sin[x]

In[6]:= ExpToTrig[(E^x - E^(-x))/2]
Out[6]= Sinh[x]

In[7]:= ExpToTrig[E^(I x) + E^(-I x)]
Out[7]= 2 Cos[x]

Implementation notes

Algorithm. builtin_exptotrig is the partial inverse of TrigToExp. It runs a four-stage pipeline on the argument: (1) ReplaceRepeated with exp_to_trig_rulesE^(I x) :> Cos[x] + I Sin[x], E^(-x) :> Cosh[x] - Sinh[x], E^x :> Cosh[x] + Sinh[x], plus Log-combination patterns that fold back to ArcTan/ArcTanh/ArcSin/ArcCsch/... ; (2) Together to combine over a common denominator; (3) Cancel to reduce the rational; (4) a final ReplaceRepeated with exp_to_trig_simp that recovers reciprocal heads (Sin/Cos :> Tan, Cos^-1 :> Sec, etc.). The trig canonicalizer is suppressed across the whole pipeline (trig_canon_suppress_inc/dec) so the intermediate Sin/Cos forms survive long enough for Together/Cancel to act.

Data structures. Three static rule lists (exp_to_trig_rules, exp_to_trig_simp, plus the shared trig_factor_* machinery) parsed once in trigsimp_init. Results are routed through the active FactorMemo by the public builtin_exptotrig wrapper path via trig_memo_call semantics shared with the other trig builtins.

  • Listable, Protected.
  • Tries when possible to give results that do not involve explicit complex numbers.
  • ExpToTrig is natively the inverse of TrigToExp.
  • Automatically threads over lists, equations, inequalities, and logic functions.

Attributes: Listable, Protected.

References

See also: TrigToExp

Notes & additional examples

Notes

ExpToTrig rewrites exponentials in terms of circular and hyperbolic functions: a real exponent yields Cosh + Sinh, an imaginary one yields Cos + I Sin. It recognises the classical combinations, folding the half-difference (E^x - E^(-x))/2 back to Sinh[x] and the sum E^(I x) + E^(-I x) to 2 Cos[x].