Why is my symbolic trig expression is not fully simplifying?
16 views (last 30 days)
Show older comments
MathWorks Support Team
on 6 Nov 2019
Edited: MathWorks Support Team
on 13 Sep 2024
When I run the following,
syms xy = sqrt(1-sin(x)^2)y = simplify(y)
the "simplify" function is not working as expected, i.e. I am not getting an output of "cos(x)" or "abs(cos(x))". Instead, "y" is simply left unchanged.
Accepted Answer
MathWorks Support Team
on 13 Sep 2024
Edited: MathWorks Support Team
on 13 Sep 2024
By default, "simplify" only performs one simplification step, and that is why some expressions, like the one in the question, are not fully reduced. However, you can get a better answer by forcing "simplify" to perform more steps:
In your example, I began getting the right answer after raising "Steps" to 15:
syms xy = sqrt(1-sin(x)^2)y = simplify(y,'Steps',15);
Now the output of "simplify" is "abs(cos(x))" as expected.
0 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!