(expr: Expression)
| 118 | // ============================================================================ |
| 119 | |
| 120 | export function TR2(expr: Expression): Expression | undefined { |
| 121 | const ce = expr.engine; |
| 122 | const op = expr.operator; |
| 123 | if (!isFunction(expr)) return undefined; |
| 124 | const arg = expr.op1; |
| 125 | |
| 126 | if (!arg) return undefined; |
| 127 | |
| 128 | if (op === 'Tan') { |
| 129 | // tan(x) -> sin(x)/cos(x) |
| 130 | return ce._fn('Sin', [arg]).div(ce._fn('Cos', [arg])); |
| 131 | } |
| 132 | |
| 133 | if (op === 'Cot') { |
| 134 | // cot(x) -> cos(x)/sin(x) |
| 135 | return ce._fn('Cos', [arg]).div(ce._fn('Sin', [arg])); |
| 136 | } |
| 137 | |
| 138 | return undefined; |
| 139 | } |
| 140 | |
| 141 | /** |
| 142 | * Apply TR2 to all subexpressions |
no test coverage detected