Skip to content

Integrate of c·sinᵐ(u)·cosⁿ(u) for a linear u and integers m, n integrates by the odd-power substitution and the even-even reduction formulas, as it does the secant and tangent powers - #579

Open
enumeratio wants to merge 1 commit into
cortex-js:mainfrom
enumeratio:trig-power-integrals

Conversation

@enumeratio

Copy link
Copy Markdown
Contributor

∫ sin³x dx is cos³x/3 − cos x, ∫ sin³x cos²x dx is cos⁵x/5 − cos³x/3, ∫ sin⁴x dx is 3x/8 − 3/16·sin 2x − ¼·cos x·sin³x; they were Integrate. Fixes #578

Rules (symbolic/antiderivative.ts):

  • integrateSinCosPower(fn, index) reads the integrand as c·sinᵐ(u)·cosⁿ(u) (a constant factor, a Negate, a Divide by a constant, one linear argument u = a·x + b with a from linearIndexCoefficient, integer powers 1…SIN_COS_POWER_LIMIT = 40) and returns the primitive divided by a. For m = 2k + 1 it is −Σⱼ C(k, j)(−1)ʲ cosⁿ⁺²ʲ⁺¹u/(n + 2j + 1), for n = 2k + 1 it is Σⱼ C(k, j)(−1)ʲ sinᵐ⁺²ʲ⁺¹u/(m + 2j + 1) (sin² + cos² = 1).
  • sinCosEvenPower(u, m, n), both even and m + n ≥ 4 (sin², cos² stay the table's): A&S 4.3.127–4.3.128 as a loop, not a recursion, then ∫du = u.
  • It is tried in antiderivativeCandidate after the established antiderivative left an Integrate and before logarithmicPrimitive, so no result that already resolved changes (∫ sin x cos x, ∫ sin²x, ∫ sin x · cos x composites, the table entries).
  • A power above 40, a non-integer, complex, symbolic or negative power, an argument that is not linear (sin³(x²)) and different arguments in the two factors (sin³x·cos 2x) are not read, and the call stays as it was.

Definite integrals are unchanged (∫₀^π sin³x dx gave 4/3 already, by another route); the degree angular unit scales by 180/π through withRadianConvention. Not compiled (Integrate is not).

Wolfram agrees (its indefinite forms are multiple-angle spellings of the same functions up to a constant).

Tests: test/compute-engine/trig-power-integrals.test.ts (new): seven exact primitives by string (sin³, cos³, sin³cos², sin²cos³, sin³cos³, 3 sin³(2x + 1), cos³/2); for sixteen (m, n, u) (odd, even and mixed, u = x, 2x + 1, 3x, x − 1) the derivative of the result equals the integrand at three points (central difference, 1e-6); definite values (4/3, 3π/16, π/8) under evaluate() and .N() (sin³ was already 4/3); degree mode; and six shapes that are not read and stay Integrate. No existing test changed; the 160-odd test files that name Integrate or \int together with Sin or Cos pass.

Overlap with the open PRs. None; it adds a function and one call in antiderivativeCandidate.
Open question: the even-even case adds a sin(2x) spelling through evaluate() of sin x cos x (∫sin⁴x prints with sin(2x) and cos x·sin³x); a primitive in the sin(kx) multiple-angle form (as Wolfram's) is also possible, and needs TrigReduce on the result.

…rates by the odd-power substitution and the even-even reduction formulas, as it does the secant and tangent powers; add regression tests. Fix cortex-js#578
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Integrate of sin³x, cos⁵x, sin⁴x and sinᵐx·cosⁿx is left unevaluated

1 participant