Real intervals with a fixed absolute precision#
- class sage.rings.real_interval_absolute.Factory#
Bases:
UniqueFactory
- create_key(prec)#
The only piece of data is the precision.
- create_object(version, prec)#
Ensures uniqueness.
- class sage.rings.real_interval_absolute.MpfrOp#
Bases:
object
This class is used to endow absolute real interval field elements with all the methods of (relative) real interval field elements.
EXAMPLES:
sage: from sage.rings.real_interval_absolute import RealIntervalAbsoluteField sage: R = RealIntervalAbsoluteField(100) sage: R(1).sin() 0.841470984807896506652502321631?
- class sage.rings.real_interval_absolute.RealIntervalAbsoluteElement#
Bases:
FieldElement
Create a
RealIntervalAbsoluteElement
.EXAMPLES:
sage: from sage.rings.real_interval_absolute import RealIntervalAbsoluteField sage: R = RealIntervalAbsoluteField(50) sage: R(1) 1 sage: R(1/3) 0.333333333333334? sage: R(1.3) 1.300000000000000? sage: R(pi) 3.141592653589794? sage: R((11, 12)) 12.? sage: R((11, 11.00001)) 11.00001? sage: R100 = RealIntervalAbsoluteField(100) sage: R(R100((5,6))) 6.? sage: R100(R((5,6))) 6.? sage: RIF(CIF(NaN)) [.. NaN ..]
- abs()#
Return the absolute value of
self
.EXAMPLES:
sage: from sage.rings.real_interval_absolute import RealIntervalAbsoluteField sage: R = RealIntervalAbsoluteField(100) sage: R(1/3).abs() 0.333333333333333333333333333334? sage: R(-1/3).abs() 0.333333333333333333333333333334? sage: R((-1/3, 1/2)).abs() 1.? sage: R((-1/3, 1/2)).abs().endpoints() (0, 1/2) sage: R((-3/2, 1/2)).abs().endpoints() (0, 3/2)
- absolute_diameter()#
Return the diameter
self
.EXAMPLES:
sage: from sage.rings.real_interval_absolute import RealIntervalAbsoluteField sage: R = RealIntervalAbsoluteField(10) sage: R(1/4).absolute_diameter() 0 sage: a = R(pi) sage: a.absolute_diameter() 1/1024 sage: a.upper() - a.lower() 1/1024
- contains_zero()#
Return whether
self
contains zero.EXAMPLES:
sage: from sage.rings.real_interval_absolute import RealIntervalAbsoluteField sage: R = RealIntervalAbsoluteField(10) sage: R(10).contains_zero() False sage: R((10,11)).contains_zero() False sage: R((0,11)).contains_zero() True sage: R((-10,11)).contains_zero() True sage: R((-10,-1)).contains_zero() False sage: R((-10,0)).contains_zero() True sage: R(pi).contains_zero() False
- diameter()#
Return the diameter
self
.EXAMPLES:
sage: from sage.rings.real_interval_absolute import RealIntervalAbsoluteField sage: R = RealIntervalAbsoluteField(10) sage: R(1/4).absolute_diameter() 0 sage: a = R(pi) sage: a.absolute_diameter() 1/1024 sage: a.upper() - a.lower() 1/1024
- endpoints()#
Return the left and right endpoints of
self
, as a tuple.EXAMPLES:
sage: from sage.rings.real_interval_absolute import RealIntervalAbsoluteField sage: R = RealIntervalAbsoluteField(10) sage: R(1/4).endpoints() (1/4, 1/4) sage: R((1,2)).endpoints() (1, 2)
- is_negative()#
Return whether
self
is definitely negative.EXAMPLES:
sage: from sage.rings.real_interval_absolute import RealIntervalAbsoluteField sage: R = RealIntervalAbsoluteField(100) sage: R(10).is_negative() False sage: R((10,11)).is_negative() False sage: R((0,11)).is_negative() False sage: R((-10,11)).is_negative() False sage: R((-10,-1)).is_negative() True sage: R(pi).is_negative() False
- is_positive()#
Return whether
self
is definitely positive.EXAMPLES:
sage: from sage.rings.real_interval_absolute import RealIntervalAbsoluteField sage: R = RealIntervalAbsoluteField(10) sage: R(10).is_positive() True sage: R((10,11)).is_positive() True sage: R((0,11)).is_positive() False sage: R((-10,11)).is_positive() False sage: R((-10,-1)).is_positive() False sage: R(pi).is_positive() True
- lower()#
Return the lower bound of
self
.EXAMPLES:
sage: from sage.rings.real_interval_absolute import RealIntervalAbsoluteField sage: R = RealIntervalAbsoluteField(50) sage: R(1/4).lower() 1/4
- midpoint()#
Return the midpoint of
self
.EXAMPLES:
sage: from sage.rings.real_interval_absolute import RealIntervalAbsoluteField sage: R = RealIntervalAbsoluteField(100) sage: R(1/4).midpoint() 1/4 sage: R(pi).midpoint() 7964883625991394727376702227905/2535301200456458802993406410752 sage: R(pi).midpoint().n() 3.14159265358979
- mpfi_prec()#
Return the precision needed to represent this value as an mpfi interval.
EXAMPLES:
sage: from sage.rings.real_interval_absolute import RealIntervalAbsoluteField sage: R = RealIntervalAbsoluteField(10) sage: R(10).mpfi_prec() 14 sage: R(1000).mpfi_prec() 20
- sqrt()#
Return the square root of
self
.EXAMPLES:
sage: from sage.rings.real_interval_absolute import RealIntervalAbsoluteField sage: R = RealIntervalAbsoluteField(100) sage: R(2).sqrt() 1.414213562373095048801688724210? sage: R((4,9)).sqrt().endpoints() (2, 3)
- upper()#
Return the upper bound of
self
.EXAMPLES:
sage: from sage.rings.real_interval_absolute import RealIntervalAbsoluteField sage: R = RealIntervalAbsoluteField(50) sage: R(1/4).upper() 1/4
- sage.rings.real_interval_absolute.RealIntervalAbsoluteField(*args, **kwds)#
This field is similar to the
RealIntervalField
except instead of truncating everything to a fixed relative precision, it maintains a fixed absolute precision.Note that unlike the standard real interval field, elements in this field can have different size and experience coefficient blowup. On the other hand, it avoids precision loss on addition and subtraction. This is useful for, e.g., series computations for special functions.
EXAMPLES:
sage: from sage.rings.real_interval_absolute import RealIntervalAbsoluteField sage: R = RealIntervalAbsoluteField(10); R Real Interval Field with absolute precision 2^-10 sage: R(3/10) 0.300? sage: R(1000003/10) 100000.300? sage: R(1e100) + R(1) - R(1e100) 1
- class sage.rings.real_interval_absolute.RealIntervalAbsoluteField_class#
Bases:
Field
This field is similar to the
RealIntervalField
except instead of truncating everything to a fixed relative precision, it maintains a fixed absolute precision.Note that unlike the standard real interval field, elements in this field can have different size and experience coefficient blowup. On the other hand, it avoids precision loss on addition and subtraction. This is useful for, e.g., series computations for special functions.
EXAMPLES:
sage: from sage.rings.real_interval_absolute import RealIntervalAbsoluteField sage: R = RealIntervalAbsoluteField(10); R Real Interval Field with absolute precision 2^-10 sage: R(3/10) 0.300? sage: R(1000003/10) 100000.300? sage: R(1e100) + R(1) - R(1e100) 1
- absprec()#
Returns the absolute precision of self.
EXAMPLES:
sage: from sage.rings.real_interval_absolute import RealIntervalAbsoluteField sage: R = RealIntervalAbsoluteField(100) sage: R.absprec() 100 sage: RealIntervalAbsoluteField(5).absprec() 5
- sage.rings.real_interval_absolute.shift_ceil(x, shift)#
Return \(x / 2^s\) where \(s\) is the value of
shift
, rounded towards \(+\infty\). For internal use.EXAMPLES:
sage: from sage.rings.real_interval_absolute import shift_ceil sage: shift_ceil(15, 2) 4 sage: shift_ceil(-15, 2) -3 sage: shift_ceil(32, 2) 8 sage: shift_ceil(-32, 2) -8
- sage.rings.real_interval_absolute.shift_floor(x, shift)#
Return \(x / 2^s\) where \(s\) is the value of
shift
, rounded towards \(-\infty\). For internal use.EXAMPLES:
sage: from sage.rings.real_interval_absolute import shift_floor sage: shift_floor(15, 2) 3 sage: shift_floor(-15, 2) -4