An exponential times a trigonometric at the same frequency no longer divides by zero, and a phase is expanded - #1472
Merged
Conversation
…divides by zero, and a phase is expanded `x e^(-i x) cos(x)` was answered NaN at every point of its domain. The closed form `int e^(ax)(c cos(bx) + d sin(bx))` divides by `a^2 + b^2`, and both places that use it guard the resonance `a = ±i b` -- where the product is a sum of two exponentials -- by asking whether `a^2 + b^2` *evaluates* to a number. With a symbolic frequency it does not: `(-i f)^2 + f^2` is `-f^2 + f^2`, which `InnerSimplified` does not collect. The guard passed, the formula divided by a zero it could not see, and the answer was NaN -- a wrong answer, not a decline. Both now test the resonance symbolically. On that footing, two capabilities. A phase in the trigonometric's argument is expanded by the angle-sum identity where an exponential stands beside it, since the closed rule reads one frequency and no phase -- an exponential's own offset is a constant factor, a trigonometric's is not. And `A + i A tan(z)` below the bar is written as `A e^(i z)/cos(z)`, `A + i A cot(z)` as `i A e^(-i z)/sin(z)`, exactly, since `cos z + i sin z` is `e^(i z)`: beside a polynomial that is the shape the closed rule answers, where the imaginary unit in the coefficient is read by nothing else. Below the bar only -- above it the tangent's own rules answer in the tangent and more shortly, and the rewrite made one such row two and a half times slower before it was restricted. Family 4 of the Rubi suite: 284 -> 286 of 422, 0 wrong, and eight rows that produced nothing now produce answers; family 6 377/417 and the 1774-problem suite 1707 unchanged. Suite 12641 passed; allocation gate passed on all 19 gated benchmarks. Every new row verified as a complex function, the answer's derivative against the integrand at five points. Part of #718. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
x e^(-i x) cos(x)was answeredNaNat every point of its domain — a wrong answer, not a decline.The closed form
int e^(ax)(c cos(bx) + d sin(bx)) = e^(ax)(…)/(a² + b²)is guarded against the resonancea = ±i b, where the product is a sum of two exponentials and the denominator vanishes. Both places that use it asked whethera² + b²evaluates to a number — and with a symbolic frequency it does not:(-i f)² + f²is-f² + f², whichInnerSimplifieddoes not collect. So the guard passed, the formula divided by a zero it could not see, and the answer wasNaN. Both now test the resonance symbolically (IsZeroOnceSimplified, which sat directly above one of them).On that footing, two capabilities:
cos(f x + p)becomescos(p) cos(f x) - sin(p) sin(f x)where an exponential stands beside it, because the closed rule reads one frequency and no phase — an exponential's own offset is a constant factor, a trigonometric's is not, and the reader said so in a comment ("a phase would want the angle-sum identity first"). Only beside an exponential: the expansion doubles every sine and cosine it touches, andsin(a + b x)alone is better answered by the closed rule that takes it whole.A + i A tan(z)below the bar is an exponential.A e^(i z)/cos(z), andA + i A cot(z)isi A e^(-i z)/sin(z)— exactly, sincecos z + i sin zise^(i z). Beside a polynomial that is the shape above. Below the bar only: above it the tangent's own rules answer in the tangent and more shortly, and before that restriction(a + i a tan(c + d x))^3 (A + B tan(c + d x))/tan(c + d x)^(5/2)went from 1.6 s to 4.2 s.Measured (final build):
familycap.sh 4 6): 284 → 286/422, 0 wrong, and unevaluated 93 → 85 — eight rows that produced nothing now produce answers (several graded unverifiable on the reals, since the integrands carryiand the harness samples the real line; each was verified separately as a complex function).bench.sh: PASSED on all 19 gated benchmarks.x e^(2x) cos(3x + 1)andx² e^x sin(x + 2), which the phase expansion is for.BREAKING-CHANGES.mdcarries the entry with the 2.5.0 column measured on a 2.5.0 build, and names theNaNas whatmasteranswered between the releases.Part of #718.
🤖 Generated with Claude Code
https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura