Bug description:
(1) -> countRealRoots(x^2-1)
(1) 2
Type: PositiveInteger
(2) -> countRealRoots(x^4-1)
(2) 1
Type: PositiveInteger
The real roots of x^2-1 and x^4-1 are 1 and -1,
so countRealRoots is wrong.
I'm pretty sure sturm.spad is based on
Sturm-Habicht Sequences Determinants and Real Roots of
Univariate Polynomials, 1993, Lalo Gonzalez Vega etc
The hard part SturmHabichtSequence seems correct.
The problem is at
wfunct [coefficient(p, (qp-j)::NNI) for p in List1 for j in 1..qp]
It took j-th coefficient of j-th polynomial in SturmHabichtSequence,
but since wfunct is to test for sign change, no reason to take
the j-th coefficient, it should be leadingCoefficient.
diff --git a/src/algebra/sturm.spad b/src/algebra/sturm.spad
index 4f5343b..a4220fe 100644
--- a/src/algebra/sturm.spad
+++ b/src/algebra/sturm.spad
@@ -317,10 +317,9 @@ SturmHabichtPackage(R, x) : T == C where
SturmHabicht(p1, p2) : INT ==
-- print("+" :: Ex)
p2 = 0 => 0
- degree(p1::UP(x, R)) = 0 => 0
- List1 : L UP(x, R) := SturmHabichtSequence(p1, p2)
- qp : NNI := #(List1)::NNI
- wfunct [coefficient(p, (qp-j)::NNI) for p in List1 for j in 1..qp]
+ degree p1 = 0 => 0
+ List1 := SturmHabichtSequence(p1, p2)
+ wfunct [leadingCoefficient p for p in List1]
countRealRoots(p1) : INT == SturmHabicht(p1, 1)
--
You received this message because you are subscribed to the Google Groups
"FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.