MMonicVale
Product

Product features · Monic polynomial division

01

Put dividend and divisor fixtures beside their caller, then inspect the representation of leading zero coefficients before accepting a change to the division routine.

01

Connection

Base URL, credentials and a reachable server.

02

Selection

A model available through the configured endpoint.

03

Capabilities

Context limits and tool support are determined by the model and server.

Monic polynomial division

● ● ●MonicVale●
A concrete starting point · Monic polynomial division ×
def divide_monic(dividend, divisor):
    for row in (dividend, divisor):
        if type(row) not in (list, tuple) or len(row) > 21:
            raise ValueError("at most 21 coefficients")
        if any(type(x) is not int for x in row): raise ValueError("integers")
    def trim(row):
        row = list(row)
        while row and row[0] == 0: row.pop(0)
        return row
    a, b = trim(dividend), trim(divisor)
    if not b or b[0] != 1: raise ValueError("monic divisor")
    quotient = [0] * max(0, len(a) - len(b) + 1)
    while a and len(a) >= len(b):
        degree, factor = len(a) - len(b), a[0]
        quotient[len(quotient)-1-degree] = factor
        a = trim([x-factor*y for x,y in zip(a,b)] + a[len(b):])
    return trim(quotient), a
✳Divide integer polynomials of at most 21 coefficients by a monic divisor.
✓ ChangesReview before applying ↗
Illustrative workspace
AI coding workspace

Your next change starts here.

Get the Windows app ↗