Goulib.polynomial module¶
simple manipulation of polynomials (without SimPy) see http://docs.sympy.org/dev/modules/polys/reference.html if you need more ...
-
class
Goulib.polynomial.
Polynomial
(val)[source]¶ Bases:
Goulib.expr.Expr
Param: val can be: - an iterable of the factors in ascending powers order : Polynomial([1,2,3]) holds 3*x^2+2*x+1
- a string of the form “ax^n + b*x^m + ... + c x + d” where a,b,c,d, are floats and n,m ... are integers the ‘x’ variable name is fixed, and the spaces and ‘*’ chars are optional. terms can be in any order, and even “overlap” : Polynomial(‘3x+x^2-x’) holds x^2+2*x
-
__init__
(val)[source]¶ Param: val can be: - an iterable of the factors in ascending powers order : Polynomial([1,2,3]) holds 3*x^2+2*x+1
- a string of the form “ax^n + b*x^m + ... + c x + d” where a,b,c,d, are floats and n,m ... are integers the ‘x’ variable name is fixed, and the spaces and ‘*’ chars are optional. terms can be in any order, and even “overlap” : Polynomial(‘3x+x^2-x’) holds x^2+2*x
-
__and__
(right)¶
-
__call__
(x=None, **kwargs)¶ evaluate the Expr at x OR compose self(x())
-
__delattr__
¶ Implement delattr(self, name).
-
__dir__
() → list¶ default dir() implementation
-
__div__
(right)¶
-
__float__
()¶
-
__format__
()¶ default object formatter
-
__ge__
(other)¶
-
__getattribute__
¶ Return getattr(self, name).
-
__gt__
(other)¶
-
__hash__
= None¶
-
__invert__
()¶
-
__le__
(other)¶
-
__lshift__
(dx)¶
-
__ne__
(other)¶
-
__new__
()¶ Create and return a new object. See help(type) for accurate signature.
-
__or__
(right)¶
-
__reduce__
()¶ helper for pickle
-
__reduce_ex__
()¶ helper for pickle
-
__repr__
()¶
-
__rshift__
(dx)¶
-
__setattr__
¶ Implement setattr(self, name, value).
-
__sizeof__
() → int¶ size of object in memory, in bytes
-
__str__
()¶
-
__truediv__
(right)¶
-
__xor__
(right)¶
-
applx
(f, var='x')¶ function composition f o self = self(f(x))
-
apply
(f, right=None)¶ function composition self o f = f(self(x))
-
complexity
()¶ measures the complexity of Expr :return: int, sum of the precedence of used ops
-
html
(**kwargs)¶
-
isNum
¶
-
isconstant
¶ Returns: True if Expr evaluates to a constant number or bool
-
latex
()¶ Returns: string LaTex formula
-
plot
(**kwargs)¶ renders on IPython Notebook (alias to make usage more straightforward)
-
png
(**kwargs)¶
-
render
(fmt='svg', **kwargs)¶
-
save
(filename, **kwargs)¶
-
svg
(**kwargs)¶
-
Goulib.polynomial.
peval
(plist, x, x2=None)[source]¶ Eval the plist at value x. If two values are given, the difference between the second and the first is returned. This latter feature is included for the purpose of evaluating definite integrals.
-
Goulib.polynomial.
integral
(plist)[source]¶ Return a new plist corresponding to the integral of the input plist. This function uses zero as the constant term, which is okay when evaluating a definite integral, for example, but is otherwise ambiguous.
The math forces the coefficients to be turned into floats. Consider importing __future__ division to simplify this.
-
Goulib.polynomial.
derivative
(plist)[source]¶ Return a new plist corresponding to the derivative of the input plist.
-
Goulib.polynomial.
add
(p1, p2)[source]¶ Return a new plist corresponding to the sum of the two input plists.
-
Goulib.polynomial.
mult_const
(p, c)[source]¶ Return a new plist corresponding to the input plist multplied by a const
-
Goulib.polynomial.
multiply
(p1, p2)[source]¶ Return a new plist corresponding to the product of the two input plists
-
Goulib.polynomial.
mult_one
(p, c, i)[source]¶ Return a new plist corresponding to the product of the input plist p with the single term c*x^i
-
Goulib.polynomial.
power
(p, e)[source]¶ Return a new plist corresponding to the e-th power of the input plist p