# square root

I am continually running into the problem where square roots defeat any attempt to simplify an expression. For example:

sqrt(-x_3 + sqrt(x_1^2 + x_2^2 + x_3^2))*sqrt(x_3 + sqrt(x_1^2 + x_2^2 +
x_3^2))/sqrt(x_2^2/x_1^2 + 1)


should simplify to x_1.

I understand the reason sage hesitates to simplify a square root. But being unable to force the issue is starting to render sage almost completely useless.

Does anybody know how to get sage to simplify these types of expressions? simplify_radical does not work. The closest I can come is to square the expression first, then simplify and take the square root. That still does not get rid of the final square root. I wonder if making the expression complex might work, and if so, how might I do that?

edit retag close merge delete

Sort by ยป oldest newest most voted

Here is how you can force sage to simplify roots

var('x_1 x_2 x_3')
t=(sqrt(-x_3 + sqrt(x_1^2 + x_2^2 + x_3^2))*sqrt(x_3 + sqrt(x_1^2 + x_2^2 +
x_3^2))/sqrt(x_2^2/x_1^2 + 1)).maxima_methods().rootscontract().simplify()
view(t)


Edit: If you want to get rid of the last square root use the following code

var('x_1 x_2 x_3')
assume(x_1>0)
t=(sqrt(-x_3 + sqrt(x_1^2 + x_2^2 + x_3^2))*sqrt(x_3 + sqrt(x_1^2 + x_2^2 +
x_3^2))/sqrt(x_2^2/x_1^2 + 1)).maxima_methods().rootscontract().simplify()
view(t)

more

That is better. I don't suppose you know how to get rid of the last square root; i.e. x_1 instead of sqrt(x_1^2)?

( 2012-02-26 01:39:34 +0200 )edit

( 2012-02-26 01:45:49 +0200 )edit

Great! And for me, it would be a good idea to finish it off with: forget(x_1>0) so the end result can be used without the constraint. Feels a bit like cheating, avoiding the things that make you safe. But, that's what I was asking for! Thanks!

( 2012-02-26 02:09:35 +0200 )edit

You have to remember that x_1 = sqrt(x_1^2) only if x_1 is positive. So the end result is actually abs(x_1). The end result cannot be used without constraint as x_1, if x_1 is actually negative.

( 2012-02-26 02:19:51 +0200 )edit

Real numbers are a subset of complex numbers. So if some property does not hold in general for real numbers it does not hold for complex numbers. Another way of looking at it is that a negative number is nothing but x_1exp(ipi) with a real x_1

( 2012-02-26 02:51:05 +0200 )edit