(base: Expression, exp: Expression)
| 4330 | function trigToExp(ce: ComputeEngine, u: Expression): Expression { |
| 4331 | const ops = u.ops; |
| 4332 | if (ops?.length === 1 && (u.operator === 'sin' || u.operator === 'cos')) { |
| 4333 | const w = trigToExp(ce, ops[0]); |
| 4334 | const i = ce.I; |
| 4335 | const ewPos = ce.E.pow(i.mul(w)); // E^(i·w) |
| 4336 | const ewNeg = ce.E.pow(i.neg().mul(w)); // E^(−i·w) |
| 4337 | const half = ce.number([1, 2]); |
| 4338 | if (u.operator === 'cos') return half.mul(ewPos).add(half.mul(ewNeg)); |
| 4339 | // sin[w] = (E^(i·w) − E^(−i·w))/(2i) = −(i/2)E^(i·w) + (i/2)E^(−i·w) |
no test coverage detected