You can do something like this:
Simplify[Sqrt[x^2]]
(* Sqrt[x^2] *)
$Assumptions = _ ∈ Reals
(* _ ∈ Reals *)
Simplify[Sqrt[x^2]]
(* Abs[x] *)
This tells those functions that have an Assumptions
option that any expression is considered real.
Caveat: This refers to any expression, not just any variable! So you get this now:
Simplify[Sqrt[x] ∈ Reals]
(* True *)
Even though it is not in general assumed that x > 0
.
I have not tried this personally and I do not know if it will cause trouble along the way.
Update
A more restrictive version is $Assumptions = _Symbol ∈ Reals
. This will not cause Simplify[Sqrt[x] ∈ Reals]
to return True
. But it will only assume proper symbols to be real. Thus, x
will be considered real, but not f[x]
and not Subscript[x,1]
. Pattern matching is not aware of mathematical meaning.
There are other functions which do not have an Assumptions
option but can still work with reals only. These will have a "domain" option, which can be set to real. Examples are Reduce
, Solve
, FindInstance
, etc.
Examples:
Reduce[x^2 == -1, x]
(* x == -I || x == I *)
Reduce[x^2 == -1, x, Reals]
(* False *)
Another thing to note is that most symbolic processing functions will assume that things appearing in an inequality are real. From the Reduce
documentation:
Reduce[expr,vars]
assumes by default that quantities appearing algebraically in inequalities are real, while all other quantities are complex.
This means that we get results like this:
Reduce[Sqrt[x] < 0]
(* False *)
Though this is not true for general complex x
, Reduce
automatically assumes x
to be real due to the inequality.