On 10/27/06, Richard Fateman <fateman at cs.berkeley.edu> wrote:
> Do we require that CF consist solely of integers?
At present cf knows how to handle integers and rationals and
square roots of those, and the result has only integers in it.
Floats and bigfloats are converted to rationals in cf input.
Symbols or other nonnumeric expressions aren't allowed.
> In which case a CF is a rational constant and should be treated
> as yet another kind of number,
Agreed, a CF should be treated like a rational constant.
On looking at src/simp.lisp it seems maybe $ratnump is the
function we would want to expand to cover CF.
> We would then have to decide how to add cf(...) and 3.14d0. etc etc.
It seems like the way to approach the sum of CF + other stuff is
to make it work like rational + other stuff. The numer flag should
turn CF objects into floats just as it does with rationals.
cf(12.345) should yield a CF object, as rat yields a rational.
Not sure what cf(sin(1)) should yield -- float(sin(1)) and
bfloat(sin(1)) yield numbers, but rat(sin(1)) yields a nonnumeric
expression.
> I don't know if there is a nice CF output representation. cf(a,b,...) might
> be clear enough, with some indication of repetition or some version of
> a+b/(c+ d/(e+ ...)) as an option.
I think a+b/(c+ d/(e+ ...)) is good even in 2d display mode; the explicit
nested ratio shown by cfdisrep is really just too bulky.
To explore the possibilities here I've reworked a few of the CF
functions to make cf a simplifying function. That is not too
complicated -- it is just a matter of renaming the existing
$cf function and repurposing the $cf symbol. I made up a
tellsimpafter rule for adding CF stuff + other stuff, e.g.
a + b - c + %i + sqrt(17) + cf(1,2,3) + cf(4,5) - 8;
=> - c + b + a + cf(1, 1, 3, 17, 4) + %i
which I think is the behavior that's been suggested elsewhere
in this thread. Presumably it would be straightforward to handle
other operators.
I think it would be straightforward to rework the CF code;
it's mostly a matter of deciding what we want to see.
For what it's worth,
Robert