---
title: "mlab-numerics-poly-fit-roots — Mova code model"
description: "Mova code model of mlab/src/builtins/poly.rs: components with their labels, obernants and the model text."
url: "https://groupants.elamur.ai/free/en/mova/mlab/src/builtins/poly.rs.groupant/poly-fit-roots.groupant/"
---
Elamur: [Mova](https://md.mova.elamur.ai/free/en/) · [Dictionary](https://md.dictionary.elamur.ai/free/en/) · [Research](https://md.research.elamur.ai/free/en/) · **Groupants**

This page as HTML: <https://groupants.elamur.ai/free/en/mova/mlab/src/builtins/poly.rs.groupant/poly-fit-roots.groupant/>

# mlab-numerics-poly-fit-roots

The groupant beside mlab/src/builtins/poly.rs in the Mova repository: what the code computes, what it never does, how to go back from its outputs, its invariants, cost and checks.

## Facts

- **kind:** groupant_fragment
- **status:** partial source bound model
- **source:** [`mlab/src/builtins/poly.rs`](https://github.com/ElamurAI/mova-free/blob/main/mlab/src/builtins/poly.rs)
- **source SHA-256:** `19ff6f221e4a7f39…`
- **covers:** polyfit parses x,y,n then rejects extra outputs, unequal lengths, invalid degree; constructs Vandermonde and calls SVD. roots rejects complex/nonfinite, removes leading zeros, records trailing zeros, constructs companion first row -c[j+1]/c0 and subdiagonal1 then calls eig. (bytes 1110–3724)
- **part of:** [mlab-numerics-poly](https://md.groupants.elamur.ai/free/en/mova/mlab/src/builtins/poly.rs.groupant/)
- **repository folder:** [`mlab/src/builtins/poly.rs.groupant/poly-fit-roots.groupant`](https://github.com/ElamurAI/mova-free/tree/main/mlab/src/builtins/poly.rs.groupant/poly-fit-roots.groupant)
- **repository commit:** `48f2e6f74146`

> **Implementation material.** A Mova code model describes this code at one source revision: partial models, finite checks and their stated scope. It is not a reviewed general exposition, and its labels are shown as written, never raised.

## Components

| component | label | where |
|---|---|---|
| **approximant** | partial | [approximant](#approximant) |
| **ast** | partial | `../syntax.json` |
| **cost** | symbolic source derived | [invariant](#invariant) |
| **descriptant** | present | [descriptant](#descriptant) |
| **invariant** | partial | [invariant](#invariant) |
| **tests** | executed bounded checks | [tests](#tests) |

## Obernants

The typed relations around the forward model: the behaviour complement (what the code never does), the reverse reconstruction (every input compatible with an output) and specialised views.

| id | type | label | where |
|---|---|---|---|
| `behavior_complement` | behavior_complement | partial source derived model | [behavior_complement](#behavior-complement) |
| `reverse_reconstruction` | reverse_reconstruction | partial source derived model | [reverse_reconstruction](#reverse-reconstruction) |
| `leading_trim` | leading_trim | partial source derived model | [leading_trim](#leading-trim) |
| `trailing_roots` | trailing_roots | partial source derived model | [trailing_roots](#trailing-roots) |
| `finite_gate` | finite_gate | partial source derived model | [finite_gate](#finite-gate) |
| `caller_join` | caller_join | partial source derived model | [caller_join](#caller-join) |

## Model text


### descriptant

#### mlab-numerics-poly-fit-roots

polyfit parses x,y,n then rejects extra outputs, unequal lengths, invalid degree; constructs Vandermonde and calls SVD. roots rejects complex/nonfinite, removes leading zeros, records trailing zeros, constructs companion first row -c[j+1]/c0 and subdiagonal1 then calls eig.

##### Modeling epoch 2026-10-31

Prospective source reading preceded inline tests. This node records implementation behavior, not a complete MATLAB compatibility contract. Models retain limits discovered in source reading, including real-only projections and warning-only result gates. Synthetic CPU fixtures are independent of frozen suites. No external effects, teacher, corpora or benchmark main are executed.

### approximant

#### Forward relation

polyfit parses x,y,n then rejects extra outputs, unequal lengths, invalid degree; constructs Vandermonde and calls SVD. roots rejects complex/nonfinite, removes leading zeros, records trailing zeros, constructs companion first row -c[j+1]/c0 and subdiagonal1 then calls eig.

Executable Rust surrogate gap: no calibrated replacement is attached. Exact test calls are evidence for the reference, not a fast approximant. Numerical approximants would need a named domain, zero convention and metric at supported caps 1/2/5/10%; categorical errors/effects have no percent surrogate here.

### invariant

#### Invariants and cost

Highest-degree coefficient first. Degree cast to usize/powi i32 not range-certified; eig result ordering is backend-dependent.

##### Cost

Vandermonde O(Md), SVD O(Md min(M,d)); companion O(d²) storage/O(d³) eig.

Allocation failure, unchecked usize dimension arithmetic and IEEE nonfinite propagation are outside finite fixture guarantees. No measured throughput or global accuracy claim.

### models

## Typed source models: mlab-numerics-poly-fit-roots

### behavior_complement

No roots eig call for constant/all-zero polynomial. polyfit's nargout error excludes further length/degree decision after initial argument parsing. Imaginary x/y cannot affect fitted Vandermonde in current code.

### reverse_reconstruction

Given monic roots, coefficient families differ by nonzero scale and leading zeros; trailing root zeros remain visible. Least-squares coefficients are compatible with residuals orthogonal to retained SVD column space, not a unique y.

### leading_trim

[0,1,-3,2] and [1,-3,2] yield same companion.

### trailing_roots

[1,-2,0] evaluates eig for residual degree1 then appends zero root.

### finite_gate

Any NaN/Inf coefficient errors before trimming, including nominal leading zeros around it.

### caller_join

roots uses it.call_function("eig",...,1); overridden/missing dispatch and non-Mat result are not backend proofs.


### tests

#### Evidence and limits

Selected wave30_tests exercise this source; fragment-specific limits are stated in its operators.

Native command specifications, numeric exits, profile-paired logs, compiled controls and exact-restoration receipts are retained externally in the wave30 numerics run. Tests exercise actual source, not a copied model. The selected finite fixtures do not prove full convergence, backend accuracy on all matrices, resource exhaustion or side-effectful callback behavior.
