How this calculation works
Evaluate gamma and its analytic logarithm in the right half-plane. The branch convention is stated explicitly because taking a principal logarithm of the final gamma value can produce a different imaginary part.
logΓ(z+1)=logΓ(z)+Log z on Re(z)>0; Γ(z)=exp(logΓ(z)).A worked example
At z=2+3i,logΓ(z)≈−2.0928517531+2.3023965435i. Exponentiating this value gives Γ(z);the recurrence residual checks the same analytic branch at z+1.
Good to know
0.1≤Re z≤30,|Im z|≤30. Right-half-plane analytic logGamma real on positive axis;imaginary part not wrapped modulo2π. Recurrence shifting plus finite Stirling corrections. No left-half-plane poles,reflection continuation or certified error enclosure.
Reference: Mathematical method reference (opens in a new tab) ↗
The logarithm of gamma needs a branch convention
Gamma is a complex-valued function,but its logarithm is not determined by exponentiation alone:adding an integer multiple of2πi leaves gamma unchanged. A usable numerical logGamma output must therefore specify how its imaginary part is chosen.
This page uses the analytic branch on the right half-plane that is real on the positive real axis. It does not wrap the result's imaginary part into the principal argument interval after evaluation,because that would change this continuous branch.
Compare this with the Complex number arithmetic calculator. Arithmetic on supplied complex values does not evaluate the gamma function or choose its logarithm branch.
The supported half-plane avoids gamma poles
Inputs have positive real part at least0.1 and bounded imaginary magnitude. This avoids the nonpositive-integer gamma poles and permits repeated shifts toward a region where the asymptotic expansion is stable without a reflection formula.
The real-part upper bound also limits the size of the exponentiated gamma output. Both logarithmic and gamma components are reported,but a logarithmic result may be the more useful representation when magnitudes vary over many orders.
Recurrence shifting reduces the asymptotic difficulty
The implementation shifts z to the right using the functional equation and records the sum of complex logarithms of the crossed factors. A finite Stirling expansion is evaluated only after the shifted real part reaches the chosen threshold.
Subtracting the accumulated factor logarithms returns the analytic logGamma at the original input. Each complex logarithm uses the right-half-plane continuation consistently;an arbitrary argument reset at the end would break the recurrence interpretation.
Follow the complex default through exponentiation
For z=2+3i,the default logarithm has real part near−2.09285 and imaginary part near2.30240. Gamma's magnitude is the exponential of the first value,and its phase is represented by the second modulo full turns.
The gamma real and imaginary components are reconstructed with cosine and sine of that phase. This gives a useful independent presentation check:the squared component magnitudes should agree with the square of the exponential magnitude,subject to floating roundoff.
A principal logarithm of the output can differ
A library function called log(gamma(z)) may first evaluate gamma and then wrap its argument. The result can differ from analytic logGamma by2πi times an integer even when both exponentiate to the same gamma value.
That difference is a branch effect rather than automatically a numerical failure. Compare branches before comparing imaginary components. The implementation reports its convention alongside the result so an apparently discontinuous phase is not silently mixed into a continuous calculation.
The recurrence residual checks branch consistency
Evaluating logGamma at z and z+1 should differ by the selected Log z. The residual measures that complex identity and can expose an inconsistent factor shift or phase handling in the implemented right-half-plane method.
It is not a rigorous bound on truncation of the Stirling expansion. Independent complex reference fixtures test the actual values,while the recurrence tests a structural relationship. Both forms of evidence are needed because a shared systematic error can survive one identity.
Use the logarithmic result without losing its meaning
Products of gamma factors are often easier to handle as sums of logGamma values before exponentiation. Keep the branch convention consistent through those sums,especially if an application later compares phases rather than only absolute magnitudes.
This page does not analytically continue across the left half-plane or infer reflection identities from unsupported input. Pole neighborhoods and branch-sensitive subtraction require separate numerical treatment;the documented domain is part of the result,not an optional display restriction.
A few questions, answered
Is the imaginary part wrapped into±π?
No. It follows the stated analytic logGamma branch.
Can I enter a negative real part?
No. This implementation is restricted to the right half-plane.
Why show gamma and logGamma?
The logarithm preserves magnitude and phase information before exponentiation.
Does the recurrence residual certify exact accuracy?
No. It checks consistency and supplements independent reference comparisons.