[Scilab-users] Strange behaviour of prod on rationals

Samuel Gougeon sgougeon at free.fr
Fri Jul 24 13:41:53 CEST 2020


Le 24/07/2020 à 13:11, Samuel Gougeon a écrit :
>
> .../...
> How to apply any absolute tolerance is quite clear (although unsafe). 
> IMHO the absolute tolerance must be set to 0 (so not keeping the 
> default one set to 1e-10), for the reason given hereabove.
>

I meant, in %r_simp(). In %r_clean(), taking the actual input absolute 
tolerance is obviously mandatory.

> How to use and apply  the relative tolerance is more debatable. 
> Presently, for a given rational, no comparison is done between 
> coefficients of its numerator and the corresponding ones of its 
> denominator. We could consider doing things is this way.
>

Either in both %r_clean() and %r_simp(), or only in %r_simp() to decide 
when simplifying. By the way, the comparison could be done either alone, 
or after applying clean() to the num and den separately.
A possible proposal:

  * keep %r_clean() as is: num and den are cleaned separately.

  * %r_simp(): to decide any denom=1 simplification for a given rational, do
      o apply clean(rational, 0, %eps).
        Then:
      o if degree(numer) <= degree(denom) and if for all numer(i)
        coefficients clean([numer(i) denom(i)], 0, %eps) sets numer(i) to 0
          + Then actually set numer=0 and denom=1
          + Otherwise: keep the rational as is.

We could illustrate with some critical examples of inputs and results

SG

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20200724/dd7e0af8/attachment.htm>


More information about the users mailing list