ComputationEngineSymbolic

class poisson_approval.ComputationEngineSymbolic[source]

Computation engine: symbolic computation.

This engine relies on the external package sympy in order to perform symbolic computation:

>>> ce = ComputationEngineSymbolic
>>> ce.inf
oo
>>> ce.nan
nan
>>> ce.exp(3)
exp(3)
>>> ce.log(3)
log(3)
>>> ce.Rational(1, 3)
1/3
>>> ce.S(1) / 3
1/3
>>> ce.simplify(- ce.Rational(1, 10) - (- ce.sqrt(15) / 5 + ce.sqrt(30) / 10)**2)
-1 + 3*sqrt(2)/5
>>> ce.sqrt(3)
sqrt(3)

Usage of look_equal():

>>> ce.look_equal(1, 0.999999999999)
True
>>> ce.look_equal(1, np.float(0.999999999999))
True
>>> ce.look_equal(1, sp.Float(0.999999999999))
False
>>> ce.look_equal(1, Fraction(999999999999, 1000000000000))
False
>>> ce.look_equal(ce.sqrt(2), ce.Rational(14142135623730951, 10000000000000000))
False
classmethod Rational(x, y)[source]

Rational number. Should return a fraction, even in a numeric engine.

classmethod S(x)[source]

Convert the number if necessary.

Return a number that has the same value as x. Cf. function S of the package sympy.

classmethod barycenter(a, b, ratio_b)

Barycenter.

Cf. ComputationEngineNumeric.barycenter() for specifications and examples.

classmethod exp(x)[source]

Exponential.

classmethod factorial(x)[source]

Factorial.

inf = oo

Positive infinity.

classmethod log(x)[source]

Logarithm.

classmethod look_equal(x, y, *args, **kwargs)

Test if two numbers can reasonably be considered as equal.

Parameters
  • x (Number) –

  • y (Number) –

  • *args – Cf. math.isclose.

  • **kwargs – Cf. math.isclose.

Returns

If x or y is a float or numpy float (but not a sympy float), then return math.isclose(x, y, *args, **kwargs). In all other cases, return True iff x is equal to y.

Return type

bool

classmethod multiply_with_absorbing_zero(x, y)

Multiplication with absorbing zero.

Parameters
  • x (Number) –

  • y (Number) –

Returns

If x or y is 0, then 0 (even if the other input is nan). Otherwise, the product of x and y.

Return type

Number

nan = nan

Not a Number.

classmethod ones(*args, **kwargs)

Array of ones.

pi = pi

Pi.

classmethod simplify(x)[source]

Simplify the number if necessary.

Return a number that has the same value as x. Cf. function simplify of the package sympy.

classmethod simplify_vector(x)

Simplify the coefficients if necessary.

classmethod sqrt(x)[source]

Square root.

classmethod zeros(*args, **kwargs)

Array of zeros.