Thanks Volker for the tip, that does the job. More comments below:

On Sun, Jun 29, 2014 at 11:52 PM, John Cremona <john.crem...@gmail.com> wrote:
> Be careful though:
>
> sage: (sqrt(-2)*sqrt(-3)).simplify_radical()
> -sqrt(3)*sqrt(2)
>
> i.e. you cannot use sqrt(a)*sqrt(b)=sqrt(a*b) everywhere without
> reaching a contradiction.
>
> sage: bool( (sqrt(-2)*sqrt(-3)) == sqrt(2)*sqrt(3) )
> False

Right, e.g. in sympy:

>>> sqrt(-2)*sqrt(-3)
-sqrt(6)


Coming to the original example, sympy returns

>>> sqrt(3)/sqrt(15)
sqrt(5)/5

And Mathematica returns 1/sqrt(5).


Here is a more difficult example, in SymPy:

>>> 2**(S(1)/3) * 6**(S(1)/4)
2**(7/12)*3**(1/4)

Mathematica returns the same thing. Sage, on the other hand, does not
simplify this:

sage: 2**(1/3) * 6**(1/4)
6^(1/4)*2^(1/3)
sage: _.rational_simplify()
6^(1/4)*2^(1/3)


What is interesting though, is that Sage does perform some
factorization automatically, e.g.:

sage: sqrt(12)
2*sqrt(3)

Mathematica and SymPy do the same here.

Here is even better example, in Sage:

sage: sqrt(12)/sqrt(6)
1/3*sqrt(6)*sqrt(3)
sage: _.rational_simplify()
1/3*sqrt(6)*sqrt(3)

SymPy or Mathematica:

>>> sqrt(12)/sqrt(6)
sqrt(2)

So the Sage rule seems to be --- factorize simple sqrt(N) into the
form a*sqrt(b), do this for all sqrt() in the expression, and then
just convert 1/sqrt(n) -> sqrt(n)/n, and return the result, after
canceling common factors.

I think a better rule is to either

a) factor everything, like SymPy or Mathematica
2) do not factor anything, and just leave sqrt(12)/sqrt(6) as is. Then
rational_simplify() should return the result from a).

Ondrej

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to