# Conjugating real elements

Facing the same problem reported here: Conjugation with real elements answers are working, I thought of the following solution:

Unprotect[Conjugate];
Conjugate[x_] := x /; Element[x, Reals]
Protect[Conjugate];


but when I test it:

$Assumptions = {Element[y, Reals]}; Conjugate[y] (* output *) Conjugate[y]  doesn't seem to be doing what I need. If I don't use $Assumptions, then:

Refine[y, y \[Element] Reals];
Conjugate[y]
Simplify[Conjugate[y]]
(* output *)
Conjugate[y]
Conjugate[y]


Can someone please explain why my "solution" is not working?

• I don't really understand what the problem is. Note that Mathematica doesn't automatically perform all simplifications. For example, evaluating x/x will immediately simplify to 1, but for some more complicated expression, you need to use Simplify (or FullSimplify). Your "solution" does not work because the assumption that $y$ is real is not automatically taken into account, and therefore your custom downvalue (Conjugate[x_] := x /; Element[x, Reals]) is not used. Jun 8 at 12:36
• I am not sure you are using Refine correctly. It seems to me like you used it like Assumptions expecting Refine[y, y \[Element] Reals]; to imply that y will be real throughout the notebook but Refine only acts locally on it's first argument by applying the assumptions from the second argument. Jun 8 at 18:21
• you can try the following Jun 8 at 18:21
• Refine[y, y \[Element] Reals] // EchoLabel["Refine[y,y\[Element]Reals]"]; Conjugate[y] // EchoLabel["Conjugate[y]"]; Refine[Conjugate[y], y \[Element] Reals] // EchoLabel["Refine[Conjugate[y],y\[Element]Reals]"]; Conjugate[y] // EchoLabel["Conjugate[y]"] Jun 8 at 18:27

$Assumptions only affects functions which use the option Assumptions. Since Conjugate takes no options, $Assumptions has no effect on it.

$Assumptions = y ∈ Reals; Conjugate[y] (* Conjugate[y] *)  However, Simplify uses Assumptions and through it, $Assumptions

Simplify[Conjugate[y]]

(* y *)


Alternatively, ComplexExpand will assume that all variables are real unless explicitly told otherwise.

$$Assumptions = True (* clearing$$Assumptions *)

ComplexExpand[Conjugate[y]]

(* y *)

• Just adding for OP that Options[Simplify] shows Assumptions :> $Assumptions which might help understand why $Assumptions = y ∈ Reals; Simplify[Conjugate[y]] has the same effect as changing the option directly via Simplify[Conjugate[y], Assumptions -> y \[Element] Reals] Jun 8 at 18:46
• Notice also the :> rather than ->. Changing :> to -> has the effect that $Assumptions = True; SetOptions[Simplify, Assumptions ->$Assumptions]; \$Assumptions = y \[Element] Reals; Simplify[Conjugate[y]] outputs Conjugate[y] Jun 8 at 18:59