Skip to content

Commit a9155c6

Browse files
Take the real root in the precise gamma function where the power takes it (#2099)
The precise evaluation read gamma(a, z) with its order as a decimal, which is the principal branch on the negative axis. The function itself takes the power's real root there for an exact order of odd denominator below 10, as the sampled checks' powers now do (#2092): gamma(1/3, -2) is 10.21, and the check read it as complex. Such an order is now handed to the function as it is written. Part of #2075. Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1 parent d9b4319 commit a9155c6

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

‎Sources/AngouriMath/Numerics/PreciseEvaluation.cs‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -559,16 +559,25 @@ private PreciseComplexInterval EvaluateOtherThanArithmetic(Entity expr)
559559
return BySlope(Evaluate(argument), Number.Chi, z => Divide(Half(Add(Exp(z), Exp(Negate(z)))), z), cutEnd: EDecimal.Zero);
560560
// The upper incomplete gamma function of a constant order, through its derivative in z,
561561
// -z^(a - 1) e^(-z), jumping across the negative real axis but at a whole order a >= 1. The
562-
// power is the principal one, as this evaluation's powers are. An order known only to its
563-
// last place, as 1/3 is, is taken at both ends, and the value is the hull of the two: across
564-
// an interval that narrow the function is linear in its order.
562+
// power's branch is the one this evaluation's powers take. Any other order known only to its
563+
// last place is taken at both ends, and the value is the hull of the two: across an interval
564+
// that narrow the function is linear in its order.
565565
// https://github.com/asc-community/AngouriMath/issues/2075
566566
case IncompleteGammaf(var parameter, var lowerLimit):
567567
{
568568
var order = Evaluate(parameter);
569569
if (!order.IsFinite)
570570
return undefined;
571571
var z = Evaluate(lowerLimit);
572+
// An exact order of odd denominator below 10 is handed to the function as it is written, which then takes
573+
// the power's real root on the negative axis, as the powers here do: as a decimal it was the principal
574+
// branch there, and gamma(1/3, -2), which is 10.21, came out complex.
575+
// https://github.com/asc-community/AngouriMath/issues/2089
576+
if (IntervalEvaluation.TheRealRootIsTaken(parameter) is not null && parameter is Number.Rational exactOrder)
577+
{
578+
var exactLessOne = Subtract(order, Real(PreciseInterval.Exactly(EDecimal.One)));
579+
return BySlope(z, w => Number.IncompleteGamma(exactOrder, w), w => Negate(Multiply(Pow(w, exactLessOne), Exp(Negate(w)))), cutEnd: EDecimal.Zero);
580+
}
572581
var entire = order.IsReal && order.Re.Low.CompareTo(order.Re.High) == 0 && order.Re.Low.IsInteger() && order.Re.Low.Sign > 0;
573582
PreciseComplexInterval AtTheOrder(EDecimal re, EDecimal im)
574583
{

‎Sources/Tests/UnitTests/Core/IntervalEvaluationTest.cs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ public void TheSizeOfALargeComplexValueIsFinite()
207207
[InlineData("gamma(1/2 + i, 2 - i)")]
208208
[InlineData("gamma(3/2, -2) + gamma(4, -1)")]
209209
[InlineData("gamma(1/3, 2) + gamma(2/7 + i/3, 1/2 + i)")]
210+
[InlineData("gamma(1/3, -2) + gamma(2/5, -17/15)")]
210211
public void ThePreciseIntervalHoldsTheValue(string expression)
211212
{
212213
var expr = expression.ToEntity();

0 commit comments

Comments
 (0)