Multiple-precision Complex
mpc Type
- class gmpy2.mpc(c=0, /, precision=0)
- class gmpy2.mpc(c=0, /, precision, context)
- class gmpy2.mpc(real, /, imag=0, precision=0)
- class gmpy2.mpc(real, /, imag, precision, context)
- class gmpy2.mpc(s, /, precision=0, base=10)
- class gmpy2.mpc(s, /, precision, base, context)
Return a complex floating-point number constructed from a numeric value c or from a pair of two non-complex numbers real and imag or from a string s made of digits in the given base.
A string can be possibly with real-part and/or imaginary-part (that have ‘j’ as a suffix), separated by ‘+’ and parsed the same as the
mpfrconstructor does (but the base must be up to 36).The precision can be specified by either a single number that is used for both the real and imaginary components, or as a pair of different precisions for the real and imaginary components. For every component, the meaning of its precision value is the same as in the
mpfrtype constructor.- __format__(fmt, /)
Return a Python string by formatting self using the format string ‘fmt’.
All of
mpfr’s format types and options are supported, with the exception of ‘%’ format type, ‘=’ alignment and zero padding.
- conjugate()
Returns the conjugate of self.
- digits(base=10, prec=0, /)
Returns up to ‘prec’ digits in the given base. If ‘prec’ is 0, as many digits that are available given self’s precision are returned. ‘base’ must be between 2 and 62. The result consists of 2 three-element tuples that contain the mantissa, exponent, and number of bits of precision of the real and imaginary components.
- is_finite()
Return
Trueif self is an actual number (i.e. non NaN or Infinity). If self is anmpc, returnTrueif both self.real and self.imag are finite.
- is_infinite()
Return
Trueif self is +Infinity or -Infinity. If self is anmpc, returnTrueif either self.real or self.imag is infinite. Otherwise returnFalse.
- is_zero()
Return
Trueif self is equal to 0. If self is anmpc, returnTrueif both self.real and self.imag are equal to 0.
- imag
imaginary component
- precision
precision in bits
- rc
return code
- real
real component
mpc Functions
- gmpy2.acos(x, /)
Return inverse cosine of x; result in radians.
- gmpy2.acosh(x, /)
Return inverse hyperbolic cosine of x.
- gmpy2.asin(x, /)
Return inverse sine of x; result in radians.
- gmpy2.asinh(x, /)
Return inverse hyperbolic sine of x.
- gmpy2.atan(x, /)
Return inverse tangent of x; result in radians.
- gmpy2.atanh(x, /)
Return inverse hyperbolic tangent of x.
- gmpy2.cos(x, /)
Return cosine of x; x in radians.
- gmpy2.cosh(x, /)
Return hyperbolic cosine of x.
- gmpy2.div_2exp(x, n, /)
Return x divided by 2**n.
- gmpy2.exp(x, /)
Return the exponential of x.
- gmpy2.is_zero(x, /)
Return
Trueif x is equal to 0. If x is anmpc, returnTrueif both x.real and x.imag are equal to 0.
- gmpy2.log(x, /)
Return the natural logarithm of x.
- gmpy2.log10(x, /)
Return the base-10 logarithm of x.
- gmpy2.mpc_random(random_state, /)
Return uniformly distributed number in the unit square [0,1]x[0,1].
- gmpy2.mul_2exp(x, n, /)
Return x multiplied by 2**n.
- gmpy2.norm(x, /)
Return the norm of a complex x. The norm(x) is defined as x.real**2 + x.imag**2. abs(x) is the square root of norm(x).
- gmpy2.phase(x, /)
Return the phase angle, also known as argument, of a complex x.
- gmpy2.polar(x, /)
Return the polar coordinate form of a complex x that is in rectangular form.
- gmpy2.proj(x, /)
Returns the projection of a complex x on to the Riemann sphere.
- gmpy2.rect(r, phi, /)
Return the rectangular coordinate form of a complex number that is given in polar form.
- gmpy2.root_of_unity(n, k, /)
Return the n-th root of mpc(1) raised to the k-th power..
- gmpy2.sin(x, /)
Return sine of x; x in radians.
- gmpy2.sin_cos(x, /)
Return a tuple containing the sine and cosine of x; x in radians.
- gmpy2.sinh(x, /)
Return hyperbolic sine of x.
- gmpy2.sqrt(x, /)
Return the square root of x.
- gmpy2.tan(x, /)
Return tangent of x; x in radians.
- gmpy2.tanh(x, /)
Return hyperbolic tangent of x.