2
$\begingroup$

I was playing around with the Solve function recently and found a behavior I couldn't explain. The equations I'm working with look like

Solve[{
Abs[(x - I y)/(x + I y)] == 4.5, 
Abs[x + I y]^2 == 2}, {x, y}]

Which computes quite quickly. The variations I looked at add a squaring (^2) to different terms, eg.

Solve[{
Abs[(x^2 - I y)/(x + I y)] == 4.5, 
Abs[x + I y]^2 == 2}, {x, y}]

Solve[{
Abs[(x - I y^2)/(x + I y)] == 4.5, 
Abs[x + I y]^2 == 2}, {x, y}]

Solve[{
Abs[(x - I y)/(x + I y^2)] == 4.5, 
Abs[x + I y]^2 == 2}, {x, y}]

All solve quite quickly. However,

Solve[{
Abs[(x - I y)/(x^2 + I y)] == 4.5, 
Abs[x + I y]^2 == 2}, {x, y}]

has been running for quite a while now, and my hopes of it completing at all are low. But it seems so similar to the previous three variations! Why is this fourth system, though ostensibly similar to the other three, so much more difficult for Mathematica to Solve?

In case it matters, I'm running v11 on Windows 7.

$\endgroup$
8
  • $\begingroup$ Have you considered preprocessing with ComplexExpand[]? $\endgroup$ Jan 31, 2017 at 17:52
  • $\begingroup$ To wit: ComplexExpand /@ {Abs[(x - I y)/(x^2 + I y)] == 4.5, Abs[x + I y]^2 == 2} and then Solve[%,{x,y}], evaluates rapidly. $\endgroup$
    – Feyre
    Jan 31, 2017 at 18:43
  • $\begingroup$ Ah thank you, I didn't know about ComplexExpand. So useful! $\endgroup$
    – nadlr
    Jan 31, 2017 at 18:51
  • $\begingroup$ @Feyre, it gives the wrong answer though, in version 11 $\endgroup$ Jan 31, 2017 at 20:34
  • 2
    $\begingroup$ You can replace x with z and get a rapid result. Sometimes altering the lexical ordering of symbols in the expression helps Mathematica choose better transformations. $\endgroup$ Jan 31, 2017 at 20:37

0

Browse other questions tagged or ask your own question.