On Wed, Jun 03, 2026 at 05:34:55PM +0800, Qian Yun wrote:
> It is happening in numsolve.spad, function "findGenZeros"
> that precision is increased by 100.
>
> I think in the attached patch, by reordering the transform
> to be after resetting precision, this problem is solved.
I am not sure if there is a problem. Namely, to compute result
at requested accuracy we need to increase intermediate precision.
Since final rounding may add to total error computing "exact
20 digits" (or similar) is rather complex process. So, instead,
normal policy in FriCAS is to keep results at whatever precision
they were computed. For the stated problem, that is display we
have controls like 'outputGeneral' which allow setting number
of displayed digits without affecting future use in computations.
Patch like below are tricky, because in 99.999999% of cases they
work fine. But there could be some pesky combination of input
data were added rounding goes outside requested bounds. To
prove that this does not happen requires effort. And if you
aim at "exact digits" then usually this requires much more
complex approach, basically estimating error and using error
estimate to decide if rounding could change displayed digits.
If not, then one rounds, otherwise repeats computation at
higher precision.
It is not clear to me if it is worth going in such direcition.
Current approach allows getting needed accuracy with reasonable
effort and output controls are enough for nicer printouts.
> To unsubscribe from this group and stop receiving emails from it, send an email to
fricas-devel...@googlegroups.com.
> To view this discussion visit
https://groups.google.com/d/msgid/fricas-devel/887ce321-5acf-4b62-bc36-6610034a0c21%40gmail.com.
> diff --git a/src/algebra/numsolve.spad b/src/algebra/numsolve.spad
> index 2400b653..5db6c0f5 100644
> --- a/src/algebra/numsolve.spad
> +++ b/src/algebra/numsolve.spad
> @@ -246,9 +246,9 @@ InnerNumericFloatSolvePackage(K, F, Par) : Cat == Cap where
> nfeps := (1/etol)*nfeps
> lz := innerSolve1(f, neps)
> ok := true
> - sol : L L F := []
> + sol : L L CI := []
> for z in lz while ok repeat
> - sol1 : L F := [CI_to_F(F_to_CI1(z, feps))]
> + sol1 : L CI := [F_to_CI1(z, feps)]
> for pol in rlp for xvar in rest(rlvar) repeat
> pp := ieval(pol, xvar, zvar, z, nfeps)
> pp case "failed" =>
> @@ -258,11 +258,12 @@ InnerNumericFloatSolvePackage(K, F, Par) : Cat == Cap where
> width(real(ppi)) > feps or width(imag(ppi)) > feps =>
> ok := false
> break
> - sol1 := cons(CI_to_F(ppi), sol1)
> + sol1 := cons(ppi, sol1)
> sol := cons(sol1, sol)
> ok =>
> bits(obits)
> - return reverse(sol)
> + res := [[CI_to_F(x) for x in l] for l in sol]
> + return reverse!(res)
> etol := etol^2
> ebits := 2*ebits
>
--
Waldek Hebisch