[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: sqrt(4/9) != 2/3



Thus spake George:
> On Wed, Feb 02, 2000 at 02:33:48AM -0500, Nils Barth wrote:
> > Well, it would be related insomuch as we have a bit of a problem
> > telling when a number is rational and when it is decimal.
> > 
> > For instance,
> > genius> 3/2 == 1.5
> > = 1
> > genius> is_rational(1.5)
> > = 0
> > genius> is_rational(3/2)
> > = 1
> > 
> > So is 3/2 equal to 1.5 or are they different?
> > We need to deal with this sometime.
> 
> Well ok it works like this.  == is numerical equality and 3/2 and 1.5 are in
> fact equal, however the types may be different.

Okay -- I didn't realize this -- I'll put a docs note to that effect.

> The fact that sqrt returns a float instead of rational is just that there is
> not test for perfectsquareness.  Putting such a test in would slow it down
> quite a bit.  Several functions in fact return floats always no matter what
> the input and I think that's not that bad.

OIC:
genius> sqrt(4)
= 2
genius> is_integer(Ans)
= 0
...sorry, I thought that sqrt (etc.) actually returned an integer.
Okay, returning floats is fine since drgenius is currently a numerical
engine. If/when it does symbolic, this could be modified (i.e.,
symbolic manipulations people would be willing to take a performance
hit for sqrt(4) to be an integer).
I just hacked together SymbolicSquareRoot, SymbolicNthRoot''.

Also, it might be a nice touch to display real integers (like the 2
above) as
2.
(i.e., with a trailing decimal point) to distinguish them from
integers (though this should be a user option most likely).

> > So........
> > I suggest that we (eventually) have a mechanism for precision
> > (volunteers?).
> 
> If somebody figures out how to do all the precision stuff I'd be waaaay more
> then happy.

Sorry for harping on this -- I meant to just put it at the bottom of a
todo list somewhere, but it seemed relevant here.

> I think with the little time I have for drgenius right now (not that I
> wouldn't have time really, but that I'm mostly lazy I think) my #1 priority
> is modularizing the gel library and fixing bugs.  I think I have the
> interface figured out for the most part so now just to finish the
> implementation changes.  Although there are still large gaps in the gel*.h
> interface which still need to be filled before I start converting the
> implementation to the new interface.
> 
> Hopefully within like a month or so I should get it somewhat working.  I
> really really want to get this working so that both the canvas and drgeo can
> start using it.  Also it will become a library so that other programs can
> embed gel as well.

Sounds cool!
Actually, it's probably a good idea if people occasionally mention
what they're doing on drg-dev, just to keep everyone up to date.

-- 
  -nils