Skip to content

Commit ecab3f7

Browse files
An odd half power of a quadratic with i in it is reduced as one without (#1805)
The reduction of a polynomial times an odd half power of a quadratic to R Q^(k + 1/2) + K/sqrt(Q) declined any coefficient off the real line, so sqrt(3 i x + 4 x^2) was answered and (3 i x + 4 x^2)^(5/2) was not. The solve is exact whatever the coefficients are, the table answers K/sqrt(Q) off the real line as on it, and the answer is differentiated back at sampled points before it is returned; it reduces those coefficients too now. Rubi's 1.2.1.1. Part of #718. Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1 parent ba77f7a commit ecab3f7

3 files changed

Lines changed: 69 additions & 3 deletions

File tree

‎BREAKING-CHANGES.md‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,22 @@ brings the root of the product of the radicands with it, and those were answered
269269
| `"1/(sqrt(a + b*x) + sqrt(a + c*x))^3".ToEntity().Integrate("x")` | `integral(...)` | the same, with logarithms and arctangents |
270270
| `"x^3/(sqrt(a + b*x) + sqrt(a + c*x))^2".ToEntity().Integrate("x")` | `integral(...)` | the same; 10 s on the unreleased master, a tenth of one now |
271271

272+
### An odd half power of a quadratic with `i` in it is reduced as one without
273+
274+
**Answers where there were none.** `sqrt(3 i x + 4 x^2)` was answered and `(3 i x + 4 x^2)^(5/2)`
275+
declined: the reduction of a polynomial times an odd half power of a quadratic to
276+
`R Q^(k + 1/2) + K/sqrt(Q)`, one linear solve, declined any coefficient off the real line, though the solve
277+
is exact whatever the coefficients are, the table answers `K/sqrt(Q)` off the real line as on it, and the
278+
answer is differentiated back at sampled points before it is returned. It reduces those too now. Rubi's
279+
1.2.1.1
280+
([#718](https://github.com/asc-community/AngouriMath/issues/718)).
281+
282+
| Input | Was (2.5.0) | Now |
283+
|---|---|---|
284+
| `"(3*i*x + 4*x^2)^(5/2)".ToEntity().Integrate("x")` | `integral(...)` | a polynomial times the root, and a logarithm |
285+
| `"1/(3*i*x + 4*x^2)^(7/2)".ToEntity().Integrate("x")` | `integral(...)` | a polynomial over a power of the root |
286+
| `"(1 + i*x + x^2)^(3/2)".ToEntity().Integrate("x")` | `integral(...)` | a polynomial times the root, and a logarithm |
287+
272288
### A power of a linear plus a root whose square matches it is integrated in their sum
273289

274290
**Answers where there were none.** `(d + e x + f sqrt(Q))^n` with `e^2` the leading coefficient of

‎Sources/AngouriMath/Functions/Continuous/Integration/IndefiniteIntegralSolver.cs‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15986,9 +15986,6 @@ static Dictionary<EInteger, Entity> Scaled(Dictionary<EInteger, Entity> poly, En
1598615986
var degreeOfP = pRead.Count == 0 ? 0 : pRead.Keys.Max()!.ToInt32Unchecked();
1598715987
if (degreeOfP > 8 || m > 9 || m < -9)
1598815988
return null;
15989-
foreach (var coefficient in new[] { a, b, c, constant }.Concat(pRead.Values))
15990-
if (coefficient.Evaled is Number.Complex and not Number.Real)
15991-
return null;
1599215989

1599315990
// Each coefficient that is neither a number nor a symbol is named for the solve and
1599415991
// written back into what it gives. Carried through the elimination as written,
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
//
2+
// Copyright (c) 2019-2026 Angouri.
3+
// AngouriMath is licensed under MIT.
4+
// Details: https://github.com/asc-community/AngouriMath/blob/master/LICENSE.md.
5+
// Website: https://am.angouri.org.
6+
//
7+
8+
using System;
9+
using AngouriMath.Extensions;
10+
using Xunit;
11+
12+
namespace AngouriMath.Tests.Calculus
13+
{
14+
/// <summary>
15+
/// A polynomial times an odd half power of a quadratic with <c>i</c> among its coefficients:
16+
/// the reduction to <c>R Q^(k + 1/2) + K/sqrt(Q)</c> is one linear solve, exact whatever the
17+
/// coefficients are, and <c>K/sqrt(Q)</c> the table answers off the real line as on it, so
18+
/// <c>sqrt(3 i x + 4 x^2)</c> was answered and <c>(3 i x + 4 x^2)^(5/2)</c> declined. The
19+
/// integrands are complex for a real <c>x</c>, and compared as complex numbers.
20+
/// <a href="https://github.com/asc-community/AngouriMath/issues/718">#718</a>
21+
/// </summary>
22+
[Trait("Area", "Calculus")]
23+
public sealed class HalfOddPowerOfAQuadraticOffTheRealLineIntegralTest
24+
{
25+
[Theory]
26+
[InlineData("(3*i*x + 4*x^2)^(5/2)")]
27+
[InlineData("1/(3*i*x + 4*x^2)^(7/2)")]
28+
[InlineData("(1 + i*x + x^2)^(3/2)")]
29+
[InlineData("x*(1 + i*x + x^2)^(3/2)")]
30+
[InlineData("(a + i*b*x + x^2)^(3/2)")]
31+
public void IsReducedAsOnTheRealLine(string integrand)
32+
{
33+
var integral = integrand.ToEntity().Integrate("x");
34+
Assert.DoesNotContain("integral(", integral.Stringize());
35+
Entity Pinned(Entity e) => e.Substitute("a", 1.3).Substitute("b", 0.7);
36+
var derivative = Pinned(integral.Substitute("C", 0)).Differentiate("x");
37+
var original = Pinned(integrand.ToEntity());
38+
var compared = 0;
39+
foreach (var at in new[] { -1.7, -0.4, 0.3, 0.9, 2.2 })
40+
{
41+
var want = original.Substitute("x", at).EvalNumerical();
42+
var got = derivative.Substitute("x", at).EvalNumerical();
43+
if (want.IsNaN || got.IsNaN)
44+
continue;
45+
compared++;
46+
Assert.True(Math.Abs((double)(got - want).RealPart) + Math.Abs((double)(got - want).ImaginaryPart)
47+
< 1e-9 * Math.Max(1, Math.Abs((double)want.RealPart) + Math.Abs((double)want.ImaginaryPart)),
48+
$"d/dx of the antiderivative of {integrand} is {got} at x = {at}, where the integrand is {want}");
49+
}
50+
Assert.True(compared >= 4, $"only {compared} points could be compared for {integrand}");
51+
}
52+
}
53+
}

0 commit comments

Comments
 (0)