Group Abstract Group Abstract

Message Boards Message Boards

0
|
8K Views
|
4 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Strange behaviour of the FindMinimum function

Posted 12 years ago
POSTED BY: Antoine Bourget
4 Replies
Posted 12 years ago

Thank you very much, this is exactly what I was looking for !

POSTED BY: Antoine Bourget

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 BY: Udo Krause

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.1`30}, {x3, 4.2`30}, {x4, 3.1`30}, {x5, 6.2`30}}, 
 WorkingPrecision -> 30]

Out[17]= {27.0000000000000000000000000004, {x2 -> \
-1.10714871779409239876812612246, 
  x3 -> 4.24874137138387983594741835137, 
  x4 -> 3.14159265358979317680956263508, 
  x5 -> 6.28318530717958648213504566537}}
POSTED BY: Udo Krause
Posted 12 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.2`n

which would mean

4.2`30

if n=30. But this doesn't seem to work.

POSTED BY: Antoine Bourget
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard