Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions BREAKING-CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,34 @@ written
| `"forall n in ZZ+ : n! >= 2^(n - 1)".ToEntity().Evaled` | `UnhandledParseException` | `True` |
| `"forall n in ZZ+ /\\ [4; +oo) : n^2 - 2 n - 1 > 0".ToEntity().Evaled` | `UnhandledParseException` | `True` — decided about `4 + t` over `ZZ*` |

### `acsch(c x)` and `asech(c x)` are integrated with a symbolic `c`, and `|c|` differentiates to `0` in `x`

Three defects behind one symptom: `x acsch(2 x)` was answered and `x acsch(c x)` declined. The
parser spells the inverse hyperbolic cosecant `ln(1/(c x) + sqrt(1/(c x)^2 + 1))`, and (1) `(c x)^2`
was read as a power of something that is not a polynomial where `(2 x)^2` had been folded to
`4 x^2` — a whole power of a product with a symbolic constant beside the variable is now written
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
not written apart as `sqrt(1 + c^2 x^2)/(|c| |x|)` because `c^2` is not a number — a parameter's
even power is taken for positive now, and the answer says so, `provided c^2 > 0`, which holds
exactly for a real non-zero `c`; (3) the step by parts differentiated `|c|` to
`derivative(|c|, x)`, since the modulus rule asks whether its argument is real before it asks
whether the argument mentions the variable — **the modulus, the sign, the floor, the ceiling,
the rounding, a limit, a sum, a product, an applied function and any node with no rule of its
own differentiate to `0` where they do not mention the variable**, with no condition, which also
removes the `provided not c in ZZ` that `floor(c) + x` carried. A node with a rule of its own
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
quotients are cancelled as polynomials in their radicals, so that `q^(-1/2)` above and `sqrt(q)`
below are one indeterminate. Rubi's 7.5.1 and 7.6.1
([#718](https://github.com/asc-community/AngouriMath/issues/718)).

| Input | Was (2.5.0) | Now |
|---|---|---|
| `"abs(c) * x".ToEntity().Differentiate("x")` | `derivative(abs(c), x) * x + abs(c)` | `abs(c)` |
| `"floor(c) + x".ToEntity().Differentiate("x")` | `1 provided not c in ZZ` | `1` |
| `"c!".ToEntity().Differentiate("x")` | `derivative(c!, x)` | `0` |
| `"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` |
| `"x^2 * asech(c * x)".ToEntity().Integrate("x")` | `integral(...)`, the same | an antiderivative |
| `"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` |
### `n in ZZ and 2^n > n^2` is solved to a set, and was a refusal

An inequality with an exponential or a factorial over the whole numbers is solved to the members
Expand Down
3 changes: 3 additions & 0 deletions Sources/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,9 @@ file_header_template=\nCopyright (c) 2019-2026 Angouri.\nAngouriMath is licensed
[AngouriMath/Functions/NumberTheory/ResidueClasses.cs]
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

[Tests/UnitTests/Calculus/InverseHyperbolicSecantIntegralTest.cs]
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

[AngouriMath/Functions/Continuous/Solvers/InequalitySolver/ThresholdSearch.cs]
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

Expand Down
39 changes: 27 additions & 12 deletions Sources/AngouriMath/Functions/Continuous/Differentiation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,22 @@ internal Entity DifferentiateOnce(Variable variable)
/// Internal differentiation function
/// </summary>
/// <param name="variable">To derive over</param>
/// <returns>The differentiated expressoin or the Derivative node</returns>
/// <returns>
/// The differentiated expression, or the Derivative node -- and zero for a node with no
/// rule of its own that does not mention the variable: it is a constant in it, and the
/// derivative of a constant is not an open question.
/// </returns>
protected virtual Entity InnerDifferentiate(Variable variable)
=> new Derivativef(this, variable, 1);
=> ContainsNode(variable) ? new Derivativef(this, variable, 1) : Integer.Zero;

/// <summary>
/// Whether the node is a constant in <paramref name="variable"/>, which the modulus, the
/// sign, the floor and their kin ask before their own rule: <c>|c|</c> is a constant in
/// <c>x</c> whether or not <c>c</c> is known to be real, and <c>floor(c)</c> one with no
/// condition on <c>c</c>. <c>|c| x</c> was differentiated to <c>derivative(|c|, x) x + |c|</c>,
/// which every rule downstream read as a function of <c>x</c>.
/// </summary>
private bool IsConstantIn(Variable variable) => !ContainsNode(variable);

partial record Variable
{
Expand Down Expand Up @@ -361,7 +374,7 @@ partial record Factorialf
/// </para>
/// </remarks>
protected override Entity InnerDifferentiate(Variable variable)
=> MathS.Derivative(this, variable, 1);
=> base.InnerDifferentiate(variable);
}

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

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

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

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

partial record Signumf
Expand All @@ -412,7 +425,8 @@ partial record Signumf
// https://github.com/asc-community/AngouriMath/issues/1186
/// <inheritdoc/>
protected override Entity InnerDifferentiate(Variable variable)
=> TreeAnalyzer.IsRealValued(Argument, variable)
=> IsConstantIn(variable) ? Integer.Zero
: TreeAnalyzer.IsRealValued(Argument, variable)
? Integer.Zero.Provided(!Argument.EqualTo(Integer.Zero))
: MathS.Derivative(this, variable);
}
Expand All @@ -431,7 +445,8 @@ partial record Absf
// https://github.com/asc-community/AngouriMath/issues/1186
/// <inheritdoc/>
protected override Entity InnerDifferentiate(Variable variable)
=> TreeAnalyzer.TryTakeNumericModulusOut(Argument, out var withoutThePhase)
=> IsConstantIn(variable) ? Integer.Zero
: TreeAnalyzer.TryTakeNumericModulusOut(Argument, out var withoutThePhase)
? withoutThePhase.InnerDifferentiate(variable)
: TreeAnalyzer.IsRealValued(Argument, variable)
? MathS.Signum(Argument).Provided(!Argument.EqualTo(Integer.Zero)) * Argument.InnerDifferentiate(variable)
Expand All @@ -447,14 +462,14 @@ partial record Floorf
// has Providedf to say more with.
/// <inheritdoc/>
protected override Entity InnerDifferentiate(Variable variable)
=> Integer.Zero.Provided(!Argument.In(MathS.Sets.Z));
=> IsConstantIn(variable) ? Integer.Zero : Integer.Zero.Provided(!Argument.In(MathS.Sets.Z));
}

partial record Ceilf
{
/// <inheritdoc/>
protected override Entity InnerDifferentiate(Variable variable)
=> Integer.Zero.Provided(!Argument.In(MathS.Sets.Z));
=> IsConstantIn(variable) ? Integer.Zero : Integer.Zero.Provided(!Argument.In(MathS.Sets.Z));
}

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

partial record Providedf
Expand Down Expand Up @@ -516,7 +531,7 @@ protected override Entity InnerDifferentiate(Variable variable)
arg =>
MathS.Derivative(this, arg) * arg.Differentiate(variable)
).Aggregate((Entity)0, (a, b) => a + b),
_ => MathS.Derivative(this, variable)
_ => base.InnerDifferentiate(variable)
};
}
}
Expand Down
Loading
Loading