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.
>
> sage: a0=RDF(1.0e1)
> sage: a1=RDF(1.01234e-100)
> sage: a2=RDF(1.0e-100)
> sage: a3=RDF(1.0e1)
> sage: b0=RDF(-1.0e1)
> sage: b1=RDF(1.0e1)
> sage: b2=RDF(-1.0e1)
> sage: b3=RDF(1.0e1)
> sage: # the coefficient of t^3
> sage: a0*b3 + a1*b2 + a2*b1 + a3*b0
> 0.0
>
> Note that a0*b3+a3*b0 is zero (both are 100 in magnitude). However,
>
> sage: a2*b1 - a1*b2
> 2.01234e-99
> sage: a2*b1 - a1*b2 +1 -1
> 0.0
>
> My guess is that adding 100 and subtracting 100 wipes out the precision
> and makes the resulting expression close enough to zero that it is
> considered zero.
Right. But I didn't ask it to do that. I asked it the result of the
product of two polynomials, and one would expect that the algorithm
used would take possible cancellations into account.
>
> Are you sure that RDF provides enough precision to carry out your
> computation?
Yes.
Note the t^3 term is correct in the following:
sage: R.<t>=RDF['t']
sage: s=1.0e-100*t^3+1.01234e-100*t^2+1.0e1*t+1.0e1
sage: u=1.0e1*t^3-1.0e1*t^2+1.0e1*t-1.0e1
sage: s*u
1e-99*t^6 + 1.234e-101*t^5 + 100.0*t^4 - 1.234e-101*t^3 - 100.0
Bill.
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---