Missing /: (%, S) -> % in Fraction

11 views
Skip to first unread message

Ralf Hemmecke

unread,
May 2, 2024, 1:22:56 PM5/2/24
to fricas-devel
It is, of course, only a convenience, but I find it somewhat weird that
SPAD does not allow to divide a rational number by an integer.
The available signatures only say

http://fricas.github.io/api/Fraction.html#l4672616374696f6e-2f

/: (%, %) -> %
/: (S, S) -> %

but not

/: (%, S) -> %

Would it be a bad idea to add such an implementation to Fraction?
Or even add a default implementationn like

((x: %) / (s: S)): % == numer(x) / (s*denom(x)

to QuotientFieldCategory?

Ralf

Qian Yun

unread,
May 2, 2024, 7:18:54 PM5/2/24
to fricas...@googlegroups.com
I guess by adding this new signature, it will cause problems for
type conferencing in compiler/interpreter.

There will be much more possibilities to consider.

IIRC, there's already performance issues when compiling expressions
with lots of "/", for example when solving radical roots for
degree 3/4 polynomials. The recent radical denesting file may
be a similar case.

So it makes sense to let user do the coercion manually:

f : %
d : S
f/(d::%)

- Qian

Waldek Hebisch

unread,
May 2, 2024, 7:59:45 PM5/2/24
to fricas...@googlegroups.com
AFAICS such division is already implemented in Fraction, more
precisely Fraction inherits implementation from LocalAlgebra.
What is missing is declaration, so inherited operation is not
exported.

I do not know conseqences. I think that there is nontrival number
of cases (enough that I remember this happening) when to divide
I need something special first, like coercion or computing inverse.
I can not say how many involve fractions. OTOH there are possible
bad things, like interpter doing strange inference or Spad compiler
loosing time on useless possibilities.

One simply needs to experiment to find out.

--
Waldek Hebisch
Reply all
Reply to author
Forward
0 new messages