1

I'd like Mathematica to to show that two complex numbers $a + b i$ and $c + d i$ (with real coefficients $a, b, c, d$) are equal if and only if $a = c$ and $b = d$.

The obvious thing does not quite work:

    Clear[a, b, c, d]
    Solve[a + b I == c + d I && {a, b, c, d} \[Element] Reals, {a, b}]

(*  {{a -> ConditionalExpression[c, (d | c) \[Element] Reals], 
      b -> ConditionalExpression[d, (d | c) \[Element] Reals]}}  *)

Similarly, using Reduce instead of Solve gives output:

(*  (d | c) \[Element] Reals && a == c && b == d  *)

While the results above are correct, they include obviously superfluous conditions. I want to obtain output simply:

   {{a -> c, b -> d}}

How else can this be obtained — without explicitly invoking Re and Im (whose use would, in essence, beg the question)?

I realize that if one has specific real numbers assigned to c and d, there is no issue. For example:

    Solve[a + b I == -2 + 3 I && a \[Element] Reals && b \[Element] Reals, {a, b}]

(* {{a -> -2, b -> 3}} *)
murray
  • 11,888
  • 2
  • 26
  • 50
  • 1
    Assuming[{c, d} \[Element] Reals, Refine[ Reduce[a + b I == c + d I && {a, b} \[Element] Reals]]] also works with Solve. – N.J.Evans Sep 15 '15 at 14:31
  • Wow! Why should it be so complicated? It's not the use of Refine that's bothering me in that method, but rather having to duplicate the reality condition on c and d in the enclosing Assuming instead of keeping it inside the Reduce (or Solve). – murray Sep 15 '15 at 14:38
  • I'm not sure, but I did a little experimenting and you can drop the conditions on c,d in the Solve or Reduce, and only apply them after the fact. (which also works for Artes soln.) This makes me think that those functions ignore the conditions you've set on the variables you're not solving for. Maybe someone with a better understanding of how Solve and Reduce work will chime in. – N.J.Evans Sep 15 '15 at 15:10

1 Answers1

6

Since one asks if we can get an appropriate result with Solve we should remember that Mathematica functionality for solving algebraic equations doesn't provide neccesarily the simplest form of solutions, this is because of (somtimes) quite involved boolean form of them. Thus the reason is in general economic usage of accesible system resources. Since we get a solution we might look for simpler form of it, otherwise the time for searching the simplest for of solution would not be optimal.

Although there are approriate functions for transforming boolean expressions in Mathematica there is quite easy resolution of the problem. We can use Refine, Simplify and FullSimplify with appropriate conditions.

Simplify[ Solve[ a + b I == c + d I && {a, b, c, d} ∈ Reals, 
                 {a, b}],
          {a, b, c, d} ∈ Reals]
{{a -> c, b -> d}}
Artes
  • 57,212
  • 12
  • 157
  • 245
  • OK, your answer is "simpler" in that it sticks with Simplify and Solve and avoids Refine, which is likely to be less familiar to a beginner than the other two. I'll be curious to see if anything simpler emerges that does not require the repeated use of the condition {a, b, c, d} ∈ Reals. – murray Sep 15 '15 at 14:51
  • Even if in a special case there is a simpler approach you shouldn't expect any shortcuts in general. It is pointed out in the anser. Since you shouldn't expect solutions for any algebraic equations ( sometimes this is because of enormous time of getting them) you shouldn't expect the simplest form of solutions, in such cases there is just Simplify, etc. – Artes Sep 15 '15 at 15:10
  • Not always we can get roots of polynomials in terms of radicals even though there is one, it is natural that in general there is no remedy for getting the simplest form of solutions. Read carefully this blog post by S.Wolfram. It' ll become more evident. – Artes Sep 15 '15 at 15:21