f = 
Hi Paul,
When applying simplify to the expression 'cos(beta) - cos(beta)*cos(alpha)^2', the MATLAB Symbolic Math Toolbox does not immediately produce the equivalent form 'cos(beta)*sin(alpha)^2'. This is due to the way 'simplify' operates: it performs a heuristic search through algebraically equivalent expressions and ranks them using an internal complexity metric, applying a transformation only when it determines the resulting form to be simpler according to that metric. The number of allowed simplification steps, specified by the Steps parameter, controls the breadth of this search. The documentation notes that “By default, simplify uses one internal simplification step. You can get different, often shorter, simplification results by increasing the number of simplification steps” and that “Simplification of a mathematical expression is not a clearly defined subject. There is no universal idea as to which form of an expression is simplest.” Because the first result returned when using 'All', true corresponds to the earliest lower-complexity form encountered in the search, increasing the number of steps (for example, from 20 to 1000) can alter that ordering and yield a different initial result. As a consequence, the form involving sin(alpha)^2 appears only once the search depth is sufficient, typically above approximately 200 steps.
You can refer to the following documentation for more information:
- Simplify symbolic expressions: https://www.mathworks.com/help/symbolic/simplify-symbolic-expressions.html
- simplify: https://www.mathworks.com/help/symbolic/sym.simplify.html
I hope this helps!