SubstFor[v, u, x] — u with the trig subexpression `v` replaced by `x` * (u is a function of v). Returns null when v isn't a handled trig target.
(v: Expression, u: Expression, ctx: Ctx)
| 3535 | const a = vc[0] ?? u.engine.Zero; |
| 3536 | const b = vc[1] ?? u.engine.Zero; |
| 3537 | const c = ac[0] ?? u.engine.Zero; |
| 3538 | const d = ac[1] ?? u.engine.Zero; |
| 3539 | if (!zeroQ(a.mul(d).sub(b.mul(c)))) return false; |
| 3540 | const bd = safeSimplify(b.div(d)); |
| 3541 | if (!(bd.isNumberLiteral && bd.isRational === true)) return false; |
| 3542 | const num = bd.numerator; |
| 3543 | return a.div(num).add(b.div(num).mul(u.engine.symbol(x))); |
| 3544 | } |
| 3545 | if (CALCULUS_FNS.has(u.operator)) return false; |
| 3546 | // recurse over operands, threading the argument state |
| 3547 | let w: FotState = v; |
| 3548 | for (const op of u.ops) { |
| 3549 | w = fotAux(op, w, x); |
| 3550 | if (w === false) return false; |
| 3551 | } |
| 3552 | return w; |
| 3553 | } |
| 3554 | |
| 3555 | /** FunctionOfTrig[u, x]: the common linear trig argument, or the False symbol. */ |
| 3556 | function functionOfTrig( |
| 3557 | ce: ComputeEngine, |
| 3558 | u: Expression, |
| 3559 | x: string |
| 3560 | ): Expression { |
| 3561 | const r = fotAux(activateTrig(ce, u), null, x); |
| 3562 | return r === null || r === false ? ce.symbol('False') : r; |
no test coverage detected