Skip to content

feat(math): add polynomial interpolation operations (#1883) - #2050

Open
morluto wants to merge 1 commit into
mainfrom
agent/polynomial-interpolation-1883
Open

feat(math): add polynomial interpolation operations (#1883)#2050
morluto wants to merge 1 commit into
mainfrom
agent/polynomial-interpolation-1883

Conversation

@morluto

@morluto morluto commented Aug 18, 2026

Copy link
Copy Markdown
Owner

Summary

Implements the polynomial_interpolation_ops domain with 3 atomic operations for polynomial interpolation using exact rational arithmetic.

Closes #1883

Operations

Operation Description
polynomial.interpolation.divided_differences.compute Compute Newton divided differences table
polynomial.interpolation.newton_form.compute Compute Newton form coefficients
polynomial.interpolation.newton_evaluate.compute Evaluate polynomial in Newton form at a point

Design

  • SymPy exact arithmetic: All computations use SymPy's exact rational arithmetic, ensuring no floating-point errors.
  • Divided differences: The classical Newton divided difference algorithm computes the coefficients of the interpolating polynomial in Newton form.
  • Nested evaluation: Newton form evaluation uses nested multiplication (Horner-like) for O(n) evaluation at any point.

Continue this on Linzumi

Add polynomial_interpolation_ops domain with 3 operations: divided
differences, Newton form, and Newton evaluation. Uses SymPy for exact
rational arithmetic.

Closes #1883
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

morluto commented Aug 18, 2026

Copy link
Copy Markdown
Owner Author

Deep review summary

Verdict: REQUEST CHANGES — repeated nodes and mismatched sample arrays cross the boundary, and the three operations do not share one coherent exact scalar domain.

1. Distinct interpolation nodes are not required

Ordinary Newton divided differences divide by x_{i+j}-x_i. Repeated nodes make that denominator zero. The request accepts them and the kernel can emit SymPy infinities/undefined expressions instead of a polynomial. Either require pairwise-distinct nodes, or implement a separate Hermite/confluent divided-difference contract carrying derivative data. Do not silently mix the two semantics.

2. Two request models omit the nodes/values length invariant

Only DividedDifferencesRequest requires equal lengths. NewtonFormRequest and NewtonEvaluateRequest accept shorter value arrays that later raise IndexError, and longer arrays whose extra values can be ignored. Reuse one validated sample-table value for every operation.

3. Parsing and advertised domains are inconsistent

divided_differences uses unrestricted sympify for both nodes and values, newton_form uses symbolic nodes but Rational values, and newton_evaluate requires rational nodes/values but again sympifys the evaluation point. Thus the same wire data can be accepted by one operation and rejected by another, while all descriptions claim exact rational arithmetic.

Use Jacobian's canonical rational type consistently, or explicitly define a bounded symbolic coefficient field. Avoid raw sympify at an untrusted wire boundary and enforce expression/work bounds.

4. newton_evaluate is not actually an evaluator for Newton form

It accepts sample values and recomputes the full divided-difference table. A composable evaluator should consume (nodes, Newton coefficients, x) and perform only nested multiplication. Keep sample-to-coefficients and coefficients-to-value as separate atomic operations; then test that evaluation interpolates every sample point and agrees with an independently expanded polynomial.

For distinct exact rational nodes and values, the divided-difference recurrence and Horner nesting themselves are correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Polynomial interpolation] Add exact divided-difference, Newton, Hermite, Hasse-jet, and multipoint-evaluation operations

1 participant