Skip to content

An exponential times a trigonometric at the same frequency no longer divides by zero, and a phase is expanded - #1472

Merged
Rafael-SOWNet merged 1 commit into
masterfrom
imaginary-tangent-and-resonance
Sep 22, 2026
Merged

Rafael-SOWNet merged 1 commit into
masterfrom
imaginary-tangent-and-resonance

Conversation

@Rafael-SOWNet

Copy link
Copy Markdown
Member

x e^(-i x) cos(x) was answered NaN at 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 resonance a = ±i b, where the product is a sum of two exponentials and the denominator vanishes. Both places that use it asked whether a² + b² evaluates to a number — and with a symbolic frequency it does not: (-i f)² + f² is -f² + f², which InnerSimplified does not collect. So the guard passed, the formula divided by a zero it could not see, and the answer was NaN. Both now test the resonance symbolically (IsZeroOnceSimplified, which sat directly above one of them).

On that footing, two capabilities:

  • A phase is expanded. cos(f x + p) becomes cos(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, and sin(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), and A + i A cot(z) is 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 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):

  • Family 4 (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 carry i and the harness samples the real line; each was verified separately as a complex function).
  • Family 6: 377/417, 0 wrong, unchanged. 1774-problem suite: 1707, 0 wrong, 0 timeout, unchanged.
  • Unit suite: 12,641 tests, 0 failed. bench.sh: PASSED on all 19 gated benchmarks.
  • Twelve integrands verified by differentiating the answer and comparing against the integrand as complex numbers at five points — worst relative deviation 0 on every one, including x e^(2x) cos(3x + 1) and x² e^x sin(x + 2), which the phase expansion is for.

BREAKING-CHANGES.md carries the entry with the 2.5.0 column measured on a 2.5.0 build, and names the NaN as what master answered between the releases.

Part of #718.

🤖 Generated with Claude Code

https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura

…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
@Rafael-SOWNet
Rafael-SOWNet merged commit b13dbf4 into master Sep 22, 2026
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant