On 5 Nov, 00:26, Jason Grout <[EMAIL PROTECTED]> wrote:
> Bill Hart wrote:
>
> > On 4 Nov, 03:39, Jason Grout <[EMAIL PROTECTED]> wrote:
> >> Bill Hart wrote:
> >>> sage: R.<x>=RDF['t']
> >>> sage: s=1.0e1*t^3+1.0e-100*t^2+1.01234e-100*t+1.0e1
> >>> sage: u=1.0e1*t^3-1.0e1*t^2+1.0e1*t-1.0e1
> >>> sage: s*u
> >>> 100.0*t^6 - 100.0*t^5 + 100.0*t^4 - 100.0*t^2 + 100.0*t - 100.0
> >>> What happened to the t^3 term?
> >> Isn't it zero in RDF?
>
> > No. RDF has the possibility to have exponents down to -1023.
>
> I just *knew* I was getting into it over my head and that you knew the
> precision issues at stake.  Sorry for giving you the naive answer; I
> should have realized that of all people, you would know exactly the
> capabilities of machine precision arithmetic!

Well, I wouldn't suppose that I know *anything* about floating point
computations. Not really my area. I learned during my conversation
about these algorithms how to use RDF['x'] to do multivariate
polynomial multiplication over the integers using Kronecker
Segmentation, which I did not know about before.

The "correct" answer to the example I concocted can certainly be
expressed in RDF['x'], but it is nontrivial to design an efficient
algorithm to return that correct answer, on account of there only
being 53 bits of mantissa to work with. The order of operations is
relevant.

>
> So I take it your question was really:
>
> Shouldn't Sage realize that the naive computation of the coefficient of
> t^3 is seen as zero, while it is very possible to do the computation in
> such a way that you (correctly) don't get zero?  Shouldn't Sage be smart
> about the precision issues here?
>
> To which I answer: Yes, sure, of course!

Well, I agree with you, though I suspect opinion will be divided on
this one.

>
> It would make for a very interesting demo to show other systems
> incorrectly returning 0 for the coefficient, while Sage is just a bit
> smarter about the arithmetic issues and doesn't return 0.

I absolutely agree.

>
> Mma returns the term as "0. t^3"
>

That's interesting. Which version of Magma?

I am using the one on sage.math (v 2.13-5) and I get:

> R<t>:=PolynomialRing(RealField(53 : Bits := true));
> s:=1.0e1*t^3+1.0e-100*t^2+1.01234e-100*t+1.0e1;
> u:=1.0e1*t^3-1.0e1*t^2+1.0e1*t-1.0e1;
> s*u;
100.000000000000*t^6 - 100.000000000000*t^5 + 100.000000000000*t^4 -
    100.000000000000*t^2 + 100.000000000000*t - 100.000000000000

It would be interesting to see if the Magma people considered this to
be a bug.

Bill.
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to