# Mathematical constants¶

Mpmath supports arbitrary-precision computation of various common (and less common) mathematical constants. These constants are implemented as lazy objects that can evaluate to any precision. Whenever the objects are used as function arguments or as operands in arithmetic operations, they automagically evaluate to the current working precision. A lazy number can be converted to a regular mpf using the unary + operator, or by calling it as a function:

>>> from mpmath import *
>>> mp.dps = 15
>>> pi
<pi: 3.14159~>
>>> 2*pi
mpf('6.2831853071795862')
>>> +pi
mpf('3.1415926535897931')
>>> pi()
mpf('3.1415926535897931')
>>> mp.dps = 40
>>> pi
<pi: 3.14159~>
>>> 2*pi
mpf('6.283185307179586476925286766559005768394338')
>>> +pi
mpf('3.141592653589793238462643383279502884197169')
>>> pi()
mpf('3.141592653589793238462643383279502884197169')


## Exact constants¶

The predefined objects j (imaginary unit), inf (positive infinity) and nan (not-a-number) are shortcuts to mpc and mpf instances with these fixed values.

## Pi (pi)¶

mp.pi = <pi: 3.14159~>

## Degree (degree)¶

mp.degree = <1 deg = pi / 180: 0.0174533~>

## Base of the natural logarithm (e)¶

mp.e = <e = exp(1): 2.71828~>

## Golden ratio (phi)¶

mp.phi = <Golden ratio phi: 1.61803~>

## Euler’s constant (euler)¶

mp.euler = <Euler's constant: 0.577216~>

## Catalan’s constant (catalan)¶

mp.catalan = <Catalan's constant: 0.915966~>

## Apery’s constant (apery)¶

mp.apery = <Apery's constant: 1.20206~>

## Khinchin’s constant (khinchin)¶

mp.khinchin = <Khinchin's constant: 2.68545~>

## Glaisher’s constant (glaisher)¶

mp.glaisher = <Glaisher's constant: 1.28243~>

## Mertens constant (mertens)¶

mp.mertens = <Mertens' constant: 0.261497~>

## Twin prime constant (twinprime)¶

mp.twinprime = <Twin prime constant: 0.660162~>