1
$\begingroup$

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?

$\endgroup$
4
  • 2
    $\begingroup$ 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. $\endgroup$
    – Domen
    Jun 8 at 12:36
  • 2
    $\begingroup$ 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. $\endgroup$ Jun 8 at 18:21
  • $\begingroup$ you can try the following $\endgroup$ Jun 8 at 18:21
  • 1
    $\begingroup$ 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]"] $\endgroup$ Jun 8 at 18:27

1 Answer 1

6
$\begingroup$

$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 *)
$\endgroup$
2
  • $\begingroup$ 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] $\endgroup$ Jun 8 at 18:46
  • $\begingroup$ 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] $\endgroup$ Jun 8 at 18:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.