# how can I define a symbol as a global real number?

Say there is a complex number a=x+I, where x is a real number. Then b=Join[{a},{1+I}], and I use Re[b].

The result is {Re[x],1}, but the desired result is {x,1}.

How can I set x as a global real number from the very beginning? Please be noted that x should be treated a real number no matter what kind of calculation is used.

I have read many questions, but none is fit to my situation.

This problem bothers me for a very long time, and I hope someone can give me the answer.

• look for $Assumptions . The first example shows how to set global assumptions. $Assumptions = a > 0. – Sumit Jul 2 '18 at 13:13
• Related: (66273) – Lukas Lang Jul 2 '18 at 13:14

\$Assumptions = x \[Element] Reals

a = x + I
b = Join[{a}, {1 + I}]
Refine[Re[b]]


i+x

{I + x, 1 + I}

{x, 1}

• Thank you so much! It works! – Robin_Lyn Jul 2 '18 at 13:26

Perhaps

ComplexExpand[Re[b], TargetFunctions -> {Re, Im}]
(*{x, 1}*)


is what you're looking for!

• Thank you for your help, but I need set 'x' as a global real number. And I have many calculation afterwards. Your answer is local. – Robin_Lyn Jul 2 '18 at 13:21
• @Robin_Lyn You have to realize, though, that only functions that take an Assumptions option will be aware of global assumptions. Ulrich's approach, on the other hand, is explicit and local, which is actually a good thing so you don't fall into hard-to-debug situations that depend on remote assumptions / assignments. – MarcoB Jul 2 '18 at 13:25
• @MarcoB Thank you for your advice. Now I know both the global and local definition for a variable. Many thanks again for Ulrich Neumann – Robin_Lyn Jul 2 '18 at 13:31
• If you Set x to be a specific real number, it'll be that number, but there is no way in general to force Mathematica to treat a free symbol as representing a real number in all circumstances. – John Doty Jul 2 '18 at 13:32