MCPcopy Create free account
hub / github.com/cortex-js/compute-engine / substFor3

Function substFor3

src/compute-engine/rubi/rubi-utils.ts:3537–3559  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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. */
3556function 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;

Callers 1

rubi-utils.tsFile · 0.85

Calls 10

substTrigNodeFunction · 0.85
selectFactorsFunction · 0.85
substForTrigFunction · 0.85
symbolMethod · 0.65
isSameMethod · 0.65
functionMethod · 0.65
subMethod · 0.65
powMethod · 0.65
addMethod · 0.65
divMethod · 0.65

Tested by

no test coverage detected