On Thu, Dec 10, 2009 at 4:30 AM, andrejv <andrej.vodopi...@gmail.com> wrote: > > On Dec 10, 12:39 pm, "ma...@mendelu.cz" <ma...@mendelu.cz> wrote: > > On 10 pro, 11:02, Harald Schilly <harald.schi...@gmail.com> wrote: > > > > > > (%i3) ratsimp(a), algebraic=true; > > > > > Ok, is it wise to do this by default if called from sage? > > > > Not sure (could it break something in integration for example?) but > > without this we have bug described > > athttp://groups.google.cz/group/sage-devel/browse_thread/thread/1220492... > > > I don't think there is a bug there. It's just that one form is harder > to compute numerically because of rounding errors. > > (%i2) A1:ratsimp(A), algebraic=true$ > (%i3) A2:ratsimp(A)$ > > (%i4) float(A1); > (%o4) 139.406088405362 > > (%i5) float(A2); > (%o5) 32.0 > > But they are the same: > > (%i6) ratsimp(A1-A2); > (%o6) 0 > > If you compute A2 in higher precision, you will get a better result: > > (%i7) fpprec:256; > (%o7) 256 > (%i8) bfloat(A2); > (%o8) 1.3940608840536196048491518637[198 digits] > 6294485890103091502824365657b2
Thanks for this excellent explanation! The same entirely in Sage using interval arithmetic (some): sage: kmat = matrix(SR,[(4, 8, 4, 0, 8, 0), (5, 16, 4, 2, 12, 2), (1/3*sqrt(3) + 3, 8/3*sqrt(3) + 8, sqrt(3) + 1, 2, 4*sqrt(3) + 4, 10/9*sqrt(3)), (sqrt(2) + 2, 6*sqrt(2) + 4, 2*sqrt(2) + 2, 2, 6*sqrt(2) + 4, 2), (6, 24, 6, 4, 24, 4)]) sage: kkernel = kmat.right_kernel().basis()[0] sage: k6 = kkernel[5]*(12*sqrt(2)+20) sage: N(k6) 139.406088405362 sage: RIF(k6) 139.406088406? sage: k2 = k6.simplify_rational() sage: N(k2) 6.00000000000000 And we have: sage: RIF(k2) [-infinity .. +infinity] Ah ha! sage: RealIntervalField(90)(k2) 2.?e2 sage: RealIntervalField(110)(k2) 139.4061? sage: RealField(110)(k2) 139.40609168254414230900933332163 -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org