bertini.symbolics¶
The symbolic expression system for building polynomial systems – a FLAT namespace.
Renamed from function_tree (the underlying C++ module keeps that name). Everything lives
directly here, with no .symbol / .operator / .root sub-levels:
operator node types –
Sum,Mult,Power,Sqrt, … (for inspecting/walking expression trees)roots –
NamedExpression
plus variables(), sqrt(), and VariableGroup.
- class bertini.symbolics.AbstractNode¶
Bases:
instanceRaises an exception This class cannot be instantiated from Python
- __init__()¶
Raises an exception This class cannot be instantiated from Python
- degree((AbstractNode)self) int :¶
compute the algebraic degree of node in a function tree, with respect to all variables. returns one integer. negative is non-algebraic.
- degree( (AbstractNode)self, (bertini._pybertini.function_tree.symbol.Variable)var) -> int :
compute the algebraic degree of node in a function tree, with respect to a particular variable. returns one integer. negative is non-algebraic.
- degree( (AbstractNode)self, (bertini._pybertini.container.VariableGroup)vars) -> int :
compute the algebraic degree of node in a function tree, with respect to a variable group. returns one integer. negative is non-algebraic.
- differentiate((AbstractNode)self) AbstractNode :¶
differentiate a node. is with respect to all variables. you get a Jacobian back, which represents derivatives wrt all variables simultaneously.
- differentiate( (AbstractNode)arg1, (bertini._pybertini.function_tree.symbol.Variable)self) -> AbstractNode :
differentiate a node with respect to one variable. You get a regular old Node in a Function Tree back.
- differentiate( (AbstractNode)self, (bertini._pybertini.function_tree.symbol.Variable)var, (int)count) -> AbstractNode :
differentiate a node with respect to one variable, count times (e.g. n.differentiate(x, 2) for the second partial). count=0 returns the node itself. You get a regular Node back.
- differentiate( (AbstractNode)self, (bertini._pybertini.container.VariableGroup)vars) -> AbstractNode :
differentiate a node with respect to each variable in vars, in sequence – a mixed partial (e.g. n.differentiate([x, x, y])). Repeated entries are allowed; an empty list returns the node itself. You get a regular Node back.
- eval()¶
- object eval(tuple args, dict kwds) :
evaluate this expression at a point, returning a complex_mp. No System is needed. Forms: keyword args f.eval(x=2, y=5); a dict f.eval({x: 2, y: 5}) (keys may be Variables or name strings); or a 1-D array/list f.eval(pt) mapped in order to the expression’s variables() (sorted by name) – override the ordering with a second positional argument or variables=, e.g. f.eval(pt, [x, y, z]) or f.eval(pt, variables=[x, y, z]). By default (strict=False) supplied variables the expression does not depend on are ignored (it is constant with respect to them), so one full point can be reused across an expression and its derivatives; pass strict=True to reject such extras as typos. A missing value for a variable the expression DOES depend on always raises. Evaluation is at the current default precision; native Python floats carry only float64 of information.
- homogenized((AbstractNode)self, (bertini._pybertini.container.VariableGroup)vars, (bertini._pybertini.function_tree.symbol.Variable)homvar) AbstractNode :¶
Return a NEW homogenized copy of this function tree (non-mutating) with respect to the variables in vars using the homogenizing variable homvar. Degree-deficient terms are padded with powers of homvar so all terms share the same degree. The original tree is left untouched.
- is_homogeneous((AbstractNode)self) bool :¶
test if this Node is homogeneous with respect to all Variables.
- is_homogeneous( (AbstractNode)self, (bertini._pybertini.function_tree.symbol.Variable)var) -> bool :
test if this Node is homogeneous with respect to Variable var.
- is_homogeneous( (AbstractNode)self, (bertini._pybertini.container.VariableGroup)vars) -> bool :
test if this Node is homogeneous with respect to the Variables in vars.
- is_polynomial((AbstractNode)self) bool :¶
test if this Node is polynomial with respect to all Variables.
- is_polynomial( (AbstractNode)self, (bertini._pybertini.function_tree.symbol.Variable)var) -> bool :
test if this Node is polynomial with respect to Variable var.
- is_polynomial( (AbstractNode)self, (bertini._pybertini.container.VariableGroup)vars) -> bool :
test if this Node is polynomial with respect to Variables vars.
- multidegree((AbstractNode)self, (bertini._pybertini.container.VariableGroup)vars) bertini._pybertini.container.ListOfInt :¶
Compute an integer vector containing the degrees with respect to the variables in vars. Negative entries indicate non-polynomiality
- simplify((AbstractNode)self) AbstractNode :¶
Return a NEW, functionally simplified copy of this expression (non-mutating): literal zeros/ones vanish and exact constants fold, including constant powers – so (3**2) simplifies to 9 and i**2 (i = Complex(0,1)) to -1. The original is left untouched.
- subs()¶
- object subs(tuple args, dict kwds) :
symbolically substitute variables, returning a NEW expression. Forms: keyword args f.subs(x=3, y=5); a dict f.subs({x: 3, y: z**2}) (keys may be Variables or name strings); or a single variable and its value f.subs(x, z**2). Values may be nodes (a Variable or any expression) or numbers (int -> Integer, fractions.Fraction -> Rational, else Complex). Substitution is simultaneous and single-pass – {x: y, y: z} maps x+y to y+z (no cascade), and the order is irrelevant; a variable not named is left unchanged. Only variables are substituted (not subexpressions), and the result is simplified.
- variables((AbstractNode)self) bertini._pybertini.container.VariableGroup :¶
The distinct variables appearing in this expression, sorted by name.
- class bertini.symbolics.MonomialOrder¶
Bases:
enumthe monomial order used to canonically order Sum/Mult operands
- GrevLex = bertini._pybertini.function_tree.MonomialOrder.GrevLex¶
- Lex = bertini._pybertini.function_tree.MonomialOrder.Lex¶
- RevLex = bertini._pybertini.function_tree.MonomialOrder.RevLex¶
- names = {'GrevLex': bertini._pybertini.function_tree.MonomialOrder.GrevLex, 'Lex': bertini._pybertini.function_tree.MonomialOrder.Lex, 'RevLex': bertini._pybertini.function_tree.MonomialOrder.RevLex}¶
- values = {0: bertini._pybertini.function_tree.MonomialOrder.Lex, 1: bertini._pybertini.function_tree.MonomialOrder.RevLex, 2: bertini._pybertini.function_tree.MonomialOrder.GrevLex}¶
- bertini.symbolics.acos((AbstractNode)arg1) AbstractNode :¶
the symbolic arccosine operator
- bertini.symbolics.asin((AbstractNode)arg1) AbstractNode :¶
the symbolic arcsine operator
- bertini.symbolics.atan((AbstractNode)arg1) AbstractNode :¶
the symbolic arctangent operator
- bertini.symbolics.canonicalize() bool :¶
whether Sum/Mult operands are canonically ordered, so x+y and y+x are one node
- canonicalize( (bool)on) -> None :
enable/disable canonical operand ordering, session-global (the per-expression opt-out)
- bertini.symbolics.cos((AbstractNode)arg1) AbstractNode :¶
the symbolic cosine operator
- bertini.symbolics.exp((AbstractNode)arg1) AbstractNode :¶
the symbolic exponential operator
- bertini.symbolics.gather_variables((bertini._pybertini.container.ListOfNode)functions) bertini._pybertini.container.VariableGroup :¶
Return the distinct variables appearing in a list of functions, ordered alphabetically by name.
- gather_variables( (AbstractNode)node) -> bertini._pybertini.container.VariableGroup :
Return the distinct variables appearing in an expression, ordered alphabetically by name.
- bertini.symbolics.log((AbstractNode)arg1) AbstractNode :¶
the symbolic natural log operator
- bertini.symbolics.monomial_order() MonomialOrder :¶
the current monomial order used for canonicalization
- monomial_order( (MonomialOrder)order) -> None :
set the monomial order (Lex/RevLex/GrevLex), session-global
- bertini.symbolics.sin((AbstractNode)arg1) AbstractNode :¶
the symbolic sine operator
- bertini.symbolics.tan((AbstractNode)arg1) AbstractNode :¶
the symbolic tangent operator
- class bertini.symbolics.Complex((object)arg1, (bertini._pybertini.multiprec.real_mp)arg2, (bertini._pybertini.multiprec.real_mp)arg3) object¶
Bases:
AbstractNumberA complex-number literal node in an expression tree. Holds a full arbitrary-precision complex value (a real literal is just zero imaginary part). Build it as Complex(real) or Complex(real, imag) from exact strings/multiprec values; prefer Integer or Rational for exact non-irrational coefficients.
__init__( (object)arg1, (str)arg2) -> object
__init__( (object)arg1, (str)arg2, (str)arg3) -> object
__init__( (object)arg1, (bertini._pybertini.multiprec.complex_mp)arg2) -> object
- __init__((object)arg1, (bertini._pybertini.multiprec.real_mp)arg2, (bertini._pybertini.multiprec.real_mp)arg3) object¶
__init__( (object)arg1, (str)arg2) -> object
__init__( (object)arg1, (str)arg2, (str)arg3) -> object
__init__( (object)arg1, (bertini._pybertini.multiprec.complex_mp)arg2) -> object
- value((Complex)arg1) bertini._pybertini.multiprec.complex_mp :¶
the literal value this node represents, at its stored (highest) precision
- class bertini.symbolics.E((object)arg1) object¶
Bases:
AbstractNumber- __init__((object)arg1) object¶
- property name¶
None( (bertini._pybertini.function_tree.symbol.E)arg1) -> str
- class bertini.symbolics.Integer((object)arg1, (int)arg2) object¶
Bases:
AbstractNumber__init__( (object)arg1, (bertini._pybertini.multiprec.int_mp)arg2) -> object
__init__( (object)arg1, (str)arg2) -> object
- __init__((object)arg1, (int)arg2) object¶
__init__( (object)arg1, (bertini._pybertini.multiprec.int_mp)arg2) -> object
__init__( (object)arg1, (str)arg2) -> object
- value((Integer)arg1) bertini._pybertini.multiprec.int_mp :¶
the literal value this node represents
- class bertini.symbolics.Pi((object)arg1) object¶
Bases:
AbstractNumber- __init__((object)arg1) object¶
- property name¶
None( (bertini._pybertini.function_tree.symbol.Pi)arg1) -> str
- class bertini.symbolics.Rational((object)arg1, (int)arg2) object¶
Bases:
AbstractNumber__init__( (object)arg1, (int)arg2, (int)arg3, (int)arg4, (int)arg5) -> object
__init__( (object)arg1, (str)arg2) -> object
__init__( (object)arg1, (str)arg2, (str)arg3) -> object
__init__( (object)arg1, (bertini._pybertini.multiprec.rational_mp)arg2, (bertini._pybertini.multiprec.rational_mp)arg3) -> object
- __init__((object)arg1, (int)arg2) object¶
__init__( (object)arg1, (int)arg2, (int)arg3, (int)arg4, (int)arg5) -> object
__init__( (object)arg1, (str)arg2) -> object
__init__( (object)arg1, (str)arg2, (str)arg3) -> object
__init__( (object)arg1, (bertini._pybertini.multiprec.rational_mp)arg2, (bertini._pybertini.multiprec.rational_mp)arg3) -> object
- value_imag((Rational)arg1) bertini._pybertini.multiprec.rational_mp :¶
the imaginary part of the literal value this node represents
- value_real((Rational)arg1) bertini._pybertini.multiprec.rational_mp :¶
the real part of the literal value this node represents
- class bertini.symbolics.Variable((object)arg1, (str)arg2) object¶
Bases:
AbstractNamedSymbol- __init__((object)arg1, (str)arg2) object¶
- class bertini.symbolics.ArcCos((object)arg1, (bertini._pybertini.function_tree.AbstractNode)arg2) object¶
-
- __init__((object)arg1, (bertini._pybertini.function_tree.AbstractNode)arg2) object¶
- class bertini.symbolics.ArcSin((object)arg1, (bertini._pybertini.function_tree.AbstractNode)arg2) object¶
-
- __init__((object)arg1, (bertini._pybertini.function_tree.AbstractNode)arg2) object¶
- class bertini.symbolics.ArcTan((object)arg1, (bertini._pybertini.function_tree.AbstractNode)arg2) object¶
-
- __init__((object)arg1, (bertini._pybertini.function_tree.AbstractNode)arg2) object¶
- class bertini.symbolics.Cos((object)arg1, (bertini._pybertini.function_tree.AbstractNode)arg2) object¶
-
- __init__((object)arg1, (bertini._pybertini.function_tree.AbstractNode)arg2) object¶
- class bertini.symbolics.Exp((object)arg1, (bertini._pybertini.function_tree.AbstractNode)arg2) object¶
Bases:
Unary- __init__((object)arg1, (bertini._pybertini.function_tree.AbstractNode)arg2) object¶
- class bertini.symbolics.IntegerPower((object)arg1, (bertini._pybertini.function_tree.AbstractNode)arg2, (int)arg3) object¶
Bases:
Unary- __init__((object)arg1, (bertini._pybertini.function_tree.AbstractNode)arg2, (int)arg3) object¶
- property exponent¶
None( (bertini._pybertini.function_tree.operator.IntegerPower)arg1) -> int
- class bertini.symbolics.Log((object)arg1, (bertini._pybertini.function_tree.AbstractNode)arg2) object¶
Bases:
Unary- __init__((object)arg1, (bertini._pybertini.function_tree.AbstractNode)arg2) object¶
- class bertini.symbolics.Mult((object)arg1, (bertini._pybertini.function_tree.AbstractNode)arg2, (bertini._pybertini.function_tree.AbstractNode)arg3) object¶
Bases:
Nary__init__( (object)arg1, (bertini._pybertini.function_tree.AbstractNode)arg2, (bool)arg3, (bertini._pybertini.function_tree.AbstractNode)arg4, (bool)arg5) -> object
- __init__((object)arg1, (bertini._pybertini.function_tree.AbstractNode)arg2, (bertini._pybertini.function_tree.AbstractNode)arg3) object¶
__init__( (object)arg1, (bertini._pybertini.function_tree.AbstractNode)arg2, (bool)arg3, (bertini._pybertini.function_tree.AbstractNode)arg4, (bool)arg5) -> object
- add_operand((Mult)arg1, (bertini._pybertini.function_tree.AbstractNode)arg2, (bool)arg3) None¶
- mult_or_div((Mult)self, (int)index) bool :¶
the operation for the operand at the given index: True if multiplied, False if divided
- class bertini.symbolics.Nary¶
Bases:
AbstractOpRaises an exception This class cannot be instantiated from Python
- __init__()¶
Raises an exception This class cannot be instantiated from Python
- add_operand((Nary)arg1, (bertini._pybertini.function_tree.AbstractNode)arg2) None¶
- first_operand((Nary)arg1) bertini._pybertini.function_tree.AbstractNode¶
- num_operands((Nary)arg1) int¶
- operand((Nary)self, (int)index) bertini._pybertini.function_tree.AbstractNode :¶
get the operand at the given index; see num_operands
- class bertini.symbolics.Negate((object)arg1, (bertini._pybertini.function_tree.AbstractNode)arg2) object¶
Bases:
Unary- __init__((object)arg1, (bertini._pybertini.function_tree.AbstractNode)arg2) object¶
- class bertini.symbolics.Power((object)arg1, (bertini._pybertini.function_tree.AbstractNode)arg2, (bertini._pybertini.function_tree.AbstractNode)arg3) object¶
Bases:
AbstractOp- __init__((object)arg1, (bertini._pybertini.function_tree.AbstractNode)arg2, (bertini._pybertini.function_tree.AbstractNode)arg3) object¶
- get_base((Power)self) bertini._pybertini.function_tree.AbstractNode :¶
get the base node
- get_exponent((Power)self) bertini._pybertini.function_tree.AbstractNode :¶
get the exponent node
- set_base((Power)arg1, (bertini._pybertini.function_tree.AbstractNode)arg2) None¶
- set_exponent((Power)arg1, (bertini._pybertini.function_tree.AbstractNode)arg2) None¶
- class bertini.symbolics.Sin((object)arg1, (bertini._pybertini.function_tree.AbstractNode)arg2) object¶
-
- __init__((object)arg1, (bertini._pybertini.function_tree.AbstractNode)arg2) object¶
- class bertini.symbolics.Sqrt((object)arg1, (bertini._pybertini.function_tree.AbstractNode)arg2) object¶
Bases:
Unary- __init__((object)arg1, (bertini._pybertini.function_tree.AbstractNode)arg2) object¶
- class bertini.symbolics.Sum((object)arg1, (bertini._pybertini.function_tree.AbstractNode)arg2, (bertini._pybertini.function_tree.AbstractNode)arg3) object¶
Bases:
Nary__init__( (object)arg1, (bertini._pybertini.function_tree.AbstractNode)arg2, (bool)arg3, (bertini._pybertini.function_tree.AbstractNode)arg4, (bool)arg5) -> object
- __init__((object)arg1, (bertini._pybertini.function_tree.AbstractNode)arg2, (bertini._pybertini.function_tree.AbstractNode)arg3) object¶
__init__( (object)arg1, (bertini._pybertini.function_tree.AbstractNode)arg2, (bool)arg3, (bertini._pybertini.function_tree.AbstractNode)arg4, (bool)arg5) -> object
- add_operand((Sum)arg1, (bertini._pybertini.function_tree.AbstractNode)arg2, (bool)arg3) None¶
- sign((Sum)self, (int)index) bool :¶
the sign of the operand at the given index: True if added, False if subtracted
- class bertini.symbolics.Tan((object)arg1, (bertini._pybertini.function_tree.AbstractNode)arg2) object¶
-
- __init__((object)arg1, (bertini._pybertini.function_tree.AbstractNode)arg2) object¶
- class bertini.symbolics.Trig¶
Bases:
AbstractNodeRaises an exception This class cannot be instantiated from Python
- __init__()¶
Raises an exception This class cannot be instantiated from Python
- class bertini.symbolics.Unary¶
Bases:
AbstractOpRaises an exception This class cannot be instantiated from Python
- __init__()¶
Raises an exception This class cannot be instantiated from Python
- operand((Unary)arg1) bertini._pybertini.function_tree.AbstractNode¶
- set_operand((Unary)arg1, (bertini._pybertini.function_tree.AbstractNode)arg2) None¶
- class bertini.symbolics.NamedExpression((object)arg1, (bertini._pybertini.function_tree.AbstractNode)arg2, (str)arg3) object¶
Bases:
AbstractNamedSymbol- __init__((object)arg1, (bertini._pybertini.function_tree.AbstractNode)arg2, (str)arg3) object¶
- root((NamedExpression)self) bertini._pybertini.function_tree.AbstractNode :¶
the defining expression this name stands for
- class bertini.symbolics.VariableGroup((object)arg1)¶
Bases:
instance__init__( (object)arg1, (object)arg2) -> object
- __init__( (object)arg1, (str)arg2, (int)arg3) -> object :
VariableGroup(name, count): the variables name0, name1, …, name{count-1}
- __init__((object)arg1) None¶
__init__( (object)arg1, (object)arg2) -> object
- __init__( (object)arg1, (str)arg2, (int)arg3) -> object :
VariableGroup(name, count): the variables name0, name1, …, name{count-1}
- append((VariableGroup)arg1, (object)arg2) None¶
- extend((VariableGroup)arg1, (object)arg2) None¶
- bertini.symbolics.variables(base, indices=None, fmt='{base}{index}')[source]¶
Make a list of Variables.
Two forms:
# explicit names -- pass a list/tuple of names as the sole argument: x, y, z = bertini.variables(['x', 'y', 'z']) # integer-indexed -- a name prefix + a count (or an iterable of indices): v = bertini.variables('v', 3) # -> [v0, v1, v2]
- Parameters:
base (str or iterable of str) – A name prefix (with
indices), OR – whenindicesis omitted – an iterable of the explicit variable names.indices (int or iterable of int, optional) – An int
n(shorthand forrange(n)) or any iterable of ints. Omit to use the explicit-names form.fmt (str) –
str.formattemplate using{base}and{index}; default'{base}{index}'givesx0, x1, x2, ....desired:: (Returns a list[Variable]. Wrap in a VariableGroup if) – pb.VariableGroup(pb.variables(‘x’, 5))
- bertini.symbolics.random_real()[source]¶
A random real number as a constant node (a real
Complexleaf, imaginary part 0).The always-symbolic shortcut for
bertini.random_real(symbolic=True)– a random real coefficient to drop straight into an expression, at the current default precision (setbertini.default_precisionfirst for more digits). For a precision-independent exact random constant useRational.rand_real()instead.
- bertini.symbolics.random_complex()[source]¶
A random complex number as a constant node (a
Complexleaf).The always-symbolic shortcut for
bertini.random_complex(symbolic=True)– a random complex coefficient to drop straight into an expression, at the current default precision (setbertini.default_precisionfirst for more digits). For a precision-independent exact random constant useRational.rand()instead.