ConvergeHazel keeps continued-fraction code in a project-aware AI conversation. Review suggested integer recurrences and examine successive approximations without treating model output as mathematical proof.
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
Project
Test a negative first term and 3-7-16, rejecting nonpositive later terms and keeping numerator-denominator pairs exact.
Review before applying
Compare actual behavior with the expected result. If a check fails, investigate it before applying more changes.
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
AI coding workspace
Review numerical work without losing the application's purpose
ConvergeHazel is a Windows AI coding workspace for discussing numerical source changes alongside the project that needs them. Open the folder and explain how the application uses the calculation. Ask the connected model to inspect the function, its callers and relevant tests before recommending an edit. That context helps keep a mathematically plausible rewrite aligned with the software's actual contract.
The convergents.py example can ground a task about a sequence of rational approximations. Provide a short input and the exact numerator-denominator pairs you expect, then ask how intermediate results reach the consumer. Treat accepted term bounds and output ordering as explicit requirements. The example supplies a concrete review target, while implementation and verification remain tasks performed against your own project files.
An unfiltered AI model may be chosen through a supported OpenAI-compatible or Anthropic endpoint that offers it. Configure the connection and credentials as required; context capacity and tool availability vary by service. Review the proposed changes and compare results with independently established cases. Keep exact arithmetic requirements visible if later code converts the output to a decimal. A patch is easier to assess when each transformation has a stated purpose and a check at the boundary where meaning could change.
Making a numerical patch checkable
Why provide exact pairs instead of decimal examples?
Decimals can hide a difference in representation or rounding. If the function's contract returns numerator-denominator pairs, check those directly first. Then evaluate any later decimal conversion as a separate step with its own precision requirements.
Can the model decide which input bounds to remove?
It can propose reasons, but the project requirements should determine accepted inputs. Inspect validation and callers before expanding the range. Larger values or longer sequences may require additional resource and output checks that the original task did not include.
Should I verify only the last approximation?
Not if callers use the intermediate sequence. Include expected order and representative earlier results as well as the last pair. A function can reach a plausible final value while returning incorrect or reordered intermediate entries.
What if the numerical explanation and tests disagree?
Pause the patch decision and trace a small case through the source. Check the expected value independently and inspect the test assumptions. Neither fluent reasoning nor an existing assertion should override a demonstrated mismatch without investigation.