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

Function expandPolyOverLinear

src/compute-engine/rubi/rubi-utils.ts:4264–4330  ·  view source on GitHub ↗
(u: Expression, ctx: Ctx)

Source from the content-addressed store, hash-verified

4262 * integer powers of sums, then each additive term is reduced. A term that
4263 * cannot be reduced (unexpected shape) is kept verbatim — a safe no-op.
4264 * Exported for the rubi-utils unit test (the reduction is an exact identity). */
4265export function circularTrigReduce(
4266 ce: ComputeEngine,
4267 u: Expression
4268): Expression {
4269 const expanded = deepExpand(ce, u);
4270 const terms =
4271 expanded.operator === 'Add' && expanded.ops ? expanded.ops : [expanded];
4272 const out: Expression[] = [];
4273 for (const t of terms) {
4274 const atoms = reduceTrigTerm(ce, t);
4275 out.push(atoms === null ? t : atomsToExpr(ce, atoms));
4276 }
4277 if (out.length === 0) return ce.Zero;
4278 if (out.length === 1) return out[0];
4279 return ce.function('Add', out);
4280}
4281
4282/** ExpandTrigReduce[u,x] (2-arg) — product/power reduction of u. Circular
4283 * Sin/Cos reduce to a real multiple-angle sum (`circularTrigReduce`);
4284 * Sinh/Cosh route through the exponential expansion (see the section
4285 * comment). Returns a sum the linearity prelude integrates termwise. */
4286function expandTrigReduce(ce: ComputeEngine, u: Expression): Expression {
4287 if (containsCircularSinCos(u)) return circularTrigReduce(ce, u);
4288 return deepExpand(ce, hyperbolicToExp(ce, u));
4289}
4290
4291/** Driver Chapter-6 fallback: rewrite a hyperbolic integrand to exponential
4292 * form and expand it into a sum, so the bundled Chapter-2 exponential rules
4293 * close each term. Used only when no Rubi rule closed the integrand — Rubi's
4294 * bare `(a+b·Sinh[linear])^n` / `(c+d·x)^m·Sinh^n` recurrences live in shared
4295 * machinery that is not a standalone corpus rule, so this self-contained
4296 * reducer keeps those linear-argument families integrable. The antiderivative
4297 * is exponential-form but numerically identical to Rubi's hyperbolic form. */
4298export function expandHyperbolicToExp(
4299 ce: ComputeEngine,
4300 u: Expression
4301): Expression {
4302 return deepExpand(ce, hyperbolicToExp(ce, u));
4303}
4304
4305// ---------------------------------------------------------------------------
4306// Trig → exponential fallback for NONLINEAR-argument sin/cos (4.1.11 / 4.1.12).
4307//
4308// The direct analog of the Chapter-6 hyperbolic→exp fallback. Rubi's
4309// nonlinear-argument sine rules (4.1.12 #5/#15 `∫Sin[c+d·xⁿ] → I/2·∫E^… − …`,
4310// #29 the t=xⁿ substitution) route `∫xᵐ·sin(a+b·xⁿ)` to `∫xᵐ·E^(k·xⁿ)`, closed
4311// by the bundled Chapter-2 incomplete-Γ kernel — exactly like the hyperbolic
4312// `Sinh[a+b·xⁿ]` cases. CE's structural matcher does not bind those Subst /
4313// linear-inner-match rules (the `(e+f·x)ⁿ` base defaulting to `xⁿ` and the
4314// `Simplify[(m+1)/n]` exponent are Mathematica-simplifier dependent), so this
4315// self-contained reducer supplies the same capability: rewrite sin/cos → E^(±i·w)
4316// and expand, so every term is `coef·xᵏ·E^(k·xⁿ)`.
4317//
4318// Gated (`sinCosArgNonlinearExpandableQ`) to fire ONLY when a sin/cos of a
4319// NONLINEAR monomial argument (`c + d·xᵏ`, k≠1 — incl. k<0 for sin(a+b/x)) is
4320// present and EVERY x-dependent sin/cos argument is such a monomial. Linear-
4321// argument sin/cos is left to the sine chapter (it never reaches this fallback —

Callers 1

rubi-utils.tsFile · 0.85

Calls 15

toTimesPowerFunction · 0.90
isNumberFunction · 0.90
expandFunction · 0.90
polyDegreeXFunction · 0.85
realNumFunction · 0.85
expandPartialFractionsFunction · 0.85
failFunction · 0.85
powOrOneFunction · 0.85
polyDivideXFunction · 0.85
hasMethod · 0.65
functionMethod · 0.65
isSameMethod · 0.65

Tested by

no test coverage detected