# Is this Matlab issue fixable or not?

• May 4th 2009, 10:09 PM
Is this Matlab issue fixable or not?
Every time I type "syms x; sqrt(x^2)" in Matlab, it keeps spitting out "ans = (x^2)^(1/2)" instead of x. Even when I tried to type "simplify(sqrt(x^2))", it will still spit out the same answer. How do I fix this? It keeps screwing up an M-file I'm trying to write.
• May 4th 2009, 10:13 PM
TheEmptySet
Quote:

Every time I type "syms x; sqrt(x^2)" in Matlab, it keeps spitting out "ans = (x^2)^(1/2)" instead of x. Even when I tried to type "simplify(sqrt(x^2))", it will still spit out the same answer. How do I fix this? It keeps screwing up an M-file I'm trying to write.

I'm not a matlab expert but the two expressions are not equal and that may be the problem.

$(x^2)^{\frac{1}{2}}=|x|$ the absolute value of x

If you can tell mat lab that x is always greater than zero it may simplify as you wish.

For $x> 0; \sqrt{x^2}=(x^2)^{\frac{1}{2}}=x$
• May 4th 2009, 11:17 PM
CaptainBlack
Quote:

Every time I type "syms x; sqrt(x^2)" in Matlab, it keeps spitting out "ans = (x^2)^(1/2)" instead of x. Even when I tried to type "simplify(sqrt(x^2))", it will still spit out the same answer. How do I fix this? It keeps screwing up an M-file I'm trying to write.

As TheEmptySet says, there is nothing wrong with its result, you could try declaring x to be positive, but I don't have the symbolic toolboxes so I can't tell you how to do that.

(you should be able to declare the domain of x, you can in Maple and the symbolic toolbox is just a front end to the Maple kernel).

CB