Question

sqrt(a^2+2*a+1) can be easily rewritten as |a+1|. I would like to do this in maxima, however cannot make it work. Although sqrt(a^2) is automatically simplified to |a|, sqrt(a^2+2*a+1) is not. And radcan(sqrt(a^2+2*a+1)) give a+1, which is incorrect. Is there anyway to get the right simplification in Maxima?

Was it helpful?

Solution

Yep. Basically, you just have to tell Maxima to try a bit harder to factorise the inside of the square root. For example:

(%i1) x: sqrt(a^2 + 2*a + 1);
                                    2
(%o1)                         sqrt(a  + 2 a + 1)
(%i2) factor(a^2 + 2*a + 1);
                                          2
(%o2)                              (a + 1)
(%i3) map (factor, x);
(%o3)                             abs(a + 1)
(%i4) 

The map here means that the function factor should be applied to each of the arguments of sqrt. What happens is that you get sqrt((a+1)^2) appear on the way, and this is automatically simplified to abs(a+1).

Note that the answer from radcan is correct for some values of a. As I understand it, this is all that radcan guarantees: it's useful for answering "Yikes! Is there a simpler way to think about this crazy expression?", but not particularly helpful for "Hmm, I'm not sure what the variables in this are. Is there a simpler form?"

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top