Search code examples
matlabsimplifysymbolic-math

Matlab's simplify behavior


I'm trying to simplify some symbolic equations.

>> syms x;
>> simplify(sqrt(x^2)/x)

ans =

(x^2)^(1/2)/x

Actually, I want matlab to return 1 or smth like that.

>> simplify((x^9+7*x^8-2*x-6)/(x-1))

ans =

-(- x^9 - 7*x^8 + 2*x + 6)/(x - 1)

1 is a root of numerator, so I want matlab to reduce that fraction.

What am I doing wrong?


Solution

  • Answer for the first question is simple.

    >> x = sym('x', 'positive' )
    
    x =
    
    x
    
    >> simplify(sqrt(x^2)/x)
    
    ans =
    
    1