Z3
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Member Functions
AlgebraicNumRef Class Reference
+ Inheritance diagram for AlgebraicNumRef:

Public Member Functions

def approx
 
def as_decimal
 
- Public Member Functions inherited from ArithRef
def sort
 
def is_int
 
def is_real
 
def __add__
 
def __radd__
 
def __mul__
 
def __rmul__
 
def __sub__
 
def __rsub__
 
def __pow__
 
def __rpow__
 
def __div__
 
def __truediv__
 
def __rdiv__
 
def __rtruediv__
 
def __mod__
 
def __rmod__
 
def __neg__
 
def __pos__
 
def __le__
 
def __lt__
 
def __gt__
 
def __ge__
 
- Public Member Functions inherited from ExprRef
def as_ast
 
def sort
 
def sort_kind
 
def __eq__
 
def __ne__
 
def decl
 
def num_args
 
def arg
 
def children
 
- Public Member Functions inherited from AstRef
def __init__
 
def __del__
 
def __str__
 
def __repr__
 
def sexpr
 
def as_ast
 
def ctx_ref
 
def eq
 
def translate
 
def hash
 
- Public Member Functions inherited from Z3PPObject
def use_pp
 

Additional Inherited Members

- Data Fields inherited from AstRef
 ast
 
 ctx
 

Detailed Description

Algebraic irrational values.

Definition at line 2469 of file z3py.py.

Member Function Documentation

def approx (   self,
  precision = 10 
)
Return a Z3 rational number that approximates the algebraic number `self`. 
The result `r` is such that |r - self| <= 1/10^precision 

>>> x = simplify(Sqrt(2))
>>> x.approx(20)
6838717160008073720548335/4835703278458516698824704
>>> x.approx(5)
2965821/2097152

Definition at line 2472 of file z3py.py.

2473  def approx(self, precision=10):
2474  """Return a Z3 rational number that approximates the algebraic number `self`.
2475  The result `r` is such that |r - self| <= 1/10^precision
2476 
2477  >>> x = simplify(Sqrt(2))
2478  >>> x.approx(20)
2479  6838717160008073720548335/4835703278458516698824704
2480  >>> x.approx(5)
2481  2965821/2097152
2482  """
return RatNumRef(Z3_get_algebraic_number_upper(self.ctx_ref(), self.as_ast(), precision), self.ctx)
def as_decimal (   self,
  prec 
)
Return a string representation of the algebraic number `self` in decimal notation using `prec` decimal places

>>> x = simplify(Sqrt(2))
>>> x.as_decimal(10)
'1.4142135623?'
>>> x.as_decimal(20)
'1.41421356237309504880?'

Definition at line 2483 of file z3py.py.

2484  def as_decimal(self, prec):
2485  """Return a string representation of the algebraic number `self` in decimal notation using `prec` decimal places
2486 
2487  >>> x = simplify(Sqrt(2))
2488  >>> x.as_decimal(10)
2489  '1.4142135623?'
2490  >>> x.as_decimal(20)
2491  '1.41421356237309504880?'
2492  """
2493  return Z3_get_numeral_decimal_string(self.ctx_ref(), self.as_ast(), prec)