Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#2663 radcan sometimes incorrect

None
closed
nobody
None
5
2014-02-19
2013-11-16
wuerfel138
No
(%i1) a : 1-x;
(%o1)                                1 - x
(%i2) b : 1-y;
(%o2)                                1 - y

(%i3) sqrt(a*b) - sqrt(a)*sqrt(b);
(%o3)           sqrt((1 - x) (1 - y)) - sqrt(1 - x) sqrt(1 - y)
(%i4) radcan(%);
(%o4)                      2 sqrt(x - 1) sqrt(y - 1)

which should however give 0, at least for 1-x > 0 and 1-y > 0.

So a second try:

(%i1) assume(1-x>0);
(%o1)                               [x < 1]
(%i2) assume(1-y>0);
(%o2)                               [y < 1]
(%i3) a : 1-x;
(%o3)                                1 - x
(%i4) b : 1-y;
(%o4)                                1 - y
(%i5) sqrt(a*b) - sqrt(a)*sqrt(b);
(%o5)                                  0

i.e. the correct answer. But now:

(%i6) sqrt(expand(a*b)) - sqrt(a)*sqrt(b);
(%o6)           sqrt(x y - y - x + 1) - sqrt(1 - x) sqrt(1 - y)
(%i7) radcan(%);
(%o7)                      2 sqrt(x - 1) sqrt(y - 1)

again the wrong result.


Maxima version: "5.27.0"
Maxima build date: "2012-05-09 21:24:21"
Host type: "x86_64-unknown-linux-gnu"
Lisp implementation type: "GNU Common Lisp (GCL)"
Lisp implementation version: "GCL 2.6.7"


Discussion

  • Raymond Toy
    Raymond Toy
    2013-11-16

    I believe this is working as intended. radcan makes certain assumptions. In particular it behaves as if the values of the variables are huge. It's best to ask on the mailing list about this. The author of radcan is on the mailing list.

    I generally use ratsimp, which doesn't make these kinds of assumptions.

     
  • wuerfel138
    wuerfel138
    2013-11-17

    Thank you for your advice. Reversing the order of the operands makes radcan work:

    (%i1) a : x-1;
    (%o1) x - 1
    (%i2) b : y-1;
    (%o2) y - 1
    (%i3) sqrt(ab) - sqrt(a)sqrt(b);
    (%o3) sqrt((x - 1) (y - 1)) - sqrt(x - 1) sqrt(y - 1)
    (%i4) radcan(%);
    (%o4) 0

    In my opinion a function should not return an incorrect result like the line
    "2 sqrt(x - 1) sqrt(y - 1)" in my original example, even without a warning.

    I agree, generally I try ratsimp. But ratsimp cannot simplify expressions like (%o3), or can it?

     
  • Closing, since this seems not to be a bug.

     
    • status: open --> closed