Changed root finder to use base-2 exponent of bound

Since the root isolation algorithm uses a power of two as bound anyway,
it makes sense to use it's exponent in method interfaces and throughout
the algorithm. This simplifies multiplications to cheap shifts and will
make it easier to detect when the isolating interval size is 1.

Also added some method documentation.
This commit is contained in:
2024-05-26 17:05:02 +02:00
parent 04e1702a2e
commit 8d4a5c2ed8
2 changed files with 32 additions and 20 deletions

View File

@@ -89,7 +89,7 @@ begin
// y = 3 * (x - 34000) * (x - 23017) * (x - 5) * (x^2 - 19) * (x + 112)
// = 3 * x^6 - 170730 * x^5 + 2329429920 * x^4 + 251300082690 * x^3 - 1270471872603 * x^2 + 4774763204640 * x - 24979889760000
a := TBigIntPolynomial.Create([-24979889760000, 4774763204640, -1270471872603, 251300082690, 2329429920, -170730, 3]);
r := TPolynomialRoots.BisectIsolation(a, TBigInt.One << 15);
r := TPolynomialRoots.BisectIsolation(a, 15);
AssertBisectResult(r, expRoots);
r.Free;
end;