Hi,
I guess Bronstein had a good reason to introduce this "if" here:
https://github.com/fricas/fricas/blob/master/src/algebra/algfunc.spad#L135
in the allroots function.
However, fn is either rootOf of zeroOf.
If it is rootOf, it would be surprising if p(alpha) were not zero.
So it can only be the case for fn=zeroOf.
But even then, the as the name (and the documentation) suggests.
p(alpha) should be zero if zeroOf(p, sy) returns successfully.
Now suppose for a moment that one can have
alpha = zeroOf(p, sy) and not zero?(p alpha)
Then "p := p quo q" suggests that a possible remainder is simply
forgotten (otherwise "p exquo q" could have been used).
I'm probably not seeing the obvious. Can someone help me in
understanding this "if" construction?
Thanks
Ralf
===============================================================
allroots(p, y, fn) ==
zero? p => error "allroots: polynomial must be nonzero"
zero? coefficient(p, 0) =>
concat(0, allroots(p quo monomial(1, 1), y, fn))
zero?(p1 := reductum p) => []$List(%)
zero? reductum p1 => binomialRoots(p, y, fn)
decompList := completeDecompose(p)
# decompList > 1 =>
h := last decompList
g := leftFactorIfCan(p, h) :: SUP
groots := allroots(g, y, fn)
"append"/[allroots(h-r::SUP, y, fn) for r in groots]
ans := []$List(%)
while not ground? p repeat
alpha := assign(x := new(y)$Symbol, fn(p, x))
q := monomial(1, 1)$SUP - alpha::SUP
if not zero?(p alpha) then <------------------
p := p quo q
ans := concat(alpha, ans)
else while zero?(p alpha) repeat
p := (p exquo q)::SUP
ans := concat(alpha, ans)
reverse! ans