factor() gives up on any float coefficient, even 2.0, and returns an unevaluated node in which the coefficients have been rewritten as integers
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 52/100
Research direction
Start by tracing the factor evaluation path and how it handles numeric coefficients, then compare it with the discriminant path, which the issue says accepts these floats. Reproduce the listed float and integer inputs in the R binding and find the relevant tests. Done when exact integer-valued floats factor correctly, or unsupported coefficients produce a domain error without changing the unevaluated expression.
Written by the indexing model from the issue text.
Description
factor(expr) is documented as "factors a polynomial or rational expression into irreducible factors over the rationals". Any coefficient written as a float makes it give up, even when the value is an exact integer:
library(rssn)
compute(parse_term("factor(x^2 - 2*x + 1)"))$text
# "(x - 1)^2"
compute(parse_term("factor(x^2 - 2.0*x + 1.0)"))$text
# "factor(x^2 - 2*x + 1)" <- unevaluated, reduced = TRUE, value = NA
compute(parse_term("factor(x^2 - 4.0*x + 3.0)"))$text
# "factor(x^2 - 4*x + 3)"
compute(parse_term("factor(2.0*x^2 - 2.0)"))$text
# "factor(2*x^2 - 2)"
compute(parse_term("factor(1.0*x^2 - 1.0)"))$text
# "factor(x^2 - 1)"
The integer forms of the same four inputs all factor correctly ((x - 1)^2, (x - 3)*(x - 1), 2*(x - 1)*(x + 1), (x - 1)*(x + 1)), so the algorithm is there and only the float coefficients stop it.
Two things make this worse than a plain "unsupported input":
- The result is not a faithful echo.
factor(x^2 - 2.0*x + 1.0)comes back asfactor(x^2 - 2*x + 1)— the2.0has been silently rewritten as2in the unevaluated node, so the returned term no longer denotes the input expression. - It hits the R binding's default numeric type. In R every numeric literal is a double, so a polynomial built the ordinary way (
x^2 - 2*x + 1with R numbers) always carries float coefficients and always fails; the user has to spell the expression with integer literals inside a string to get a factorization.
discriminant already handles the same float coefficients (discriminant(x^2 + 2.0*x + 1.0, x) = 0), so the polynomial family is inconsistent about it.
Expected: normalise exact float coefficients to rationals before factoring (2.0 → 2), or reject the input with a domain error naming the coefficient — not return an unevaluated call whose arguments have been changed.
rssn 0.3.0, R 4.6.2 binding, Windows x86_64.
- Dominant language
- Rust
- Stars
- 36
- Forks
- 3
- Avg merge
- 14h 51m
- Merged PRs (30d)
- 29
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Apich-Organization/rssn
-
num_ode_rk4_adaptive rejects atol = 0 while accepting rtol = 0 and while num_ode_dopri5 accepts bothOpenarea/ode-pde good first issue help wanted kind/contract severity/4-minor
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Apich-Organization/rssn#383 ·
Maintainers usually reply within 1 day
-
area/numerical good first issue help wanted kind/doc-mismatch severity/5-trivial
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Apich-Organization/rssn#373 ·
Maintainers usually reply within 1 day
-
area/numerical good first issue help wanted kind/doc-mismatch severity/4-minor
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Apich-Organization/rssn#371 ·
Maintainers usually reply within 1 day
-
json_encode() re-emits a decoded empty JSON object as [], so {} and {"":1} are not round-trip stableOpenarea/api-bindings good first issue help wanted kind/contract severity/4-minor
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Apich-Organization/rssn#361 ·
Maintainers usually reply within 1 day
-
area/statistics good first issue help wanted kind/wrong-result severity/4-minor
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Apich-Organization/rssn#362 ·
Maintainers usually reply within 1 day
All issues in Apich-Organization/rssn
Similar issues
-
triage: failed
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
oxc-project/tsrs#1277 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
autofixer: follow-up triage: bug triage: classified triage: correctness triage: has-reproducer
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
tursodatabase/turso#13221 ·
Maintainers usually reply within 1 day
-
Update Wasmtime to 48.0.11 for RUSTSEC-2026-0648Possibly taken @flyingrobots claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
flyingrobots/edict#457 ·