# Strange behaviour of the FindMinimum function

Posted 9 years ago
6545 Views
|
4 Replies
|
0 Total Likes
|
 HiI am trying to evaluate the minimum of a function, which may seem complicated at first sight but is in fact quite simple, it is just a sum of inverses of sines squared. I want 20 digits of precision, thus set WorkingPrecision to 20. In[22]:= min = FindMinimum[ Sin[ (x2 - x3)/2]^(-2) + Sin[ (x4 - x3)/2]^(-2) + Sin[ (x4 - x2)/2]^(-2) + Sin[ (x5 - x3)/2]^(-2) + Sin[ (x4 - x5)/2]^(-2) + Sin[ (x5 - x2)/2]^(-2) + Sin[ (x2 + x3)/2]^(-2) + Sin[ (x4 + x3)/2]^(-2) + Sin[(x4 + x2)/2]^(-2) + Sin[ (x5 + x3)/2]^(-2) + Sin[ (x4 + x5)/2]^(-2) + Sin[ (x5 + x2)/2]^(-2) - 1, {{x2, -1.1}, {x3, 4.2}, {x4, 3.1}, {x5, 6.2}}, WorkingPrecision -> 20] During evaluation of In[22]:= FindMinimum::sszero: The step size in the search has become less than the tolerance prescribed by the PrecisionGoal option, but the gradient is larger than the tolerance specified by the AccuracyGoal option. There is a possibility that the method has stalled at a point that is not a local minimum. >> Out[22]= {26.000000000000014553, {x2 -> -1.1071487225113589847, x3 -> 4.2487413858936085020, x4 -> 3.1415926678804502181, x5 -> 6.2831853137302564605}} The minimum seems to be around 26. But then if I evaluate the function at the given values of x2,x3,x4,x5, this is what I get : In[23]:= Sin[ (x2 - x3)/2]^(-2) + Sin[ (x4 - x3)/2]^(-2) + Sin[ (x4 - x2)/2]^(-2) + Sin[ (x5 - x3)/2]^(-2) + Sin[ (x4 - x5)/2]^(-2) + Sin[ (x5 - x2)/2]^(-2) + Sin[ (x2 + x3)/2]^(-2) + Sin[ (x4 + x3)/2]^(-2) + Sin[(x4 + x2)/2]^(-2) + Sin[ (x5 + x3)/2]^(-2) + Sin[ (x4 + x5)/2]^(-2) + Sin[ (x5 + x2)/2]^(-2) - 1 /. min[[2]] Out[23]= 27.00000000000001455 Here it finds 27 ! I know from analytical calculation that the correct result is indeed 27. I am aware of the error message above, but I don't understand the reason for the shift by 1 in the answer. A few remarks : This strange behaviour occurs only for sufficiently high WorkingPrecision. It disappears if I remove the "-1" at the end of the function whose minimum I am looking for. Any explanation would be highly appreciated !
4 Replies
Sort By:
Posted 9 years ago
 Thank you very much, this is exactly what I was looking for !
Posted 9 years ago
 This is a way  In[8]:= With[{prC = #}, FindMinimum[ Sin[(x2 - x3)/2]^(-2) + Sin[(x4 - x3)/2]^(-2) + Sin[(x4 - x2)/2]^(-2) + Sin[(x5 - x3)/2]^(-2) + Sin[(x4 - x5)/2]^(-2) + Sin[(x5 - x2)/2]^(-2) + Sin[(x2 + x3)/2]^(-2) + Sin[(x4 + x3)/2]^(-2) + Sin[(x4 + x2)/2]^(-2) + Sin[(x5 + x3)/2]^(-2) + Sin[(x4 + x5)/2]^(-2) + Sin[(x5 + x2)/2]^(-2) - 1, SetPrecision[{{x2, -1.1}, {x3, 4.2}, {x4, 3.1}, {x5, 6.2}}, prC], WorkingPrecision -> prC] ] & /@ {3, 32, 61} Out[8]= {{27.1, {x2 -> -1.06, x3 -> 4.25, x4 -> 3.15, x5 -> 6.29}}, {27.000000000000000000000000000002, {x2 -> -1.1071487177940905138496002853351, x3 -> 4.2487413713838834891688579745400, x4 -> 3.1415926535897932411309593731572, x5 -> 6.2831853071795864767829818942239}}, \ {27.00000000000000000000000000000000000000000000000000000000001, {x2 -> -1.107148717794090503017065460178941989217603383476861620425671, x3 -> 4.248741371383883741479708843458057352686502591415249448346964, x4 -> 3.141592653589793238462643383279422163300186884667391231912264, x5 -> 6.283185307179586476925286766559006139382728552267429532050186}}} 
Posted 9 years ago
 If you ramp up the WorkingPrecision, you should do so for the initial values too: In[17]:= FindMinimum[ Sin[(x2 - x3)/2]^(-2) + Sin[(x4 - x3)/2]^(-2) + Sin[(x4 - x2)/2]^(-2) + Sin[(x5 - x3)/2]^(-2) + Sin[(x4 - x5)/2]^(-2) + Sin[(x5 - x2)/2]^(-2) + Sin[(x2 + x3)/2]^(-2) + Sin[(x4 + x3)/2]^(-2) + Sin[(x4 + x2)/2]^(-2) + Sin[(x5 + x3)/2]^(-2) + Sin[(x4 + x5)/2]^(-2) + Sin[(x5 + x2)/2]^(-2) - 1.27, {{x2, -1.130}, {x3, 4.230}, {x4, 3.130}, {x5, 6.230}}, WorkingPrecision -> 30] Out[17]= {27.0000000000000000000000000004, {x2 -> \ -1.10714871779409239876812612246, x3 -> 4.24874137138387983594741835137, x4 -> 3.14159265358979317680956263508, x5 -> 6.28318530717958648213504566537}} 
Posted 9 years ago
 Thank you, this solution works indeed, even if I still don't understand why I get such a false result in my initial calculation. But then I didn't find out how to set the precision for my initial values in such a way that I can modify it easily if I want to. I would like to write something like 4.2n which would mean 4.230 `if n=30. But this doesn't seem to work.