prodigy.distribution.exact_division

Exact division of a variable with infinite marginal by a natural number.

The update target := numerator / q is only defined if numerator is a multiple of q in every state. For an infinite marginal this cannot be checked state by state. If the generating function is rational in numerator, it can be decided exactly:

Write f = P / Q with polynomials P and Q in x = numerator and let D(y) = Res_t(t^q - y, Q(t)), so that D(x^q) is the product of Q(w x) over all q-th roots of unity w. Q divides D(x^q), hence f = N(x) / D(x^q) for the polynomial N = P D(x^q) / Q. As 1 / D(x^q) only has exponents of x that are multiples of q, the exponents of x in f are all multiples of q if and only if those of N are. In that case f with x^k replaced by x^k target^(k/q) is N(x) with x^(qk) replaced by x^(qk) target^k, divided by D(x^q target).

The computation is engine independent and works on SymPy expressions.

divide_exponents(function, numerator, target, divisor)[source]

The generating function after the update target := numerator / divisor, or None if it is not proven that numerator is a multiple of divisor in every state. The result is None as well if function is not rational in numerator; the caller has to reject the update then.

Parameters:
Return type:

Expr | None