Results 1 to 3 of 3

Math Help - Is this Matlab issue fixable or not?

  1. #1
    Newbie
    Joined
    May 2009
    Posts
    14

    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.
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Behold, the power of SARDINES!
    TheEmptySet's Avatar
    Joined
    Feb 2008
    From
    Yuma, AZ, USA
    Posts
    3,764
    Thanks
    78
    Quote Originally Posted by seadog View Post
    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
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by seadog View Post
    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
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. transpose issue
    Posted in the Algebra Forum
    Replies: 5
    Last Post: May 12th 2011, 09:55 AM
  2. TI - 89 TI issue
    Posted in the Calculators Forum
    Replies: 3
    Last Post: October 10th 2009, 09:45 PM
  3. Log Issue
    Posted in the Algebra Forum
    Replies: 2
    Last Post: June 11th 2009, 08:09 PM
  4. Issue With MATLAB Homework Problem
    Posted in the Math Software Forum
    Replies: 2
    Last Post: March 2nd 2009, 02:48 AM
  5. Probability Issue
    Posted in the Statistics Forum
    Replies: 1
    Last Post: April 2nd 2008, 05:18 PM

Search Tags


/mathhelpforum @mathhelpforum