Is this a bug in coercion?

20 views
Skip to first unread message

kcrisman

unread,
Apr 28, 2011, 9:12:35 AM4/28/11
to sage-devel
sage: var('y,z')
(y, z)
sage: x = 4/5*(4*y-3)*z-1/3
sage: 1.0*x
4/5*(4*y - 3)*z - 1/3
sage: 1.2*x
0.960000000000000*(4*y - 3)*z - 0.400000000000000


I'm not familiar enough with the goals of that to be able to say for
sure. See http://ask.sagemath.org/question/525/numerical-approximation-for-expression
for background.

- kcrisman

Maarten Derickx

unread,
Apr 28, 2011, 10:49:16 AM4/28/11
to sage-devel
I think that somewhere the factor with which you multiply is checked
for being -1,0 or 1 and that that causes the problem.
Here is at least an easier way to reproduce the problem

sage: var('y')
y
sage: (y*(-3.0),y*(-2.0),y*(-1.0),y*0.0,y*1.0,y*2.0,y*3.0,y*4.0)
(-3.00000000000000*y, -2.00000000000000*y, -y, 0, y,
2.00000000000000*y, 3.00000000000000*y, 4.00000000000000*y)
sage: 1.0==1
True


On Apr 28, 3:12 pm, kcrisman <kcris...@gmail.com> wrote:
> sage: var('y,z')
> (y, z)
> sage: x = 4/5*(4*y-3)*z-1/3
> sage: 1.0*x
> 4/5*(4*y - 3)*z - 1/3
> sage: 1.2*x
> 0.960000000000000*(4*y - 3)*z - 0.400000000000000
>
> I'm not familiar enough with the goals of that to be able to say for
> sure.  Seehttp://ask.sagemath.org/question/525/numerical-approximation-for-expr...
> for background.
>
> - kcrisman

kcrisman

unread,
Apr 28, 2011, 2:57:32 PM4/28/11
to sage-devel


On Apr 28, 10:49 am, Maarten Derickx <m.derickx.stud...@gmail.com>
wrote:
> I think that somewhere the factor with which you multiply is checked
> for being -1,0 or 1 and that that causes the problem.
> Here is at least an easier way to reproduce the problem
>
> sage: var('y')
> y
> sage: (y*(-3.0),y*(-2.0),y*(-1.0),y*0.0,y*1.0,y*2.0,y*3.0,y*4.0)
> (-3.00000000000000*y, -2.00000000000000*y, -y, 0, y,
> 2.00000000000000*y, 3.00000000000000*y, 4.00000000000000*y)
> sage: 1.0==1
> True

Yes, but my question is whether it's a bug or a feature? Sorry for
not being clear.

- kcrisman

Robert Bradshaw

unread,
Apr 28, 2011, 6:27:50 PM4/28/11
to sage-...@googlegroups.com

I think it really boils down to the fact that the symbolic ring
doesn't understand the notion of exact vs. inexact values. E.g.

sage: 3.0*x
3.00000000000000*x
sage: 2.0*x
2.00000000000000*x
sage: 3.0*x - 2.0*x
x

- Robert

Reply all
Reply to author
Forward
0 new messages