MCPcopy Create free account
hub / github.com/cortex-js/compute-engine / real_roots

Function real_roots

benchmarks/gen_cases.py:37–44  ·  view source on GitHub ↗

Real roots of a polynomial (highest degree first), as decimal strings. Used to bake an independent reference root set for `solve` cases — the `solve` oracle checks a tool's returned (real) roots against this set.

(coeffs)

Source from the content-addressed store, hash-verified

35
36
37def real_roots(coeffs):
38 """Real roots of a polynomial (highest degree first), as decimal strings.
39
40 Used to bake an independent reference root set for `solve` cases — the
41 `solve` oracle checks a tool's returned (real) roots against this set."""
42 roots = polyroots([mpf(c) for c in coeffs], maxsteps=500, extraprec=200)
43 reals = sorted(r.real for r in roots if abs(r.imag) < mpf(10) ** (-40))
44 return [dec(r, 40) for r in reals]
45
46DEF_POINTS = [mpf("0.37"), mpf("1.93"), mpf("2.71")] # > 0, off singularities
47UNIT_POINTS = [mpf("0.13"), mpf("0.41"), mpf("0.67")] # inside (-1, 1)

Callers 1

gen_cases.pyFile · 0.85

Calls 2

decFunction · 0.85
absFunction · 0.50

Tested by

no test coverage detected