Skip to content

Euler's constant, eulergamma - #2204

Merged
Rafael-SOWNet merged 1 commit into
masterfrom
the-euler-mascheroni-constant
Oct 29, 2026
Merged

Rafael-SOWNet merged 1 commit into
masterfrom
the-euler-mascheroni-constant

Conversation

@Rafael-SOWNet

Copy link
Copy Markdown
Member

Part of #2182.

eulergamma is Euler's constant, the Euler–Mascheroni constant γ = 0.5772156649…, the one constant the register lists.

  • It is a constant like pi and e: evaluated to the working precision (Brent and McMillan, the routine Ei and Ci already used), in the interval and decimal evaluators, and in both compilers.
  • EulerGamma, the Mathematica and SymPy name, is read as it too. γ stays a variable, and gamma is still the Γ function.
  • It draws as \mathrm{\gamma} and exports as sympy.EulerGamma.
  • A name an operator declares is the name, as for e: sum(eulergamma, eulergamma, 1, 3) is 6.

With it, values that had no closed form become exact:

Simplify master (97843f4) now
digamma(1) digamma(1) -eulergamma
digamma(3) digamma(3) 3/2 - eulergamma
digamma(1/2) digamma(1/2) (-2) * ln(2) - eulergamma
harmonicnumber(1/2) harmonicnumber(1/2) 2 - 2 * ln(2)
harmonicnumber(1/2, 2) harmonicnumber(1/2, 2) 4 - 1/3 * pi ^ 2

That is psi(1) = -gamma and psi(1/2) = -gamma - 2 ln 2 (DLMF 5.4.12, 5.4.13) and the recurrence from either. harmonicnumber(n, m) at a half-whole n is exact for m = 1 and an even m. An odd m from 3 needs zeta(3) and stays as written.

Tests: EulerGammaTest. The value is checked against mpmath to 100 and 150 digits, and every exact digamma and harmonic value against mpmath's to 30 digits.
Full suite 17835/0, interactive trio, AOT smoke 64/0, all frameworks build.

🤖 Generated with Claude Code

https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura

eulergamma is the Euler-Mascheroni constant, 0.5772156649..., and
EulerGamma, its name in Mathematica and SymPy, is read as it. It is
evaluated to the working precision by the Brent-McMillan routine the
exponential and trigonometric integrals already used, and it has a
value in the interval and decimal evaluators and in both compilers. It
draws as \mathrm{\gamma} and exports as sympy.EulerGamma.

With it the digamma function is exact at a whole or half-whole
argument: psi(1) = -gamma and psi(1/2) = -gamma - 2 ln 2, and the
recurrence from either. digamma(3) is 3/2 - eulergamma. The harmonic
number at a half-whole n is exact for m = 1 and an even m, from the
same values with Euler's constant left out, since it cancels:
harmonicnumber(1/2) is 2 - 2 ln 2.

Part of #2182

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura
@Rafael-SOWNet Rafael-SOWNet moved this from Todo to In review in AngouriMath Oct 29, 2026
@codecov

codecov Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.71429% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.55%. Comparing base (cefe104) to head (07db58b).

Files with missing lines Patch % Lines
Sources/AngouriMath/Numerics/PreciseEvaluation.cs 0.00% 4 Missing and 1 partial ⚠️
Sources/AngouriMath/Numerics/IntervalEvaluation.cs 0.00% 1 Missing and 1 partial ⚠️
...uriMath/Core/Entity/Continuous/Number/Polygamma.cs 97.36% 0 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2204      +/-   ##
==========================================
- Coverage   86.57%   86.55%   -0.03%     
==========================================
  Files         301      301              
  Lines       66764    66807      +43     
  Branches    19372    19389      +17     
==========================================
+ Hits        57801    57824      +23     
- Misses       4874     4890      +16     
- Partials     4089     4093       +4     
Flag Coverage Δ
cpp 37.77% <ø> (ø)
csharp 87.11% <85.71%> (-0.03%) ⬇️
fsharp 32.97% <ø> (ø)
interactive 40.72% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
Sources/AngouriMath/Convenience/MathS.cs 90.49% <100.00%> (+0.05%) ⬆️
...e/Entity/Continuous/Number/ExponentialIntegrals.cs 93.25% <ø> (ø)
...es/AngouriMath/Core/Entity/Omni/Entity.Variable.cs 96.55% <100.00%> (+1.90%) ⬆️
...nuous/Evaluation.Continuous.Arithmetics.Classes.cs 86.71% <100.00%> (+0.04%) ⬆️
...ngouriMath/Functions/Output/Latex/Latex.Classes.cs 100.00% <100.00%> (ø)
...riMath/Functions/Output/ToSympy/ToSympy.Classes.cs 100.00% <100.00%> (ø)
...uriMath/Core/Entity/Continuous/Number/Polygamma.cs 96.62% <97.36%> (-0.06%) ⬇️
Sources/AngouriMath/Numerics/IntervalEvaluation.cs 87.66% <0.00%> (-0.58%) ⬇️
Sources/AngouriMath/Numerics/PreciseEvaluation.cs 84.61% <0.00%> (-1.03%) ⬇️

... and 6 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Rafael-SOWNet
Rafael-SOWNet merged commit 7633d18 into master Oct 29, 2026
37 of 38 checks passed
@github-project-automation github-project-automation Bot moved this from In review to Done in AngouriMath Oct 29, 2026
@Rafael-SOWNet
Rafael-SOWNet deleted the the-euler-mascheroni-constant branch October 29, 2026 17:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant