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.
>&开发者_如何转开发gt; 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?
For the second question, you might have to help show Matlab the way:
>> factor(x^9+7*x^8-2*x-6)
ans =
(x - 1)*(x^8 + 8*x^7 + 8*x^6 + 8*x^5 + 8*x^4 + 8*x^3 + 8*x^2 + 8*x + 6)
>> ans/(x-1)
ans =
x^8 + 8*x^7 + 8*x^6 + 8*x^5 + 8*x^4 + 8*x^3 + 8*x^2 + 8*x + 6
Answer for the first question is simple.
>> x = sym('x', 'positive' )
x =
x
>> simplify(sqrt(x^2)/x)
ans =
1
精彩评论