Menu

#3879 rat/algebraic can return unsimplified result with tellrat

None
open
nobody
5
2021-10-16
2021-10-16
No
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.

Discussion

  • Stavros Macrakis

    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,7 +1,7 @@
     ~~~~
     tellrat(q^2-q) =&gt; [q^2-q]
     rat(q*(q+1)/2) =&gt; (q^2+q)/2
    -rat(%),algebraic =&gt; (2*q)/2
    +ralg: rat(%),algebraic =&gt; (2*q)/2
     ~~~~
    
     I&#39;d think that the last result should be simply ``q``.
    @@ -11,5 +11,12 @@
     rat(q*(q+1)/2),algebraic =&gt; q
     ~~~~
    
    +Workaround: call ``rat/algebraic`` on the result again:
    +~~~~
    +rat(ralg) =&gt; (2*q)/2          &lt;&lt; rat doesn&#39;t simplify
    +rat(ralg),algebraic =&gt; q      &lt;&lt; repeating rat/algebraic simplifies
    +ratdisrep(ralg) =&gt; q          &lt;&lt; ratdisrep also works
    +~~~~
    +
     Tested on the prebuilt Windows version of Maxima 5.45.1 / SBCL 2.0.0 / Windows 10.
    
     
  • Stavros Macrakis

    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -18,5 +18,11 @@
     ratdisrep(ralg) =&gt; q          &lt;&lt; ratdisrep also works
     ~~~~
    
    +The problem does not come up with ``ratsubst``:
    +~~~~
    +ratsubst(r,r^2,rat(r*(r+1)/2)) =&gt; r
    +ratsubst(0,r^2-r,rat(r*(r+1)/2)) =&gt; r
    +~~~~
    +
     Tested on the prebuilt Windows version of Maxima 5.45.1 / SBCL 2.0.0 / Windows 10.
    
     

Log in to post a comment.