Skip to content

Exponentials of quadratics beside sines, cosines and hyperbolic functions of quadratics are integrated onto the Gaussian - #1521

Merged
Rafael-SOWNet merged 2 commits into
masterfrom
exponentials-of-quadratics
Sep 27, 2026
Merged

Rafael-SOWNet merged 2 commits into
masterfrom
exponentials-of-quadratics

Conversation

@Rafael-SOWNet

Copy link
Copy Markdown
Member

Part of #1501.

A product of exponentials of polynomials of degree at most two, whole powers of sines, cosines and hyperbolic functions of such polynomials, and a polynomial is now integrated when some exponent is a quadratic. Each sine or cosine is written as exponentials, sin(q) = (e^(i q) - e^(-i q))/(2i). Multiplied out, the product is a sum of terms k P(x) e^(Q(x)), with Q of degree at most two. Where Q is a quadratic, a term is the Gaussian's moments, which #1512 and #1519 answer. Otherwise it is elementary. A hyperbolic function is already written as exponentials, so it needs no rewriting.

The answer for a real integrand with a sine or cosine in it is written with the imaginary unit, as Rubi's is:

e^(x^2) sin(x)  ->  -i/2 e^(1/4) sqrt(pi)/2 erfi(x + i/2) + i/2 e^(1/4) sqrt(pi)/2 erfi(x - i/2)

A sine or cosine is taken only beside an exponential. On its own, or beside a polynomial only, the sine of a quadratic is a Fresnel integral, which this does not write. And x sin(x^2) still gives -cos(x^2)/2, by the substitution, with no imaginary unit in it.

integral master this PR
f^(a + b x + c x^2) trig(d + e x + f x^2)^n, n = 1, 2, 3, every combination of linear and quadratic (Rubi's 4.7.6) unevaluated answered, with erf or erfi
the same with sinh or cosh (6.1.5, 6.2.5) unevaluated, 5 of them past 3 s answered
x^2 sinh(a + b x ± c x^2)^2, (d + e x)^2 sinh(a + b x + c x^2)^2 and their cosh twins (6.1.4, 6.2.4) past 3 s answered
e^(asin(a x)^2) x^m, after the integrator's own u = asin(a x) (5.1.5) unevaluated answered
f^(a + b x + c x^2) g^(d + e x + f x^2) (2.3) unevaluated answered
x sin(x^2), e^x sin(2x), e^(2x) cos(x)^2 answered, real the same answer

Exact cancellation

A term's exponent is kept as whole multiples of the exponents the integrand writes, not as their sum. So e^(i q) e^(-i q) is the multiple 0, decided in integers. The first version added the exponents, and InnerSimplified does not read i q + (-i) q as zero. The cross term of cos(q)^2 was then taken for a Gaussian with a zero square coefficient, and came back as NaN. For the same reason, a zero coefficient is never multiplied by ln(f): simplified, 0 ln(f) is 0 provided not f = 0, which does not test as zero either.

Not yet

x^2 sinh(a + b x^2)^3 and sinh(a + b x^2)^3/x^2 are still declined: a polynomial, or a power of x below the bar, beside a term whose exponent has no linear part. A follow-up takes both.

Cost

The rule is asked of every product the integrator meets. It first counts the factors by their written shape, which reads and allocates nothing. It declines there unless there is a sine beside an exponential, two exponentials, or a power of a sum.

Measured

  • Rubi's problems whose answer uses erf, erfc or erfi: 811 across families 0 to 7, at a 3 s budget. This PR solves 720, where master (22021b1c) solves 593, with 0 wrong and nothing lost. Timeouts go from 14 to 3, with none new. The total time goes from 574 s to 298 s, mostly the sections whose declines this answers. The 127 gained are 64 in 4.7.6, 24 in 6.1.5, 24 in 6.2.5, 8 in 5.1.5, 3 in 6.1.4, 3 in 6.2.4 and 1 in 2.3. That makes 4.7.6, 6.1.5, 6.2.5 and 5.1.5 complete: 64/64, 29/29, 29/29 and 8/8. The slowest problem gained now takes 1.1 s.
  • The textbook suites (family 0) are unchanged: 1723/1778, 0 wrong, 0 timeouts. The total goes from 82.0 s to 83.2 s, with no problem more than 153 ms slower.
  • The unit suite passes on net10.0: 12965 passed, 14 skipped, none failed, of 12979.
  • The allocation gate passes on all 19 gated benchmarks, with no allocation moved.

🤖 Generated with Claude Code

https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura

Rafael-SOWNet and others added 2 commits September 27, 2026 22:09
…ions of quadratics are integrated onto the Gaussian

A product of exponentials of polynomials of degree at most two, whole
powers of sines and cosines of such polynomials, whole powers of sums of
those exponentials (the hyperbolic functions) and a polynomial, where some
exponent is a quadratic: with each sine or cosine written as exponentials
of i times its argument and the product multiplied out, every term is
k P(x) e^(Q(x)) with Q of degree at most two, the Gaussian's moments where
Q is a quadratic and elementary where it is not. A term's exponent is kept
as whole multiples of the exponents the integrand writes, so that
e^(i q) e^(-i q) is decidably e^0. Rubi's 4.7.6, 6.1.5 and 6.2.5, 6.1.4's
x^2 sinh(a + b x + c x^2)^2, and 2.3's f^(q1) g^(q2).

Part of #1501.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura
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