Macaulay2 » Documentation
Packages » Macaulay2Doc » rings » basic rings of numbers » RR
next | previous | forward | backward | up | index | toc

RR -- the class of all real numbers

Description

A real number is entered as a sequence of decimal digits with a point. It is stored internally as an arbitrary precision floating point number, using the MPFR library.
i1 : 3.14159

o1 = 3.14159

o1 : RR (of precision 53)
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.
i2 : precision 3.14159

o2 = 53
For real 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.
i3 : class 3.1

o3 = RR

o3 : InexactFieldFamily
i4 : ring 3.1

o4 = RR
       53

o4 : RealField
The precision can be specified on input by appending the letter p and a positive number.
i5 : 3p300

o5 = 3

o5 : RR (of precision 300)
An optional exponent (for the power of ten to multiply by) can be specified on input by appending the letter e and a number.
i6 : 3e3

o6 = 3000

o6 : RR (of precision 53)
i7 : -3e-3

o7 = -.003

o7 : RR (of precision 53)
i8 : -3p111e-3

o8 = -.003

o8 : RR (of precision 111)
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.)
i9 : 1/3.

o9 = .3333333333333333

o9 : RR (of precision 53)
i10 : 1/3p100

o10 = .3333333333333333333333333333335

o10 : RR (of precision 100)
i11 : 100 * log(10,2)

o11 = 30.10299956639811

o11 : RR (of precision 53)
Numbers displayed inside more complicated objects are printed with the number of digits specified by printingPrecision.
i12 : printingPrecision

o12 = 6
i13 : {1/3.,1/3p100}

o13 = {.333333, .333333}

o13 : List
The notion of equality tested by == amounts to equality of the internal binary digits.
i14 : .5p100 == .5p30

o14 = true
i15 : .2p100 == .2p30

o15 = false
The notion of (strict) equality tested by === also takes the precision into account.
i16 : .5p100 === .5p30

o16 = false
i17 : .2p100 === .2p30

o17 = false
Perhaps surprisingly, the IEEE floating point standard also specifies that every number, including 0, has a sign bit, and strict equality testing takes it into account, as it must do, because some arithmetic and transcendental functions take it into account.
i18 : 0.

o18 = 0

o18 : RR (of precision 53)
i19 : -0.

o19 = -0

o19 : RR (of precision 53)
i20 : 1/0.

o20 = infinity

o20 : RR (of precision 53)
i21 : 1/-0.

o21 = -infinity

o21 : RR (of precision 53)
i22 : log 0

o22 = -infinity

o22 : RR (of precision 53)
i23 : csc (0.)

o23 = infinity

o23 : RR (of precision 53)
i24 : csc (-0.)

o24 = -infinity

o24 : RR (of precision 53)
Use toExternalString to produce something that, when encountered as input, will reproduce exactly what you had before.
i25 : x = {1/3.,1/3p100}

o25 = {.333333, .333333}

o25 : List
i26 : x == {.333333, .333333}

o26 = false
i27 : y = toExternalString x

o27 = {.33333333333333331p53,.33333333333333333333333333333346p100}
i28 : x === value y

o28 = true
Transcendental constants and functions are available to high precision, with numeric.
i29 : numeric pi

o29 = 3.141592653589793

o29 : RR (of precision 53)
i30 : numeric_200 pi

o30 = 3.141592653589793238462643383279502884197169399375105820974944

o30 : RR (of precision 200)
i31 : Gamma oo

o31 = 2.288037795340032417959588909060233922889688153356222441199382

o31 : RR (of precision 200)

See also

Menu

Functions and methods returning a real number:

  • QQ * RR -- see * -- a binary operator, usually used for multiplication
  • RR * QQ -- see * -- a binary operator, usually used for multiplication
  • RR * RR -- see * -- a binary operator, usually used for multiplication
  • RR * ZZ -- see * -- a binary operator, usually used for multiplication
  • ZZ * RR -- see * -- a binary operator, usually used for multiplication
  • + RR -- see + -- a unary or binary operator, usually used for addition
  • QQ + RR -- see + -- a unary or binary operator, usually used for addition
  • RR + QQ -- see + -- a unary or binary operator, usually used for addition
  • RR + RR -- see + -- a unary or binary operator, usually used for addition
  • RR + ZZ -- see + -- a unary or binary operator, usually used for addition
  • ZZ + RR -- see + -- a unary or binary operator, usually used for addition
  • - RR -- see - -- a unary or binary operator, usually used for negation or subtraction
  • QQ - RR -- see - -- a unary or binary operator, usually used for negation or subtraction
  • RR - QQ -- see - -- a unary or binary operator, usually used for negation or subtraction
  • RR - RR -- see - -- a unary or binary operator, usually used for negation or subtraction
  • RR - ZZ -- see - -- a unary or binary operator, usually used for negation or subtraction
  • ZZ - RR -- see - -- a unary or binary operator, usually used for negation or subtraction
  • QQ / RR -- see / -- a binary operator, usually used for division
  • RR / QQ -- see / -- a binary operator, usually used for division
  • RR / RR -- see / -- a binary operator, usually used for division
  • RR / ZZ -- see / -- a binary operator, usually used for division
  • ZZ / RR -- see / -- a binary operator, usually used for division
  • acos(RR) -- see acos -- arccosine
  • agm(RR,RR) -- see agm -- arithmetic-geometric mean
  • asin(RR) -- see asin -- arcsine
  • atan(RR) -- see atan -- compute the arctangent of a number
  • atan2(RR,RR) -- see atan2 -- compute an angle of a certain triangle
  • Beta(RR,RR) -- see Beta -- Beta function
  • cos(RR) -- see cos -- compute the cosine
  • cosh(RR) -- see cosh -- compute the hyperbolic cosine
  • cot(RR) -- see cot -- cotangent
  • coth(RR) -- see coth -- hyperbolic cotangent
  • csc(RR) -- see csc -- cosecant
  • csch(RR) -- see csch -- hyperbolic cosecant
  • Digamma(RR) -- see Digamma -- Digamma function
  • eint(RR) -- see eint -- exponential integral
  • erf(RR) -- see erf -- error function
  • erfc(RR) -- see erfc -- complementary error function
  • exp(RR) -- see exp -- exponential function
  • expm1(RR) -- see expm1 -- exponential minus 1
  • Gamma(RR) -- see Gamma -- Gamma function
  • Gamma(RR,RR) -- see Gamma -- Gamma function
  • inverseErf(RR) -- see inverseErf -- inverse error function
  • inverseRegularizedBeta(RR,RR,RR) -- see inverseRegularizedBeta -- inverse of the regularized beta function
  • inverseRegularizedGamma(RR,RR) -- see inverseRegularizedGamma -- inverse of the upper regularized gamma function
  • log(RR) -- see log -- logarithm function
  • log1p(RR) -- see log1p -- logarithm of 1+x
  • random(RR) -- see random(ZZ,ZZ) -- get a random integer or real number
  • regularizedBeta(RR,RR,RR) -- see regularizedBeta -- regularized beta function
  • regularizedGamma(RR,RR) -- see regularizedGamma -- upper regularized gamma function
  • sec(RR) -- see sec -- secant
  • sech(RR) -- see sech -- hyperbolic secant
  • sin(RR) -- see sin -- compute the sine
  • sinh(RR) -- see sinh -- compute the hyperbolic sine
  • tan(RR) -- see tan -- compute the tangent
  • tanh(RR) -- see tanh -- compute the hyperbolic tangent
  • zeta(RR) -- see zeta -- Riemann zeta function

Methods that use a real number:

  • RR ! -- see ! -- factorial
  • CC % RR -- see % -- a binary operator, usually used for remainder and reduction
  • RR % QQ -- see % -- a binary operator, usually used for remainder and reduction
  • RR % RR -- see % -- a binary operator, usually used for remainder and reduction
  • RR % ZZ -- see % -- a binary operator, usually used for remainder and reduction
  • CC * RR -- see * -- a binary operator, usually used for multiplication
  • RR * CC -- see * -- a binary operator, usually used for multiplication
  • RR * RRi -- see * -- a binary operator, usually used for multiplication
  • RRi * RR -- see * -- a binary operator, usually used for multiplication
  • CC + RR -- see + -- a unary or binary operator, usually used for addition
  • RR + CC -- see + -- a unary or binary operator, usually used for addition
  • RR + RRi -- see + -- a unary or binary operator, usually used for addition
  • RRi + RR -- see + -- a unary or binary operator, usually used for addition
  • CC - RR -- 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
  • RR - RRi -- see - -- a unary or binary operator, usually used for negation or subtraction
  • RRi - RR -- see - -- a unary or binary operator, usually used for negation or subtraction
  • CC / RR -- see / -- a binary operator, usually used for division
  • RR / CC -- see / -- a binary operator, usually used for division
  • RR / RRi -- see / -- a binary operator, usually used for division
  • RRi / RR -- see / -- a binary operator, usually used for division
  • CC // RR -- see // -- a binary operator, usually used for quotient
  • RR // QQ -- see // -- a binary operator, usually used for quotient
  • RR // RR -- see // -- a binary operator, usually used for quotient
  • RR // ZZ -- see // -- a binary operator, usually used for quotient
  • abs(RR) -- see abs -- absolute value function
  • agm(CC,RR) -- see agm -- arithmetic-geometric mean
  • agm(RR,CC) -- see agm -- arithmetic-geometric mean
  • atan2(RR,RRi) -- see atan2 -- compute an angle of a certain triangle
  • atan2(RRi,RR) -- see atan2 -- compute an angle of a certain triangle
  • Beta(CC,RR) -- see Beta -- Beta function
  • Beta(RR,CC) -- see Beta -- Beta function
  • Beta(RR,RRi) -- see Beta -- Beta function
  • Beta(RRi,RR) -- see Beta -- Beta function
  • clean(RR,Matrix) -- see clean -- set to zero elements that are approximately zero
  • clean(RR,MutableMatrix) -- see clean -- set to zero elements that are approximately zero
  • clean(RR,Number) -- see clean -- set to zero elements that are approximately zero
  • clean(RR,RingElement) -- see clean -- set to zero elements that are approximately zero
  • format(RR) -- see format -- format a string or real number
  • Gamma(CC,RR) -- see Gamma -- Gamma function
  • Gamma(RR,CC) -- see Gamma -- Gamma function
  • Gamma(RR,RRi) -- see Gamma -- Gamma function
  • Gamma(RRi,RR) -- see Gamma -- Gamma function
  • interval(QQ,RR) -- see interval -- construct an interval
  • interval(RR) -- see interval -- construct an interval
  • interval(RR,QQ) -- see interval -- construct an interval
  • interval(RR,RR) -- see interval -- construct an interval
  • interval(RR,ZZ) -- see interval -- construct an interval
  • interval(ZZ,RR) -- see interval -- construct an interval
  • isMember(RR,RRi) -- see isMember(QQ,RRi) -- membership test in an interval
  • isReal(RR) -- see isReal -- whether a number is real
  • RR << ZZ -- see left shift
  • lift(RR,type of QQ) -- see lift -- lift to another ring
  • lift(RR,type of ZZ) -- see lift -- lift to another ring
  • lngamma(RR) -- see lngamma -- logarithm of the Gamma function
  • log(RR,CC) -- see log -- logarithm function
  • log(RR,RR) -- see log -- logarithm function
  • log(RR,RRi) -- see log -- logarithm function
  • log(RRi,RR) -- see log -- logarithm function
  • norm(RR,Matrix) -- see norm
  • norm(RR,MutableMatrix) -- see norm
  • norm(RR,Number) -- see norm
  • norm(RR,RingElement) -- see norm
  • numeric(RR) -- see numeric -- convert to floating point
  • promote(RR,type of QQ) -- see promote -- promote to another ring
  • random(RR,RR) -- see random(ZZ,ZZ) -- get a random integer or real number
  • randomMutableMatrix(ZZ,ZZ,RR,ZZ) -- a random mutable matrix of integers
  • regularizedBeta(CC,CC,RR) -- see regularizedBeta -- regularized beta function
  • regularizedBeta(CC,RR,CC) -- see regularizedBeta -- regularized beta function
  • regularizedBeta(CC,RR,RR) -- see regularizedBeta -- regularized beta function
  • regularizedBeta(RR,CC,CC) -- see regularizedBeta -- regularized beta function
  • regularizedBeta(RR,CC,RR) -- see regularizedBeta -- regularized beta function
  • regularizedBeta(RR,RR,CC) -- see regularizedBeta -- regularized beta function
  • regularizedBeta(RR,RR,RRi) -- see regularizedBeta -- regularized beta function
  • regularizedBeta(RR,RRi,RR) -- see regularizedBeta -- regularized beta function
  • regularizedBeta(RR,RRi,RRi) -- see regularizedBeta -- regularized beta function
  • regularizedBeta(RRi,RR,RR) -- see regularizedBeta -- regularized beta function
  • regularizedBeta(RRi,RR,RRi) -- see regularizedBeta -- regularized beta function
  • regularizedBeta(RRi,RRi,RR) -- see regularizedBeta -- regularized beta function
  • regularizedGamma(CC,RR) -- see regularizedGamma -- upper regularized gamma function
  • regularizedGamma(RR,CC) -- see regularizedGamma -- upper regularized gamma function
  • regularizedGamma(RR,RRi) -- see regularizedGamma -- upper regularized gamma function
  • regularizedGamma(RRi,RR) -- see regularizedGamma -- upper regularized gamma function
  • RR >> ZZ -- see right shift
  • ring(RR) -- see ring -- get the associated ring of an object
  • round(ZZ,RR) -- see round -- round a number
  • size2(RR) -- see size2 -- number of binary digits to the left of the point
  • sqrt(RR) -- see sqrt -- square root function
  • toCC(RR) -- see toCC -- convert to high-precision complex number
  • toCC(RR,RR) -- see toCC -- convert to high-precision complex number
  • toCC(ZZ,QQ,RR) -- 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,RR) -- see toCC -- convert to high-precision complex number

For the programmer

The object RR is an inexact field family, with ancestor classes InexactNumber < Number < Thing.


The source of this document is in Macaulay2Doc/ov_rings.m2:254:0.