# Why Mathematica is not assuming real variable as real?

I am dealing with the situation where despite of specifying my variables b1 and c to be greater than zero, Mathematica still returns the output with Re[b1+c]

x = a - (b1 + c)/2 I

FullSimplify[
Im[x],
{a >= 0, b1 >= 0, c >= 0}
]
(* -(1/2) Re[b1 + c] *)

• Next time please take the time to contsruct a minimal example and use readable formatting in your post. See my edit for reference. Jun 18, 2021 at 9:13

Clear["Global*"]

mat1 = Simplify[({{a - (b1 + c)/2 I, d}, {d, a - (b2 - c)/2 I}})];

mat2 = ({{0, 0, 1, 0}, {0, 0, 0, 1}, {-1, 0, 0, 0}, {0, -1, 0, 0}});


The primary tool for simplifying complex expressions is ComplexExpand

MatrixForm[
Simplify@
ComplexExpand[({{Re[mat1[][]],
Re[mat1[][]], -Im[mat1[][]], -Im[mat1[][]]}, {Re[
mat1[][]],
Re[mat1[][]], -Im[mat1[][]], -Im[mat1[][]]}, {Im[
mat1[][]], Im[mat1[][]], Re[mat1[][]],
Re[mat1[][]]}, {Im[mat1[][]], Im[mat1[][]],
Re[mat1[][]], Re[mat1[][]]}})]] This result shows that you need only require that the variables are real rather than the more restrictive nonnegative.

• I think it's worth noting that while Simplify and Refine are "safe", in that they shouldn't make invalid assumptions, ComplexExpand assumes that variables are real, unless told otherwise. I treat ComplexExpand (and PowerExpand) as unsafe, that is every use needs careful examination to ensure that their assumptions are met. Jun 17, 2021 at 22:20

I don't know really know why FullSimplify doesn't work, but Refine does

Assuming[{a >= 0, d >= 0, b1 >= 0, b2 >= 0, c >= 0},
Refine[({{Re[mat1[][]],
Re[mat1[][]], -Im[mat1[][]], -Im[
mat1[][]]}, {Re[mat1[][]],
Re[mat1[][]], -Im[mat1[][]], -Im[
mat1[][]]}, {Im[mat1[][]], Im[mat1[][]],
Re[mat1[][]], Re[mat1[][]]}, {Im[mat1[][]],
Im[mat1[][]], Re[mat1[][]], Re[mat1[][]]}})]]
(* {{a, d, (b1 + c)/2, 0}, {d, a, 0, (b2 - c)/2}, {1/2 (-b1 - c),
0, a, d}, {0, 1/2 (-b2 + c), d, a}} *)


Occasionally, a more specific simplification, such as Refine finds what you want when the more general one, FullSimplify, does not. Presumably FullSimplify` tries a lot of other things before it gives up.