Skip to content

Commit 27b98dd

Browse files
acsch(c x) and asech(c x) are integrated with a symbolic c, and |c| differentiates to 0 in x (#1451)
x acsch(2 x) was answered and x acsch(c x) declined, for four reasons: (c x)^2 was read as a power of something that is not a polynomial where (2 x)^2 had been folded -- a whole power of a product with a symbolic constant beside the variable is written as the product of the powers, as a rule of its own; the root of (1 + c^2 x^2)/(c^2 x^2) was not written apart because c^2 is not a number -- a parameter's even power is taken for positive, the answer says so with provided c^2 > 0, and (c^2)^(-1/2) is written 1/|c|; the step by parts differentiated |c| to derivative(|c|, x) -- the modulus, the sign, the floor and their kin, and any node with no rule of its own, differentiate to 0 where they do not mention the variable; and q^(-1/2) above and sqrt(q) below were two atoms to the cancellation -- a negative fractional power goes below the bar where the same radicand also stands under a positive one. SolveAsPolynomialTerm gathers constants from any position among the factors once the two-operand reading has declined. Rubi's family 7: 162 -> 187 of 270, 0 wrong; the 1774 unchanged at 1706, 0 wrong, 0 timeout. Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent cd786d5 commit 27b98dd

7 files changed

Lines changed: 302 additions & 17 deletions

File tree

‎BREAKING-CHANGES.md‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -788,6 +788,34 @@ written
788788
| `"forall n in ZZ+ : n! >= 2^(n - 1)".ToEntity().Evaled` | `UnhandledParseException` | `True` |
789789
| `"forall n in ZZ+ /\\ [4; +oo) : n^2 - 2 n - 1 > 0".ToEntity().Evaled` | `UnhandledParseException` | `True` — decided about `4 + t` over `ZZ*` |
790790

791+
### `acsch(c x)` and `asech(c x)` are integrated with a symbolic `c`, and `|c|` differentiates to `0` in `x`
792+
793+
Three defects behind one symptom: `x acsch(2 x)` was answered and `x acsch(c x)` declined. The
794+
parser spells the inverse hyperbolic cosecant `ln(1/(c x) + sqrt(1/(c x)^2 + 1))`, and (1) `(c x)^2`
795+
was read as a power of something that is not a polynomial where `(2 x)^2` had been folded to
796+
`4 x^2` — a whole power of a product with a symbolic constant beside the variable is now written
797+
as the product of the powers, as a rule of its own; (2) the root of `(1 + c^2 x^2)/(c^2 x^2)` was
798+
not written apart as `sqrt(1 + c^2 x^2)/(|c| |x|)` because `c^2` is not a number — a parameter's
799+
even power is taken for positive now, and the answer says so, `provided c^2 > 0`, which holds
800+
exactly for a real non-zero `c`; (3) the step by parts differentiated `|c|` to
801+
`derivative(|c|, x)`, since the modulus rule asks whether its argument is real before it asks
802+
whether the argument mentions the variable — **the modulus, the sign, the floor, the ceiling,
803+
the rounding, a limit, a sum, a product, an applied function and any node with no rule of its
804+
own differentiate to `0` where they do not mention the variable**, with no condition, which also
805+
removes the `provided not c in ZZ` that `floor(c) + x` carried. A node with a rule of its own
806+
keeps it: `d/dy piecewise(x provided a, 1/x)` still says where `1/x` exists. And a negative fractional power is put below the bar before two
807+
quotients are cancelled as polynomials in their radicals, so that `q^(-1/2)` above and `sqrt(q)`
808+
below are one indeterminate. Rubi's 7.5.1 and 7.6.1
809+
([#718](https://github.com/asc-community/AngouriMath/issues/718)).
810+
811+
| Input | Was (2.5.0) | Now |
812+
|---|---|---|
813+
| `"abs(c) * x".ToEntity().Differentiate("x")` | `derivative(abs(c), x) * x + abs(c)` | `abs(c)` |
814+
| `"floor(c) + x".ToEntity().Differentiate("x")` | `1 provided not c in ZZ` | `1` |
815+
| `"c!".ToEntity().Differentiate("x")` | `derivative(c!, x)` | `0` |
816+
| `"x * acsch(c * x)".ToEntity().Integrate("x")` | `integral(x * ln(1 / (c * x) + sqrt(1 / (c * x) ^ 2 + 1)), x)` | an antiderivative, `provided c^2 > 0` |
817+
| `"x^2 * asech(c * x)".ToEntity().Integrate("x")` | `integral(...)`, the same | an antiderivative |
818+
| `"x / sqrt(1 + 1/(c*x)^2)".ToEntity().Integrate("x")` | `integral(x / sqrt(1 + 1 / (c * x) ^ 2), x)` | an antiderivative, `provided c^2 > 0` |
791819
### `n in ZZ and 2^n > n^2` is solved to a set, and was a refusal
792820

793821
An inequality with an exponential or a factorial over the whole numbers is solved to the members

‎Sources/.editorconfig‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,9 @@ file_header_template=\nCopyright (c) 2019-2026 Angouri.\nAngouriMath is licensed
291291
[AngouriMath/Functions/NumberTheory/ResidueClasses.cs]
292292
file_header_template=\nCopyright (c) 2019-2026 Angouri.\nAngouriMath is licensed under MIT.\nDetails: https://github.com/asc-community/AngouriMath/blob/master/LICENSE.md.\nWebsite: https://am.angouri.org.\n
293293

294+
[Tests/UnitTests/Calculus/InverseHyperbolicSecantIntegralTest.cs]
295+
file_header_template=\nCopyright (c) 2019-2026 Angouri.\nAngouriMath is licensed under MIT.\nDetails: https://github.com/asc-community/AngouriMath/blob/master/LICENSE.md.\nWebsite: https://am.angouri.org.\n
296+
294297
[AngouriMath/Functions/Continuous/Solvers/InequalitySolver/ThresholdSearch.cs]
295298
file_header_template=\nCopyright (c) 2019-2026 Angouri.\nAngouriMath is licensed under MIT.\nDetails: https://github.com/asc-community/AngouriMath/blob/master/LICENSE.md.\nWebsite: https://am.angouri.org.\n
296299

‎Sources/AngouriMath/Functions/Continuous/Differentiation.cs‎

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,22 @@ internal Entity DifferentiateOnce(Variable variable)
7171
/// Internal differentiation function
7272
/// </summary>
7373
/// <param name="variable">To derive over</param>
74-
/// <returns>The differentiated expressoin or the Derivative node</returns>
74+
/// <returns>
75+
/// The differentiated expression, or the Derivative node -- and zero for a node with no
76+
/// rule of its own that does not mention the variable: it is a constant in it, and the
77+
/// derivative of a constant is not an open question.
78+
/// </returns>
7579
protected virtual Entity InnerDifferentiate(Variable variable)
76-
=> new Derivativef(this, variable, 1);
80+
=> ContainsNode(variable) ? new Derivativef(this, variable, 1) : Integer.Zero;
81+
82+
/// <summary>
83+
/// Whether the node is a constant in <paramref name="variable"/>, which the modulus, the
84+
/// sign, the floor and their kin ask before their own rule: <c>|c|</c> is a constant in
85+
/// <c>x</c> whether or not <c>c</c> is known to be real, and <c>floor(c)</c> one with no
86+
/// condition on <c>c</c>. <c>|c| x</c> was differentiated to <c>derivative(|c|, x) x + |c|</c>,
87+
/// which every rule downstream read as a function of <c>x</c>.
88+
/// </summary>
89+
private bool IsConstantIn(Variable variable) => !ContainsNode(variable);
7790

7891
partial record Variable
7992
{
@@ -361,7 +374,7 @@ partial record Factorialf
361374
/// </para>
362375
/// </remarks>
363376
protected override Entity InnerDifferentiate(Variable variable)
364-
=> MathS.Derivative(this, variable, 1);
377+
=> base.InnerDifferentiate(variable);
365378
}
366379

367380
#pragma warning disable IDE0054 // Use compound assignment
@@ -371,7 +384,7 @@ partial record Derivativef
371384
protected override Entity InnerDifferentiate(Variable variable) =>
372385
Var == variable
373386
? this with { Iterations = Iterations + 1 }
374-
: MathS.Derivative(this, variable, 1);
387+
: base.InnerDifferentiate(variable);
375388
}
376389

377390
partial record Integralf
@@ -384,7 +397,7 @@ protected override Entity InnerDifferentiate(Variable variable) =>
384397
? to.InnerDifferentiate(variable) * Expression.Substitute(variable, to) -
385398
from.InnerDifferentiate(variable) * Expression.Substitute(variable, from)
386399
: Expression
387-
: MathS.Derivative(this, variable, 1);
400+
: base.InnerDifferentiate(variable);
388401
}
389402
#pragma warning restore IDE0054 // Use compound assignment
390403

@@ -396,7 +409,7 @@ protected override Entity InnerDifferentiate(Variable variable) =>
396409

397410
// See https://math.stackexchange.com/a/1048570/627798:
398411
// The derivative itself is a limit, so we can exchange limits if possible. -- Happypig375
399-
MathS.Derivative(this, variable);
412+
base.InnerDifferentiate(variable);
400413
}
401414

402415
partial record Signumf
@@ -412,7 +425,8 @@ partial record Signumf
412425
// https://github.com/asc-community/AngouriMath/issues/1186
413426
/// <inheritdoc/>
414427
protected override Entity InnerDifferentiate(Variable variable)
415-
=> TreeAnalyzer.IsRealValued(Argument, variable)
428+
=> IsConstantIn(variable) ? Integer.Zero
429+
: TreeAnalyzer.IsRealValued(Argument, variable)
416430
? Integer.Zero.Provided(!Argument.EqualTo(Integer.Zero))
417431
: MathS.Derivative(this, variable);
418432
}
@@ -431,7 +445,8 @@ partial record Absf
431445
// https://github.com/asc-community/AngouriMath/issues/1186
432446
/// <inheritdoc/>
433447
protected override Entity InnerDifferentiate(Variable variable)
434-
=> TreeAnalyzer.TryTakeNumericModulusOut(Argument, out var withoutThePhase)
448+
=> IsConstantIn(variable) ? Integer.Zero
449+
: TreeAnalyzer.TryTakeNumericModulusOut(Argument, out var withoutThePhase)
435450
? withoutThePhase.InnerDifferentiate(variable)
436451
: TreeAnalyzer.IsRealValued(Argument, variable)
437452
? MathS.Signum(Argument).Provided(!Argument.EqualTo(Integer.Zero)) * Argument.InnerDifferentiate(variable)
@@ -447,14 +462,14 @@ partial record Floorf
447462
// has Providedf to say more with.
448463
/// <inheritdoc/>
449464
protected override Entity InnerDifferentiate(Variable variable)
450-
=> Integer.Zero.Provided(!Argument.In(MathS.Sets.Z));
465+
=> IsConstantIn(variable) ? Integer.Zero : Integer.Zero.Provided(!Argument.In(MathS.Sets.Z));
451466
}
452467

453468
partial record Ceilf
454469
{
455470
/// <inheritdoc/>
456471
protected override Entity InnerDifferentiate(Variable variable)
457-
=> Integer.Zero.Provided(!Argument.In(MathS.Sets.Z));
472+
=> IsConstantIn(variable) ? Integer.Zero : Integer.Zero.Provided(!Argument.In(MathS.Sets.Z));
458473
}
459474

460475
partial record Roundf
@@ -463,7 +478,7 @@ partial record Roundf
463478
// jumps where the argument is exactly a half, not where it is an integer.
464479
/// <inheritdoc/>
465480
protected override Entity InnerDifferentiate(Variable variable)
466-
=> Integer.Zero.Provided(!(Argument - Rational.Create(1, 2)).In(MathS.Sets.Z));
481+
=> IsConstantIn(variable) ? Integer.Zero : Integer.Zero.Provided(!(Argument - Rational.Create(1, 2)).In(MathS.Sets.Z));
467482
}
468483

469484
partial record Providedf
@@ -516,7 +531,7 @@ protected override Entity InnerDifferentiate(Variable variable)
516531
arg =>
517532
MathS.Derivative(this, arg) * arg.Differentiate(variable)
518533
).Aggregate((Entity)0, (a, b) => a + b),
519-
_ => MathS.Derivative(this, variable)
534+
_ => base.InnerDifferentiate(variable)
520535
};
521536
}
522537
}

0 commit comments

Comments
 (0)