plumial.core.D._D.r

_D.r()[source]

Calculate the remainder: c() * o() - e().

This method computes the remainder value defined as the ceiling of log_h(g) times the number of odd bits minus the number of even bits.

Return type:

Union[Expr, int, float, Rational]

Returns:

Remainder value, either symbolic or evaluated based on the basis

Mathematical Formula:

r = c * o - e = ceil(log_h(g)) * o - e

Examples

>>> d = D(2, 5)
>>> d.r()  # Symbolic form
>>> collatz_d = D(2, 5).encode(B.Collatz)
>>> collatz_d.r()  # Numerical evaluation: 2 * 2 - 5 = -1