Loading...

sage-support@googlegroups.com

[Prev] Thread [Next]  |  [Prev] Date [Next]

[sage-support] Re: Keeping coefficients as floats when using solve kcrisman Mon Feb 20 11:01:07 2012


On Feb 20, 10:39 am, Michael Orlitzky <[EMAIL PROTECTED]> wrote:
> On 02/19/12 19:58, Mike wrote:
>
> > When I run:
>
> > x,y=var('x,y', domain=RR)
> > solve(2.0*x+3.0*y==4.0, y)
>
> > I get
>
> > [y == -2/3*x + 4/3]
>
> > but I would like to get
>
> > [y == -0.666666666666666*x + 1.3333333333333]
>
> > How can I do this?
>
> Wild guess: the float coefficients are coerced to QQ, because otherwise
> numerical inaccuracy would prevent us from finding a solution. For example,

No, this is just Maxima.  We try to "keep float" as much as possible,
but in their *sub*routines like solve, sometimes this distinction is
not preserved for technical reasons - probably analogous to the one
that you allude to about QQ.


(%i2) keepfloat:True;
(%o2)                                True
(%i3) solve(2.0*x+3.0*y=4.0,y);

rat: replaced -4.0 by -4/1 = -4.0

rat: replaced 2.0 by 2/1 = 2.0

rat: replaced 3.0 by 3/1 = 3.0
                                       2 x - 4
(%o3)                           [y = - -------]
                                          3

-- 
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-support
URL: http://www.sagemath.org