Project

General

Profile

Design #1772

Continued fraction: arg type RAT or RAT/INT?

Added by John Abbott 5 months ago. Updated 5 months ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
enhancing/improving
Target version:
Start date:
28 Nov 2023
Due date:
% Done:

0%

Estimated time:
Spent time:

Description

Currently the continued fraction functions expect an arg of type RAT.
This cause a problem in one program I wrote which had the following structure:

  N := AsRAT(...);
  D := AsRAT(...);
  CF := ContFrac(N/D);

The problem was that in one instance N/D actually turned out to be an integer, so CoCoA-5 automatically gave the value the type INT.
This triggered an error (after several minutes' execution).

Should we allow the continued fraction functions to accept INT or not?

History

#1 Updated by John Abbott 5 months ago

Possible options:
  • disable the auto conversion from RAT to INT -- JAA doubts that this is wise (it could cause many other problems)
  • extend all the continued fraction functions to accept both RAT and INT -- a bit tedious; also it barely makes sense to ask for the continued fraction of an integer (it's well defined, but fairly pointless)
  • update the documentation (e.g. with an example like the one which gave me problems, and a solution)
  • if we do extend to allow INT too, should we also allow RINGELEM? [we must then convert it to RAT)

Also available in: Atom PDF