# CC -- the class of all complex numbers

## Description

In Macaulay2, complex numbers are represented as floating point numbers, and so are only approximate. The symbol ii represents the square root of -1 in many numeric contexts. A complex number is obtained by using the symbolic constant ii or the conversion functions toCC and numeric, in combination with real numbers (see RR). It is stored internally as a pair of arbitrary precision floating point real numbers, using the MPFR library.
 i1 : z = 3-4*ii o1 = 3-4*ii o1 : CC (of precision 53) i2 : z^5 o2 = -237.000000000002+3116*ii o2 : CC (of precision 53) i3 : 1/z o3 = .12+.16*ii o3 : CC (of precision 53) i4 : +ii o4 = ii o4 : CC (of precision 53) i5 : numeric_200 ii o5 = ii o5 : CC (of precision 200)
Complex numbers are ordered lexicographically, mingled with real numbers.
 i6 : sort {1+ii,2+ii,1-ii,2-ii,1/2,2.1,7/5} 1 7 o6 = {-, 1-ii, 1+ii, -, 2-ii, 2+ii, 2.1} 2 5 o6 : List
The precision is measured in bits, is visible in the ring displayed on the second of each pair of output lines, and can be recovered using precision.
 i7 : precision z o7 = 53
For complex numbers, the functions class and ring yield different results. That allows numbers of various precisions to be used without creating a new ring for each precision.
 i8 : class z o8 = CC o8 : InexactFieldFamily i9 : ring z o9 = CC 53 o9 : ComplexField
A computation involving numbers of different precisions has a result with the minimal precision occurring. Numbers that appear alone on an output line are displayed with all their meaningful digits. (Specifying 100 bits of precision yields about 30 decimal digits of precision.)
 i10 : 3p100+2p90e3*ii o10 = 3+2000*ii o10 : CC (of precision 90)
Numbers displayed inside more complicated objects are printed with the number of digits specified by printingPrecision.
 i11 : printingPrecision o11 = 6 i12 : x = {1/3.*ii,1/3p100*ii} o12 = {.333333*ii, .333333*ii} o12 : List
Use toExternalString to produce something that, when encountered as input, will reproduce exactly what you had before.
 i13 : y = toExternalString x o13 = {toCC(.0p53,.33333333333333331p53),toCC(.0p100 ,.33333333333333333333333333333346p100)} i14 : value y === x o14 = true

## Caveat

Currently, most transcendental functions are not implemented for complex arguments.

• ii -- the square root of -1
• toCC -- convert to high-precision complex number
• toRR -- convert to high-precision real number
• numeric -- convert to floating point
• precision
• format -- format a string or a real number
• printingPrecision -- current precision for printing numbers
• printingAccuracy -- current accuracy for printing numbers
• printingLeadLimit -- maximum number of leading zeroes to use when printing real numbers
• printingTrailLimit -- maximum number of additional trailing digits to use when printing real numbers
• printingSeparator -- string used to separate mantissa from exponent when printing real numbers

## Functions and methods returning a complex number :

• "CC * CC" -- see * -- a binary operator, usually used for multiplication
• "CC * QQ" -- see * -- a binary operator, usually used for multiplication
• "CC * RR" -- see * -- a binary operator, usually used for multiplication
• "CC * ZZ" -- see * -- a binary operator, usually used for multiplication
• "QQ * CC" -- see * -- a binary operator, usually used for multiplication
• "RR * CC" -- see * -- a binary operator, usually used for multiplication
• "ZZ * CC" -- see * -- a binary operator, usually used for multiplication
• "+ CC" -- see + -- a unary or binary operator, usually used for addition
• "CC + CC" -- see + -- a unary or binary operator, usually used for addition
• "CC + QQ" -- see + -- a unary or binary operator, usually used for addition
• "CC + RR" -- see + -- a unary or binary operator, usually used for addition
• "CC + ZZ" -- see + -- a unary or binary operator, usually used for addition
• "QQ + CC" -- see + -- a unary or binary operator, usually used for addition
• "RR + CC" -- see + -- a unary or binary operator, usually used for addition
• "ZZ + CC" -- see + -- a unary or binary operator, usually used for addition
• "- CC" -- see - -- a unary or binary operator, usually used for negation or subtraction
• "CC - CC" -- see - -- a unary or binary operator, usually used for negation or subtraction
• "CC - QQ" -- see - -- a unary or binary operator, usually used for negation or subtraction
• "CC - RR" -- see - -- a unary or binary operator, usually used for negation or subtraction
• "CC - ZZ" -- see - -- a unary or binary operator, usually used for negation or subtraction
• "QQ - CC" -- see - -- a unary or binary operator, usually used for negation or subtraction
• "RR - CC" -- see - -- a unary or binary operator, usually used for negation or subtraction
• "ZZ - CC" -- see - -- a unary or binary operator, usually used for negation or subtraction
• "CC / CC" -- see / -- a binary operator, usually used for division
• "CC / QQ" -- see / -- a binary operator, usually used for division
• "CC / RR" -- see / -- a binary operator, usually used for division
• "CC / ZZ" -- see / -- a binary operator, usually used for division
• "QQ / CC" -- see / -- a binary operator, usually used for division
• "RR / CC" -- see / -- a binary operator, usually used for division
• "ZZ / CC" -- see / -- a binary operator, usually used for division
• "acos(CC)" -- see acos -- arccosine
• "agm(CC,CC)" -- see agm -- arithmetic-geometric mean
• "agm(CC,QQ)" -- see agm -- arithmetic-geometric mean
• "agm(CC,RR)" -- see agm -- arithmetic-geometric mean
• "agm(CC,ZZ)" -- see agm -- arithmetic-geometric mean
• "agm(QQ,CC)" -- see agm -- arithmetic-geometric mean
• "agm(RR,CC)" -- see agm -- arithmetic-geometric mean
• "agm(ZZ,CC)" -- see agm -- arithmetic-geometric mean
• "asin(CC)" -- see asin -- arcsine
• "atan(CC)" -- see atan -- compute the arctangent of a number
• "cos(CC)" -- see cos -- compute the cosine
• "cosh(CC)" -- see cosh -- compute the hyperbolic cosine
• "cot(CC)" -- see cot -- cotangent
• "coth(CC)" -- see coth -- hyperbolic cotangent
• "csc(CC)" -- see csc -- cosecant
• "csch(CC)" -- see csch -- hyperbolic cosecant
• "exp(CC)" -- see exp -- exponential function
• "log(CC)" -- see log -- logarithm function
• "log(QQ,CC)" -- see log -- logarithm function
• "log(RR,CC)" -- see log -- logarithm function
• "log(RR,RR)" -- see log -- logarithm function
• "log(ZZ,CC)" -- see log -- logarithm function
• "sec(CC)" -- see sec -- secant
• "sech(CC)" -- see sech -- hyperbolic secant
• "sin(CC)" -- see sin -- compute the sine
• "sinh(CC)" -- see sinh -- compute the hyperbolic sine
• "sqrt(CC)" -- see sqrt -- square root function
• "sqrt(QQ)" -- see sqrt -- square root function
• "sqrt(RR)" -- see sqrt -- square root function
• "sqrt(ZZ)" -- see sqrt -- square root function
• "tan(CC)" -- see tan -- compute the tangent
• "tanh(CC)" -- see tanh -- compute the hyperbolic tangent
• "toCC(CC)" -- see toCC -- convert to high-precision complex number
• "toCC(QQ)" -- see toCC -- convert to high-precision complex number
• "toCC(RR)" -- see toCC -- convert to high-precision complex number
• "toCC(RR,RR)" -- see toCC -- convert to high-precision complex number
• "toCC(ZZ)" -- see toCC -- convert to high-precision complex number
• "toCC(ZZ,CC)" -- see toCC -- convert to high-precision complex number
• "toCC(ZZ,QQ)" -- see toCC -- convert to high-precision complex number
• "toCC(ZZ,QQ,QQ)" -- see toCC -- convert to high-precision complex number
• "toCC(ZZ,QQ,RR)" -- see toCC -- convert to high-precision complex number
• "toCC(ZZ,QQ,ZZ)" -- see toCC -- convert to high-precision complex number
• "toCC(ZZ,RR)" -- see toCC -- convert to high-precision complex number
• "toCC(ZZ,RR,QQ)" -- see toCC -- convert to high-precision complex number
• "toCC(ZZ,RR,RR)" -- see toCC -- convert to high-precision complex number
• "toCC(ZZ,RR,ZZ)" -- see toCC -- convert to high-precision complex number
• "toCC(ZZ,ZZ)" -- see toCC -- convert to high-precision complex number
• "toCC(ZZ,ZZ,QQ)" -- see toCC -- convert to high-precision complex number
• "toCC(ZZ,ZZ,RR)" -- see toCC -- convert to high-precision complex number
• "toCC(ZZ,ZZ,ZZ)" -- see toCC -- convert to high-precision complex number

## Methods that use a complex number :

• "CC % CC" -- see % -- a binary operator, usually used for remainder and reduction
• "CC % QQ" -- see % -- a binary operator, usually used for remainder and reduction
• "CC % RR" -- see % -- a binary operator, usually used for remainder and reduction
• "CC % ZZ" -- see % -- a binary operator, usually used for remainder and reduction
• "CC // CC" -- see // -- a binary operator, usually used for quotient
• "CC // QQ" -- see // -- a binary operator, usually used for quotient
• "CC // RR" -- see // -- a binary operator, usually used for quotient
• "CC // ZZ" -- see // -- a binary operator, usually used for quotient
• "CC == CC" -- see == -- equality
• "CC == QQ" -- see == -- equality
• "CC == RR" -- see == -- equality
• "CC == ZZ" -- see == -- equality
• "QQ == CC" -- see == -- equality
• "RR == CC" -- see == -- equality
• "ZZ == CC" -- see == -- equality
• "CC ^ ZZ" -- see ^ -- a binary operator, usually used for powers
• "abs(CC)" -- see abs -- absolute value function
• CC * InfiniteNumber (missing documentation)
• CC + InfiniteNumber (missing documentation)
• CC - InfiniteNumber (missing documentation)
• CC ? InfiniteNumber (missing documentation)
• conjugate(CC) -- complex conjugate
• "format(CC)" -- see format -- format a string or a real number
• InfiniteNumber * CC (missing documentation)
• InfiniteNumber + CC (missing documentation)
• InfiniteNumber - CC (missing documentation)
• InfiniteNumber / CC (missing documentation)
• InfiniteNumber // CC (missing documentation)
• InfiniteNumber ? CC (missing documentation)
• "isReal(CC)" -- see isReal -- whether a number is real
• "CC << ZZ" -- see left shift
• "lift(CC,type of QQ)" -- see lift -- lift to another ring
• "lift(CC,type of RR_*)" -- see lift -- lift to another ring
• "lift(CC,type of ZZ)" -- see lift -- lift to another ring
• liftable(CC,type of RR_*) (missing documentation)
• "numeric(CC)" -- see numeric -- convert to floating point
• "numeric(ZZ,CC)" -- see numeric -- convert to floating point
• "CC >> ZZ" -- see right shift
• "ring(CC)" -- see ring -- get the associated ring of an object
• "round(CC)" -- see round -- round a number
• "size2(CC)" -- see size2 -- number of binary digits to the left of the point

## For the programmer

The object CC is , with ancestor classes InexactNumber < Number < Thing.