Skip to content

Commit f18a7d2

Browse files
A radical of a hyperbolic function of a logarithm is integrated on both sides of zero (#1752)
1/csch(2 ln(x))^(1/2) was answered under t = ln(x), provided x > 0, and its derivative was not the integrand for 0 < x < 1, where the integrand is imaginary. It is ((x^2 - x^(-2))/2)^(1/2), real on both sides of zero, and is answered by folding the exponentials into powers of x before the substitution. A negative power in the base of a power that is not whole is written below the bar now, which the rules for a root read, and c/g^p with p not whole is asked as the same question rather than one level down, where the rules scoped to the question asked did not see it. A whole power keeps its level. Rubi's hyperbolic functions of a logarithm go from 114 to 117 of 125. Part of #718. Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura
1 parent 4dbe73a commit f18a7d2

4 files changed

Lines changed: 57 additions & 41 deletions

File tree

‎BREAKING-CHANGES.md‎

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -674,21 +674,25 @@ zero-discriminant arm, which gives the right answer.
674674
Each of these was checked by differentiating it back with the parameters pinned and comparing at
675675
four points. Nothing that already had an antiderivative changes.
676676

677-
### A radical function of whole powers of `x` written through its logarithm says where its answer holds
677+
### A radical function of whole powers of `x` written through its logarithm is integrated on both sides of zero
678678

679-
**Answers where there were none, each with the condition it holds under.** `1/csch(2 ln(x))^(1/2)`
680-
is `sqrt(sinh(2 ln(x)))`, which is `sqrt((x^2 - x^(-2))/2)` and real on both sides of zero; 2.5.0
681-
declined it. On the unreleased master it was integrated under `t = ln(x)`, where the rules take
682-
`e^t` to be positive, and the answer was right for a positive `x` and wrong for every negative one.
683-
Such an answer is given `provided x > 0` now, and `provided c x^n > 0` for a logarithm of `c x^n`
684-
([#718](https://github.com/asc-community/AngouriMath/issues/718)).
679+
**Answers where there were none.** `1/csch(2 ln(x))^(1/2)` is `sqrt(sinh(2 ln(x)))`, which is
680+
`sqrt((x^2 - x^(-2))/2)` and real on both sides of zero; 2.5.0 declined it. Its exponentials are
681+
folded into powers of `x`, a negative one under a root written below the bar, and the answer is in those, on
682+
both sides of zero and on both sides of 1, where `sinh(2 ln(x))` changes sign. Under `t = ln(x)`,
683+
where the rules take `e^t` to be positive, an answer of this kind is given `provided x > 0`, and
684+
`provided c x^n > 0` for a logarithm of `c x^n`. A constant over a power that is not whole, `1/g^p`,
685+
is asked as `g^(-p)` at the depth it was asked at, so that the rules scoped to the question asked see
686+
it, which is how `1/csch(2 ln(x))^(1/2)` reaches the fold, and `1/sqrt(x + x^(3/2))` is answered on
687+
both sides of zero as well ([#718](https://github.com/asc-community/AngouriMath/issues/718)).
685688

686689
| Input | Was (2.5.0) | Now |
687690
|---|---|---|
688-
| `"1/csch(2*ln(x))^(1/2)".ToEntity().Integrate("x")` | `integral(...)` | an antiderivative, `provided x > 0` |
689-
| `"csch(2*ln(x))^(-3/2)".ToEntity().Integrate("x")` | `integral(...)` | an antiderivative, `provided x > 0` |
690-
| `"1/csch(2*ln(c*x))^(1/2)".ToEntity().Integrate("x")` | `integral(...)` | an antiderivative, `provided c x > 0` |
691-
| `"1/sech(2*ln(x))^(1/2)".ToEntity().Integrate("x")` | `integral(...)` | an antiderivative, `provided x > 0` |
691+
| `"1/csch(2*ln(x))^(1/2)".ToEntity().Integrate("x")` | `integral(...)` | an antiderivative on both sides of zero |
692+
| `"csch(2*ln(x))^(-3/2)".ToEntity().Integrate("x")` | `integral(...)` | an antiderivative on both sides of zero |
693+
| `"1/csch(2*ln(c*x))^(1/2)".ToEntity().Integrate("x")` | `integral(...)` | an antiderivative on both sides of zero |
694+
| `"1/sech(2*ln(x))^(1/2)".ToEntity().Integrate("x")` | `integral(...)` | an antiderivative on both sides of zero |
695+
| `"1/sqrt(x + x^(3/2))".ToEntity().Integrate("x")` | `integral(...)` | `4 sqrt(1 + sqrt(x))` times a factor constant where it is continuous, on both sides of zero |
692696

693697
### `e^(k acoth(a x))` beside a power of `c - a c x` is integrated
694698

@@ -1731,7 +1735,7 @@ was ([#718](https://github.com/asc-community/AngouriMath/issues/718)).
17311735
| Input | Was (2.5.0) | Now |
17321736
|---|---|---|
17331737
| `"x * sqrt(c - a*c*x) / e^(3 * atanh(a*x))".Integrate("x")` | `integral(…)` — left unevaluated, with `e` evaluated to a hundred digits inside it | an antiderivative in `sqrt(c - a c x)`, `provided c - a * c * x >= 0` |
1734-
| `"1/sqrt(x + x^(3/2))".Integrate("x")` | `integral(1 / sqrt(x + x ^ (3/2)), x)` — left unevaluated | `2 * sqrt(1 + sqrt(x)) / (1/2) + C provided x >= 0` |
1738+
| `"sqrt(x)/sqrt(x + x^2)".Integrate("x")` | `integral(...)` — left unevaluated | `2 sqrt(x + 1)` times a factor constant where it is continuous, `provided x + 1 >= 0` |
17351739

17361740
### An answer that read the sign of an even root says where the root is real
17371741

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

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2173,9 +2173,17 @@ private static bool TryReadAsQuotient(Entity expr, out Entity numerator, out Ent
21732173
// The exponent negated as a number rather than as a tree: `-power` on the
21742174
// node `2` is `2 * (-1)`, and `sin(x)^(2 * (-1))` is a shape the closed rule
21752175
// for a power of the sine does not read, so `c/sin(x)^2` went to the
2176-
// half-angle substitution for what is `-c cot(x)`.
2176+
// half-angle substitution for what is `-c cot(x)`. And where the power is not
2177+
// whole asked as the same question, since `c/g^p` and `c g^(-p)` are one: a
2178+
// level down the rules scoped to the question asked, the ones for a root, did
2179+
// not see it, and `1/csch(2 ln(x))^(1/2)` reached the fold of its exponentials
2180+
// there and was declined, where asked at the top it is answered. A whole power
2181+
// keeps its level: asked as the same question, `(c + d x)/(a + a tanh(e + f x))^3`
2182+
// ran past the budget where it is answered in a second.
21772183
over is Entity.Powf(var @base, var power) ?
2178-
Integration.ComputeIndefiniteIntegral(MathS.Pow(@base, (-power).InnerSimplified), x, integrateByParts)?.Pipe(i => div * i) :
2184+
(power is Number.Rational and not Number.Integer
2185+
? Integration.ComputeAsTheSameQuestion(MathS.Pow(@base, (-power).InnerSimplified), x, integrateByParts)
2186+
: Integration.ComputeIndefiniteIntegral(MathS.Pow(@base, (-power).InnerSimplified), x, integrateByParts))?.Pipe(i => div * i) :
21792187
// A constant over a product is the reciprocal of the product, asked as the
21802188
// same question with the constant in front, and not the product to the
21812189
// power -1: `pe/(x (d + e x) sqrt(1 - c^2 x^2))` handed on as
@@ -16513,7 +16521,20 @@ node is Powf(Powf(var @base, var inner), var outer)
1651316521
var folded = FoldTheExponent(exponent, x);
1651416522
return folded ?? node;
1651516523
});
16516-
return folded == expr ? null : Integration.ComputeAsAQuestionOfItsOwn(folded, x, integrateByParts);
16524+
if (folded == expr)
16525+
return null;
16526+
// A radicand with its negative powers written below the bar, which is where the rules
16527+
// for a root read a denominator: `(1/((x^2 - x^(-2))/2))^(-3/2)` was declined where
16528+
// `(1/((x^2 - 1/x^2)/2))^(-3/2)` is answered. Only under a power that is not whole: a
16529+
// whole power of a sum is expanded, and the power rule reads its terms as `x^(-k)`,
16530+
// through which `sinh(a + b ln(c x^n))^4` is answered in a second and was searched for
16531+
// six with them below the bar.
16532+
folded = folded.Replace(node => node is Powf(var radicand, var exponent) && exponent.Evaled is not Number.Integer && radicand.ContainsNode(x)
16533+
? MathS.Pow(radicand.Replace(inside => inside is Powf(var @base, Number.Integer { EInteger: var power }) && power.Sign < 0 && @base.ContainsNode(x)
16534+
? Number.Integer.One / (power.Equals(EInteger.FromInt32(-1)) ? @base : MathS.Pow(@base, Number.Integer.Create(-power)))
16535+
: inside), exponent)
16536+
: node);
16537+
return Integration.ComputeAsAQuestionOfItsOwn(folded, x, integrateByParts);
1651716538
}
1651816539

1651916540
/// <summary>

‎Sources/Tests/UnitTests/Calculus/LinearRadicalSubstitutionIntegralTest.cs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ private static void DifferentiatesBack(string integrand)
7979

8080
/// <summary>
8181
/// That step reads <c>u</c> as a non-negative real, which it is only where the radical
82-
/// is real, and the answer says so: <c>1/sqrt(x + x^(3/2))</c> comes back
83-
/// <c>provided x &gt;= 0</c>. Beyond the radicand's zero <c>u</c> is imaginary, and the
82+
/// is real, and the answer says so: <c>sqrt(x)/sqrt(x + x^2)</c> comes back
83+
/// <c>provided x + 1 &gt;= 0</c>. Beyond the radicand's zero <c>u</c> is imaginary, and the
8484
/// integrand can still be real there -- Rubi's <c>x sqrt(c - a c x) / e^(3 atanh(a x))</c>
8585
/// above <c>a x = 1</c> is the product of two imaginary factors -- while the answer built
8686
/// for a real <c>u</c> is not its antiderivative: with <c>a = 3.1</c>, <c>c = 0.7</c> at
@@ -93,8 +93,8 @@ private static void DifferentiatesBack(string integrand)
9393
[Fact]
9494
public void TheEvenRootStepSaysWhereItHolds()
9595
{
96-
var conditioned = "1/sqrt(x + x^(3/2))".ToEntity().Integrate("x");
97-
Assert.Contains("provided x >= 0", conditioned.Stringize());
96+
var conditioned = "sqrt(x)/sqrt(x + x^2)".ToEntity().Integrate("x");
97+
Assert.Contains("provided x + 1 >= 0", conditioned.Stringize());
9898

9999
var integrand = "x * sqrt(c - a*c*x) / e^(3 * atanh(a*x))".ToEntity();
100100
var integral = integrand.Integrate("x");

‎Sources/Tests/UnitTests/Calculus/LogarithmSubstitutionTest.cs‎

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
//
77

88
using System;
9-
using System.Linq;
109
using AngouriMath.Extensions;
1110
using Xunit;
1211

@@ -121,38 +120,30 @@ public void ATrigonometricFunctionOfTheLogarithm(string integrand)
121120
/// <summary>
122121
/// A radical function of whole powers of <c>x</c> written through its logarithm, which is
123122
/// real on both sides of zero: <c>sinh(2 ln(x))</c> is <c>(x^2 - x^(-2))/2</c> for a
124-
/// negative <c>x</c> as well. Each answer is compared at three negative points and three
125-
/// positive ones, wherever it does not say it holds only elsewhere. Integrated under
126-
/// <c>t = ln(x)</c>, the first four say they hold where the logarithm's argument is
127-
/// positive; the last two are answered in powers of <c>x</c> and hold on both sides.
128-
/// Rubi's 6.5.3, 226, and 6.6.3, 188.
123+
/// negative <c>x</c> as well. Each answer is compared on both sides of zero and on both
124+
/// sides of 1, where <c>sinh(2 ln(x))</c> changes sign, and holds at every point: the
125+
/// exponentials of the logarithm are folded into powers of <c>x</c>, and the answer is in
126+
/// those. Rubi's 6.5.3, 226, and 6.6.3, 188.
129127
/// </summary>
130128
[Theory]
131-
[InlineData("1/csch(2*ln(x))^(1/2)", false)]
132-
[InlineData("csch(2*ln(x))^(-3/2)", false)]
133-
[InlineData("1/csch(2*ln(13/10*x))^(1/2)", false)]
134-
[InlineData("1/sech(2*ln(x))^(1/2)", false)]
135-
[InlineData("sqrt(sinh(2*ln(x)))", true)]
136-
[InlineData("sqrt(cosh(2*ln(13/10*x)))", true)]
137-
public void ARadicalFunctionOfAWholePowerOfX(string integrand, bool onBothSides)
129+
[InlineData("1/csch(2*ln(x))^(1/2)")]
130+
[InlineData("csch(2*ln(x))^(-3/2)")]
131+
[InlineData("1/csch(2*ln(13/10*x))^(1/2)")]
132+
[InlineData("1/sech(2*ln(x))^(1/2)")]
133+
[InlineData("sqrt(sinh(2*ln(x)))")]
134+
[InlineData("sqrt(cosh(2*ln(13/10*x)))")]
135+
public void ARadicalFunctionOfAWholePowerOfX(string integrand)
138136
{
139137
var integral = integrand.ToEntity().Integrate("x");
140138
Assert.DoesNotContain("integral(", integral.Stringize());
141139
var derivative = integral.Substitute("C", 0).Differentiate("x");
142140
var original = integrand.ToEntity();
143-
var conditions = integral.Nodes.OfType<Entity.Providedf>().Select(provided => provided.Predicate).ToList();
144-
foreach (var at in new[] { -2.7, -1.9, -1.3, 1.3, 1.9, 2.7 })
141+
foreach (var at in new[] { -2.7, -1.9, -1.3, -0.7, -0.4, 0.4, 0.7, 1.3, 1.9, 2.7 })
145142
{
146-
if (conditions.Any(condition => condition.Substitute("x", at).Evaled == Entity.Boolean.False))
147-
{
148-
Assert.False(onBothSides, $"the antiderivative of {integrand} says it does not hold at x = {at}");
149-
Assert.True(at < 0, $"the antiderivative of {integrand} says it does not hold at x = {at}");
150-
continue;
151-
}
152143
var got = derivative.Substitute("x", at).EvalNumerical();
153144
var want = original.Substitute("x", at).EvalNumerical();
154145
var difference = Math.Abs((double)(got - want).RealPart) + Math.Abs((double)(got - want).ImaginaryPart);
155-
Assert.True(difference / Math.Max(1.0, Math.Abs((double)want.RealPart)) < 1e-9,
146+
Assert.True(difference / Math.Max(1.0, Math.Abs((double)want.RealPart) + Math.Abs((double)want.ImaginaryPart)) < 1e-9,
156147
$"d/dx of the antiderivative of {integrand} is {got} at x = {at}, where the integrand is {want}");
157148
}
158149
}

0 commit comments

Comments
 (0)