5
$\begingroup$

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] *)
$\endgroup$
1
  • $\begingroup$ Next time please take the time to contsruct a minimal example and use readable formatting in your post. See my edit for reference. $\endgroup$ – Szabolcs Jun 18 at 9:13
4
$\begingroup$
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[[1]][[1]]], 
      Re[mat1[[1]][[2]]], -Im[mat1[[1]][[1]]], -Im[mat1[[1]][[2]]]}, {Re[
       mat1[[2]][[1]]], 
      Re[mat1[[2]][[2]]], -Im[mat1[[2]][[1]]], -Im[mat1[[2]][[2]]]}, {Im[
       mat1[[1]][[1]]], Im[mat1[[1]][[2]]], Re[mat1[[1]][[1]]], 
      Re[mat1[[1]][[2]]]}, {Im[mat1[[2]][[1]]], Im[mat1[[2]][[2]]], 
      Re[mat1[[2]][[1]]], Re[mat1[[2]][[2]]]}})]]

enter image description here

This result shows that you need only require that the variables are real rather than the more restrictive nonnegative.

$\endgroup$
1
  • $\begingroup$ 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. $\endgroup$ – mikado Jun 17 at 22:20
2
$\begingroup$

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[[1]][[1]]], 
     Re[mat1[[1]][[2]]], -Im[mat1[[1]][[1]]], -Im[
       mat1[[1]][[2]]]}, {Re[mat1[[2]][[1]]], 
     Re[mat1[[2]][[2]]], -Im[mat1[[2]][[1]]], -Im[
       mat1[[2]][[2]]]}, {Im[mat1[[1]][[1]]], Im[mat1[[1]][[2]]], 
     Re[mat1[[1]][[1]]], Re[mat1[[1]][[2]]]}, {Im[mat1[[2]][[1]]], 
     Im[mat1[[2]][[2]]], Re[mat1[[2]][[1]]], Re[mat1[[2]][[2]]]}})]]
(* {{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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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