|
From: Stavros M. (Σ. Μ. <mac...@al...> - 2016-03-30 21:33:28
|
Though float(mod(rationalize(x),rationalize(y))) is the easiest exact
calculation, mod(a*2^m,b*2^n) can easily be calculated without expanding
the powers, since it is equal to mod(a*2^(m-min(m,n)), b)*2^min(m,n), where
the modular exponentiation can be performed using cexpt (in rat3a).
The Maxima equivalent is:
modfloat(a,m,b,n) :=
block([q:min(m,n), modulus: b, t],
t: ratdisrep(a*rat(2)^(m-q)),
2^q * (if t>=0 then t else t:t+b))
-s
On Wed, Mar 30, 2016 at 11:13 AM, Raymond Toy <toy...@gm...> wrote:
> >>>>> "Robert" == Robert Dodier <rob...@gm...> writes:
>
> Robert> On 2016-03-21, Stavros Macrakis <mac...@al...> wrote:
> >> So we have a choice between making float mod exact (i.e., the
> correctly
> >> rounded result of the infinite-precision result) or making it
> consistent
> >> with floating division. And if we want to make it consistent with
> >> floating-point division, it is outside the nominal range of mod. Is
> it
> >> correct to cheatXXX round up in this case and define
> mod(6.3,2.1)=0.0?
>
> Robert> I have spent some time thinking about this, and I've come to
> the
> Robert> conclusion that we should make mod exact. This might be a
> little more
> Robert> work, but it's much easier to understand, and therefore it's
> much
> Robert> easier to figure out what to do in any given case.
>
> Robert> As part of this, I'd like to implement a two-argument floor
> function
> Robert> which will be consistent with mod, that is, such that x -
> floor(x,y)*y =
> Robert> mod(x,y) (since it is possible to construct examples such that
> Robert> x - floor(x/y)*y != mod(x,y) when mod(x,y) is exact).
>
> It seems to me the only way to make it exact is to convert all floats
> to the corresponding rational number. How will that work with bfloats
> where the exponent could be so large that no rational will fit in the
> machine?
>
> I personally am happy with float behaving as they do today. Well,
> except for x/y being computed as x*(1/y), which you've fixed.
>
> --
> Ray
>
>
>
> ------------------------------------------------------------------------------
> Transform Data into Opportunity.
> Accelerate data analysis in your applications with
> Intel Data Analytics Acceleration Library.
> Click to learn more.
> http://pubads.g.doubleclick.net/gampad/clk?id=278785471&iu=/4140
> _______________________________________________
> Maxima-discuss mailing list
> Max...@li...
> https://lists.sourceforge.net/lists/listinfo/maxima-discuss
>
|