CConvergeHazel
Product

Product features · Continued-fraction convergents

01

Trace successive numerator and denominator updates in ConvergeHazel while preserving their integer relationship.

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.

Continued-fraction convergents

● ● ●ConvergeHazel●
A concrete starting point · Continued-fraction convergents ×
def convergents(terms):
    terms = tuple(terms)
    if not 1 <= len(terms) <= 32 or any(type(a) is not int or abs(a) > 1000 for a in terms):
        raise ValueError("fraction.terms")
    if any(a <= 0 for a in terms[1:]):
        raise ValueError("fraction.tail")
    p0, p1, q0, q1, out = 0, 1, 1, 0, []
    for a in terms:
        p, q = a*p1+p0, a*q1+q0
        out.append((p, q))
        p0, p1, q0, q1 = p1, p, q1, q
    return out
✳Return every convergent of a continued fraction with one through 32 integer coefficients bounded by 1000 in magnitude.
✓ ChangesReview before applying ↗
Illustrative workspace
AI coding workspace

Your next change starts here.

Get the Windows app ↗