Skip to content

ExpToTrig ​

Rewrite every exponential in expr as circular or hyperbolic functions -- the inverse of TrigToExp. Provided by @enumeratio/analytic.

✓ checked against that system · ! checked, with disagreements (hover a chip)Wolfram LanguageExpToTrig!
ExpToTrig(expr)expr with each Exp rewritten via Euler's formula or its hyperbolic analogue.
Typed signatures
TypePackageApplies
(expression) -> expressionanalyticalways

Domain: Transformations

Details
  • Rewrites Exp(ix) to cos(x) + i·sin(x) and a real Exp(x) to cosh(x) + sinh(x) everywhere in the tree, then simplifies. A combination that cancels back down to a single Cosh/Sinh/Sin -- the Scope examples -- falls out of that simplification pass; there is no separate 'recognize this shape' rule.

Examples

Basic #

Euler's formula

live ↗
InExpToTrig(eix)\mathrm{ExpToTrig}(e^{i x})Outisin⁡(x)+cos⁡(x)i\sin(x)+\cos(x)

A real exponential splits into hyperbolic parts

live ↗
InExpToTrig(ex)\mathrm{ExpToTrig}(e^{x})Outsinh⁡(x)+cosh⁡(x)\sinh(x)+\cosh(x)
Scope #

Recognizes Cosh

live ↗
InExpToTrig(12(ex+e−x))\mathrm{ExpToTrig}(\frac{1}{2}(e^{x}+e^{-x}))Outcosh⁡(x)\cosh(x)

Recognizes Sin

live ↗
InExpToTrig(eix−e−(ix)2i)\mathrm{ExpToTrig}(\frac{e^{i x}-e^{-(i x)}}{2i})Outsin⁡(x)\sin(x)

Real exponentials with base 3 are not rewritten

live ↗
InExpToTrig(3x−3−x)\mathrm{ExpToTrig}(3^{x}-3^{-x})Out3x−3−x3^{x}-3^{-x}
live ↗
InExpToTrig((−1)57)\mathrm{ExpToTrig}((-1)^{\frac{5}{7}})Out−1-1
live ↗
InExpToTrig([eix=−1,−111])\mathrm{ExpToTrig}(\bigl\lbrack e^{i x}=-1, \sqrt[11]{-1}\bigr\rbrack)Out[isin⁡(x)+cos⁡(x)=−1,−1]\bigl\lbrack i\sin(x)+\cos(x)=-1, -1\bigr\rbrack

Real logs are unchanged too

live ↗
InExpToTrig(ln⁡(x+2)−ln⁡(2−x))\mathrm{ExpToTrig}(\ln(x+2)-\ln(2-x))Outln⁡(x+2)−ln⁡(2−x)\ln(x+2)-\ln(2-x)
live ↗
InExpToTrig(ex≤11∧3ix=7)\mathrm{ExpToTrig}(e^{x}≤11∧3^{i x}=7)Outsinh⁡(x)+cosh⁡(x)≤11∧3ix=7\sinh(x)+\cosh(x)≤11∧3^{i x}=7
live ↗
InExpToTrig(2ix)\mathrm{ExpToTrig}(2^{i x})Out2ix2^{i x}
live ↗
InExpToTrig(ln⁡(ix+1)−ln⁡(1−ix))\mathrm{ExpToTrig}(\ln(i x+1)-\ln(1-i x))Outln⁡(ix+1)−ln⁡(1−ix)\ln(i x+1)-\ln(1-i x)
Properties #

A root of unity stays symbolic

live ↗
InExpToTrig(−116)\mathrm{ExpToTrig}(\sqrt[16]{-1})Out−116\sqrt[16]{-1}
live ↗
InExpToTrig(eix=−1)\mathrm{ExpToTrig}(e^{i x}=-1)Outisin⁡(x)+cos⁡(x)=−1i\sin(x)+\cos(x)=-1
About
Examples13
Checked againstWolfram Language 6 agree7 differSymPy 5 agree5 differ1 unevaluated2 error
CrosswalkWolfram Language

Implementation

mappedsympypackages/oracle/src/mappings.ts

See also: ComplexExpand, TrigToExp