(x^3 + x)/x^2 + 5
ans =
real(ans)
ans =
You can see that if you have a real() call then the Symbolic Toolbox already automatically picks out the portions that are certain to be real and moves them outside the real() call.
If you have a real() call that is not simplifying the expression, then either the expression contains calls to unknown functions
real(F(x) + 5)
ans = or else the expression is in complex variables.
When you syms a variable, by default the variable is assumed to be complex, unless you add the real flag to the syms call
or else you use assume or assumeAlso to explicitly mark the variable as real, or to add an assertion that implies the variable is real real(y + 5)
ans = Here, the assumption of >0 can only be satisfied if y is real, so you get y is real "for free"