rtoy / maxima

A Clone of Maxima's repo
Other
0 stars 0 forks source link

rat/algebraic can return unsimplified result with tellrat #4199

Open rtoy opened 4 months ago

rtoy commented 4 months ago

Imported from SourceForge on 2024-07-09 19:42:23 Created by macrakis on 2021-10-16 19:48:41 Original: https://sourceforge.net/p/maxima/bugs/3879


tellrat(q^2-q) => [q^2-q]
rat(q*(q+1)/2) => (q^2+q)/2
ralg: rat(%),algebraic => (2*q)/2

I'd think that the last result should be simply q.

This only happens with an argument in CRE form; with general representation, it's correct:

rat(q*(q+1)/2),algebraic => q

Workaround: call rat/algebraic on the result again:

rat(ralg) => (2*q)/2          << rat doesn't simplify
rat(ralg),algebraic => q      << repeating rat/algebraic simplifies
ratdisrep(ralg) => q          << ratdisrep also works

The problem does not come up with ratsubst:

ratsubst(r,r^2,rat(r*(r+1)/2)) => r
ratsubst(0,r^2-r,rat(r*(r+1)/2)) => r

Tested on the prebuilt Windows version of Maxima 5.45.1 / SBCL 2.0.0 / Windows 10.