If you have an expression that contains variables, i.e. non-numeric symbols, and you want to simplify that expression assuming that all variables are real: How can that be achieved?
Unfortunately Simplify[expr,Reals]
like in Solve is accepted, but the assumption "Reals
" is ignored.
An example with expected result Abs[1+x]
:
Block[{x, expr},
expr = Sqrt[(1 + 2 Conjugate[x] + x^2)];
{expr, Simplify[expr, Reals], Simplify[expr, Element[x,Reals]]}
]
==>
{Sqrt[1 + x^2 + 2 Conjugate[x]], Sqrt[1 + x^2 + 2 Conjugate[x]], Abs[1 + x]}
Of course I could use the last syntax Simplify[expr, Element[x, Reals]]
but only if I knew the variables within expr. Often expr or its predecessors are unknown since passed into a function as a parameter. Then, before simplification, I had to scan the complete expr for its variables.