8

Bug introduced in 10.2 or earlier and fixed in 11.0.0


EDIT In a very fast response from Wolfram they state that this is a known problem and give an example of it working for version 10.4.1.

$Version
(*10.4.1 for Microsoft Windows (64-bit) (April 11, 2016)*)

NSolve[eqn, {h, r, fc}]
(*{{h -> 6944.52 - 3662.26 I, r -> 4.68843*10^10 + 3.07219*10^12 I,   
   fc -> -1.76222*10^8 + 3.51039*10^8 I}, 
  {h -> 0.387583 + 0.0290387 I,  
   r -> 44.9117 - 8.67483 I, fc -> 415.19 + 53.0697 I}} *)

Two solutions are supplied suggesting numerical issues which innaiz has identified below.

The ever helpful Daniel Lichtblau suggests using the "EndomorphismMatrix" method which works well.

sol = NSolve[eqn, {h, r, fc}, Method -> "EndomorphismMatrix"]

(*{{h -> 0.387601 + 0.0289255 I, r -> 44.9137 - 8.66856 I, fc -> 415.189 + 53.0819 I}}*)

One solution is found which satisfies the equations:

eqn /. sol

(* {{True, True, True}} *)

This looks like the way forward.

Original Post

I need to solve equations of the form

eqn = {0.046443987614013964` + 0.3690429826762282` I == 
   h + r/(336.458333332019` - fc), 
  0.8898053473498362` + 0.5457057083738883` I == 
   h + r/(449.9999999982421` - fc), 
  0.6745246773524501` + 0.07315743778713857` I == 
   h + r/(563.5416666644653` - fc)}

So I use NSolve[]

Using Version 9

NSolve[eqn, {h, r, fc}]

(* {{h -> 0.387601 + 0.0289255 I, r -> 44.9137 - 8.66856 I, 
    fc -> 415.189 + 53.0819 I}}*)

Using Version 10.3

(* {{h -> 17838.7 - 12957.1 I, r -> 2.88691*10^12 + 2.45046*10^12 I, 
    fc ->    5.21787*10^7 + 1.8054*10^8 I}, 
   {h -> 0.387583 + 0.0290387 I, r -> 44.9117 - 8.67483 I, 
    fc -> 415.19 + 53.0697 I}} *)

Using Version 10.4

(* {} *)

So the solution is found in Version $9$. In Version $10.3$ there are two solutions, one of which looks like it is a numerical artifact. Finally in Version $10.4$ there is no solution. So is there a bug? I can use Solve but the problem is numeric and NSolve is meant to work better than Solve for numerical cases. What is the solution?

Thanks

Michael E2
  • 235,386
  • 17
  • 334
  • 747
Hugh
  • 16,387
  • 3
  • 31
  • 83

2 Answers2

8

Without SetPrecision it actually doesn't work fine in Mathematica 10.4.1:

In[2]:= NSolve[eqn, {h, r, fc}]

Out[2]= {{h -> 45112.4 + 69798. I, 
  r -> 3.6894*10^11 - 2.09612*10^12 I, 
  fc -> -3.94833*10^7 - 4.35473*10^7 I}, {h -> 0.387583 + 0.0290387 I,
   r -> 44.9117 - 8.67483 I, fc -> 415.19 + 53.0697 I}}

In[3]:= eqn /. %

Out[3]= {{False, False, False}, {False, False, False}}

However, in Mathematica 5.2 it works the same fine way as in version 9 in the subject question:

In[2]:=
NSolve[eqn, {h, r, fc}]

Out[2]=
{{h -> 0.3876007531699076 + 0.028925452482355368*I, 
  r -> 44.913731800940106 - 8.668559624622056*I, 
  fc -> 415.18940593411503 + 53.08192645339874*I}}

In[3]:=
eqn/.%

Out[3]=
{{True,True,True}}

Very sorry, this is not a reason to upgrade.

Alexey Popkov
  • 61,809
  • 7
  • 149
  • 368
innaiz
  • 116
  • 1
  • 2
  • 4
4

Works fine in Mathematica 10.4.1

NSolve[SetPrecision[eqn, 16], {h, r, fc}] // Chop
(* {{h -> 0.3876007531699077 + 0.0289254524823553 I, 
  r -> 44.91373180094011 - 8.66855962462205 I, 
  fc -> 415.1894059341150 + 53.0819264533987 I}} *)