Interaction between floats and rational expression code.
Subject: Interaction between floats and rational expression code.
From: Rupert Swarbrick
Date: Sat, 10 Apr 2010 23:06:48 +0100
Hi,
I was looking at bug 1928142 [1] from 2008, because I ran into a similar
issue with one of my own calculations. In it, Harald Geyer reports
(among other things) the problem that when keepfloat is true,
(%i6) ratsubst(%pi/3,th,1.2*cos(th))
(%o6) 1.2
(In case you, the reader, are being as dopey as I was when I first read
the bug report: it should be 0.6 since cos(%pi/3) = 1/2)
With some tracing of things, I got to an occurrence of CDISREP and
realised that, for example, (CDISREP (1.2 . 2.0)) returns 1.2. In the
code of CDISREP, it checks to see whether the denominator is a float
and, if so, returns the numerator.
After a minute or so of confusion, I realised that this might be
sensible behaviour: since you can't test whether a floating point number
is 1, you could just have a convention that you always divided through
to make the denominator 1.0 if it was a float.
Am I right there? Is this documented anywhere?
Anyway, I then realised that functions like RATTIMES don't preserve this
"convention". For example, in the middle of a trace I get
1: (RATTIMES (1.2 . 1.0) (1 . 2) NIL)
1: RATTIMES returned (1.2 . 2.0)
Is there a way to deal with floats sensibly in the rational expressions
code? And, if so, can anyone explain which bit went wrong in the
original reported bug?
Rupert
[1] http://sourceforge.net/tracker/?func=detail&aid=1928142&group_id=4933&atid=104933
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 315 bytes
Desc: not available
URL: <http://www.math.utexas.edu/pipermail/maxima/attachments/20100410/01132a71/attachment-0001.pgp>