50234

Why does FindMaximum with Newton's method complain it can't find a sufficient decrease in

Question:

Firstly, this seems like (from ContourPlot) a fairly straightforward maximization problem, why is FindMaximum with Newton's method having problems?

Secondly, how can I get rid of the warnings?

Thirdly, if I can't get rid of these warnings, how can I tell if the warning is meaningful, ie, maximization failed?

For instance, in the code below, FindMaximum with Newton's method gives a warning, whereas the PrincipalAxis method doesn't

o = 1/5 Log[E^(-(h/Sqrt[3]))/( 2 E^(-(h/Sqrt[3])) + 2 E^(h/Sqrt[3]) + E^(-(h/Sqrt[3]) - Sqrt[2] j) + E^(h/Sqrt[3] - Sqrt[2] j) + E^(-Sqrt[3] h + Sqrt[2] j) + E^(Sqrt[3] h + Sqrt[2] j))] + 3/10 Log[E^(h/Sqrt[3])/( 2 E^(-(h/Sqrt[3])) + 2 E^(h/Sqrt[3]) + E^(-(h/Sqrt[3]) - Sqrt[2] j) + E^(h/Sqrt[3] - Sqrt[2] j) + E^(-Sqrt[3] h + Sqrt[2] j) + E^(Sqrt[3] h + Sqrt[2] j))] + 1/5 Log[E^(-(h/Sqrt[3]) - Sqrt[2] j)/( 2 E^(-(h/Sqrt[3])) + 2 E^(h/Sqrt[3]) + E^(-(h/Sqrt[3]) - Sqrt[2] j) + E^(h/Sqrt[3] - Sqrt[2] j) + E^(-Sqrt[3] h + Sqrt[2] j) + E^(Sqrt[3] h + Sqrt[2] j))] + 1/10 Log[E^(h/Sqrt[3] - Sqrt[2] j)/( 2 E^(-(h/Sqrt[3])) + 2 E^(h/Sqrt[3]) + E^(-(h/Sqrt[3]) - Sqrt[2] j) + E^(h/Sqrt[3] - Sqrt[2] j) + E^(-Sqrt[3] h + Sqrt[2] j) + E^(Sqrt[3] h + Sqrt[2] j))] + 1/10 Log[E^(-Sqrt[3] h + Sqrt[2] j)/( 2 E^(-(h/Sqrt[3])) + 2 E^(h/Sqrt[3]) + E^(-(h/Sqrt[3]) - Sqrt[2] j) + E^(h/Sqrt[3] - Sqrt[2] j) + E^(-Sqrt[3] h + Sqrt[2] j) + E^(Sqrt[3] h + Sqrt[2] j))] + 1/10 Log[E^(Sqrt[3] h + Sqrt[2] j)/( 2 E^(-(h/Sqrt[3])) + 2 E^(h/Sqrt[3]) + E^(-(h/Sqrt[3]) - Sqrt[2] j) + E^(h/Sqrt[3] - Sqrt[2] j) + E^(-Sqrt[3] h + Sqrt[2] j) + E^(Sqrt[3] h + Sqrt[2] j))]; (* -1 makes more contours towards maximum *) contourFunc[n_, p_] := Function[{min, max}, range = max - min; Table[Exp[p (x - 1)] x range + min, {x, 0, 1, 1/n}] ]; cf = contourFunc[10, -1]; ContourPlot @@ {o, {j, -1, 1}, {h, -1, 1}, Contours -> cf} FindMaximum @@ {o, {{j, 0}, {h, 0}}, Method -> "Newton"} FindMaximum @@ {o, {{j, 0}, {h, 0}}, Method -> "PrincipalAxis"}

Note, I thought that maybe gradient being 0 in direction of one of the components was the problem, but if I perturb the initial point I still get the same warning, here's an example

o = 1/5 Log[E^(-(h/Sqrt[3]))/( 2 E^(-(h/Sqrt[3])) + 2 E^(h/Sqrt[3]) + E^(-(h/Sqrt[3]) - Sqrt[2] j) + E^(h/Sqrt[3] - Sqrt[2] j) + E^(-Sqrt[3] h + Sqrt[2] j) + E^(Sqrt[3] h + Sqrt[2] j))] + 1/5 Log[E^(h/Sqrt[3])/( 2 E^(-(h/Sqrt[3])) + 2 E^(h/Sqrt[3]) + E^(-(h/Sqrt[3]) - Sqrt[2] j) + E^(h/Sqrt[3] - Sqrt[2] j) + E^(-Sqrt[3] h + Sqrt[2] j) + E^(Sqrt[3] h + Sqrt[2] j))] + 1/10 Log[E^(-(h/Sqrt[3]) - Sqrt[2] j)/( 2 E^(-(h/Sqrt[3])) + 2 E^(h/Sqrt[3]) + E^(-(h/Sqrt[3]) - Sqrt[2] j) + E^(h/Sqrt[3] - Sqrt[2] j) + E^(-Sqrt[3] h + Sqrt[2] j) + E^(Sqrt[3] h + Sqrt[2] j))] + 3/10 Log[E^(h/Sqrt[3] - Sqrt[2] j)/( 2 E^(-(h/Sqrt[3])) + 2 E^(h/Sqrt[3]) + E^(-(h/Sqrt[3]) - Sqrt[2] j) + E^(h/Sqrt[3] - Sqrt[2] j) + E^(-Sqrt[3] h + Sqrt[2] j) + E^(Sqrt[3] h + Sqrt[2] j))] + 1/10 Log[E^(-Sqrt[3] h + Sqrt[2] j)/( 2 E^(-(h/Sqrt[3])) + 2 E^(h/Sqrt[3]) + E^(-(h/Sqrt[3]) - Sqrt[2] j) + E^(h/Sqrt[3] - Sqrt[2] j) + E^(-Sqrt[3] h + Sqrt[2] j) + E^(Sqrt[3] h + Sqrt[2] j))] + 1/10 Log[E^(Sqrt[3] h + Sqrt[2] j)/( 2 E^(-(h/Sqrt[3])) + 2 E^(h/Sqrt[3]) + E^(-(h/Sqrt[3]) - Sqrt[2] j) + E^(h/Sqrt[3] - Sqrt[2] j) + E^(-Sqrt[3] h + Sqrt[2] j) + E^(Sqrt[3] h + Sqrt[2] j))]; ContourPlot @@ {o, {j, -1, 1}, {h, -1, 1}} FindMaximum @@ {o, {{j, -0.008983550852535105`}, {h, 0.06931364191023386`}}, Method -> "Newton"}

Answer1:

Mathematically, I'm not sure exactly why Netwon's method fails, but the examples in the <a href="http://reference.wolfram.com/mathematica/ref/FindMaximum.html#ExampleSection" rel="nofollow">documentation for FindMaximum</a> point out this specific problem and error message under <strong>Possible Issues</strong>: "<em>With machine-precision arithmetic, even functions with smooth maxima may seem bumpy</em>".

Thus, if you increase the working precision with e.g. the WorkingPrecision -> 20 option to FindMaximum the warnings go away:

In[25]:= FindMaximum[o, {{j, 0}, {h, 0}}, Method->"Newton", WorkingPrecision->20] Out[25]= {-2.0694248079871222533, {j -> -0.14189560954670761863, h -> 0}}

Given that the text of the error is fairly descriptive:

<blockquote>

FindMaximum::lstol: The line search decreased the step size to within the tolerance specified by AccuracyGoal and PrecisionGoal but was unable to find a sufficient increase in the function. You may need more than MachinePrecision digits of working precision to meet these tolerances. >>

</blockquote>

... I suspect Newton's method is failing to reached a fixed point with sufficiently small error using machine-precision arithmetic.

As the error message hints, you can instead use the AccuracyGoal option to specify the number of significant digits you want in the solution if you don't want to switch to slower high-precision arithmetic:

In[27]:= FindMaximum[o, {{j, 0}, {h, 0}}, Method -> "Newton", AccuracyGoal -> 5] Out[27]= {-2.06942, {j -> -0.141896, h -> -2.78113*10^-17}}

Hope that helps!

Recommend

  • API's similar to GLUTesselator? [closed]
  • error: 'varName' was not declared in this scope [duplicate]
  • exceptions.TypeError: src is not a numpy array, neither a scalar
  • how to calculate distance between two points in google maps?
  • Put percent labels next to legend instead of in the slice
  • HABTM associations in Rails : collecting and counting the categories of a model's children
  • Selectively hide background elements when overlayed with transparent div
  • Guava how to copy all files from one directory to another
  • Cut the background to expose the layer below
  • How can I tell a form not to dispose a particular control when it closes?
  • Hash Code in SQL Server?
  • quiver not drawing arrows just lots of blue, matlab
  • Intel-64 and ia32 atomic operations acquire-release semantics and GCC 5+
  • Read text file that is not in the main package in a runnable jar
  • RxJava debounce by arbitrary value
  • Eliminate partial duplicate rows from result set
  • D3 get axis values on zoom event
  • Excel's Macro-Recorder usage
  • C: Incompatible pointer type initializing
  • Custom validator control occupying space even though display set to dynamic
  • JSON response opens as a file, but I can't access it with JavaScript
  • How to use remove-erase idiom for removing empty vectors in a vector?
  • CSS Linear-gradient formatting issue accross different browsers
  • Validaiting emails with Net.Mail MailAddress
  • How to handle AllServersUnavailable Exception
  • Trying to switch camera back to front but getting exception
  • Which linear programming package should I use for high numbers of constraints and “warm starts” [clo
  • Javascript + PHP Encryption with pidCrypt
  • VBA Convert delimiter text file to Excel
  • How to get next/previous record number?
  • Free memory of cv::Mat loaded using FileStorage API
  • Angular 2 constructor injection vs direct access
  • How to CLICK on IE download dialog box i.e.(Open, Save, Save As…)
  • apache spark aggregate function using min value
  • Programmatically clearing map cache
  • Reading document lines to the user (python)
  • Observable and ngFor in Angular 2
  • How to Embed XSL into XML
  • UserPrincipal.Current returns apppool on IIS
  • Conditional In-Line CSS for IE and Others?