<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Mar 30, 2017 at 7:09 PM, Gideon Simpson <span dir="ltr"><<a href="mailto:gideon.simpson@gmail.com" target="_blank">gideon.simpson@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">About a month ago, I mentioned that I was trying to set up a projected integration scheme within petsc, where I use a classical integrator (i.e., RK4), at each time step, and then correct my prediction dependent variable, yp, by solving a nonlinear equation g(y + lambda * f(yp)) =0 for a scalar parameter lambda.  Out of stubbornness, I did this entirely within the confines of petsc, using a SNES.  Following up on a comment of Barry’s, about the solver taking an excessive number of function evaluations, I realized that, in fact, the SNES was failing to converge (algorithmically), even though it was giving reasonable answers.  In particular, I see output like what is displayed below.<div><br></div><div>I am using the default snes/ksp solvers with default tolerances.  It would seem to me that I should have been quite happy after 1 SNES iteration, given that this is a scalar problem.  This can obviously be done by setting the atol to something like 1e-12, but I was curious if people had other thoughts on this.</div></div></blockquote><div><br></div><div>I think its possible that your Jacobian is not accurate enough to converge below 1e-13, or that your residual evaluation</div><div>is no longer accurate below that. I would set the atol as you suggest.</div><div><br></div><div>   Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><div><div><div style="margin:0px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)"><span style="font-variant-ligatures:no-common-ligatures">  0 SNES Function norm 5.142950291311e-10 </span></div><div style="margin:0px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)"><span style="font-variant-ligatures:no-common-ligatures">    0 KSP Residual norm 6.057087103783e-11 </span></div><div style="margin:0px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)"><span style="font-variant-ligatures:no-common-ligatures">    1 KSP Residual norm 1.681179391195e-26 </span></div><div style="margin:0px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)"><span style="font-variant-ligatures:no-common-ligatures">      Line search: Using full step: fnorm 5.142950291311e-10 gnorm 5.783398860650e-14</span></div><div style="margin:0px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)"><span style="font-variant-ligatures:no-common-ligatures">  1 SNES Function norm 5.783398860650e-14 </span></div><div style="margin:0px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)"><span style="font-variant-ligatures:no-common-ligatures">    0 KSP Residual norm 5.520053977167e-15 </span></div><div style="margin:0px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)"><span style="font-variant-ligatures:no-common-ligatures">    1 KSP Residual norm 1.370372252609e-30 </span></div><div style="margin:0px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)"><span style="font-variant-ligatures:no-common-ligatures">      Line search: gnorm after quadratic fit 5.728578676879e-14</span></div><div style="margin:0px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)"><span style="font-variant-ligatures:no-common-ligatures">      Line search: Quadratically determined step, lambda=3.9611360239162957e-01</span></div><div style="margin:0px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)"><span style="font-variant-ligatures:no-common-ligatures">  2 SNES Function norm 5.728578676879e-14 </span></div><div style="margin:0px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)"><span style="font-variant-ligatures:no-common-ligatures">    0 KSP Residual norm 5.024285935857e-15 </span></div><div style="margin:0px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)"><span style="font-variant-ligatures:no-common-ligatures">    1 KSP Residual norm 2.789038964144e-31 </span></div><div style="margin:0px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)"><span style="font-variant-ligatures:no-common-ligatures">      Line search: gnorm after quadratic fit 4.278033777465e-14</span></div><div style="margin:0px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)"><span style="font-variant-ligatures:no-common-ligatures">      Line search: Quadratically determined step, lambda=2.4691358024691357e-01</span></div><div style="margin:0px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)"><span style="font-variant-ligatures:no-common-ligatures">  3 SNES Function norm 4.278033777465e-14 </span></div><div style="margin:0px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)"><span style="font-variant-ligatures:no-common-ligatures">    0 KSP Residual norm 3.520343148370e-15 </span></div><div style="margin:0px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)"><span style="font-variant-ligatures:no-common-ligatures">    1 KSP Residual norm 5.527264229234e-31 </span></div><div style="margin:0px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)"><span style="font-variant-ligatures:no-common-ligatures">      Line search: gnorm after quadratic fit 2.842170943040e-14</span></div><div style="margin:0px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)"><span style="font-variant-ligatures:no-common-ligatures">      Line search: Quadratically determined step, lambda=2.5438596491228038e-01</span></div><div style="margin:0px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)"><span style="font-variant-ligatures:no-common-ligatures">  4 SNES Function norm 2.842170943040e-14 </span></div><div style="margin:0px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)"><span style="font-variant-ligatures:no-common-ligatures">    0 KSP Residual norm 2.016428211944e-15 </span></div><div style="margin:0px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)"><span style="font-variant-ligatures:no-common-ligatures">    1 KSP Residual norm 2.238685028403e-31 </span></div><div style="margin:0px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)"><span style="font-variant-ligatures:no-common-ligatures">      Line search: gnorm after quadratic fit 5.695433295430e-14</span></div><div style="margin:0px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)"><span style="font-variant-ligatures:no-common-ligatures">      Line search: Cubic step no good, shrinking lambda, current gnorm 4.278033777465e-14 lambda=1.0000000000000002e-02</span></div><div style="margin:0px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)"><span style="font-variant-ligatures:no-common-ligatures">      Line search: Cubic step no good, shrinking lambda, current gnorm 2.842170943040e-14 lambda=1.0000000000000002e-03</span></div><div style="margin:0px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)"><span style="font-variant-ligatures:no-common-ligatures">      Line search: Cubic step no good, shrinking lambda, current gnorm 2.842170943040e-14 lambda=5.0000000000000012e-04</span></div><div style="margin:0px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)"><span style="font-variant-ligatures:no-common-ligatures">      Line search: Cubic step no good, shrinking lambda, current gnorm 2.842170943040e-14 lambda=2.1132486540518717e-04</span></div><div style="margin:0px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)"><span style="font-variant-ligatures:no-common-ligatures">      Line search: Cubic step no good, shrinking lambda, current gnorm 2.842170943040e-14 lambda=9.2196144189362134e-05</span></div><div style="margin:0px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)"><span style="font-variant-ligatures:no-common-ligatures">      Line search: Cubic step no good, shrinking lambda, current gnorm 2.842170943040e-14 lambda=4.0004514620095227e-05</span></div><div style="margin:0px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)"><span style="font-variant-ligatures:no-common-ligatures">      Line search: Cubic step no good, shrinking lambda, current gnorm 2.842170943040e-14 lambda=1.7374756353482527e-05</span></div><div style="margin:0px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)"><span style="font-variant-ligatures:no-common-ligatures">      Line search: Cubic step no good, shrinking lambda, current gnorm 2.842170943040e-14 lambda=7.5449506476837614e-06</span></div><div style="margin:0px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)"><span style="font-variant-ligatures:no-common-ligatures">      Line search: Cubic step no good, shrinking lambda, current gnorm 2.842170943040e-14 lambda=3.2764733594125655e-06</span></div><div style="margin:0px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)"><span style="font-variant-ligatures:no-common-ligatures">      Line search: Cubic step no good, shrinking lambda, current gnorm 2.842170943040e-14 lambda=1.4228354923470249e-06</span></div><div style="margin:0px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)"><span style="font-variant-ligatures:no-common-ligatures">      Line search: Cubic step no good, shrinking lambda, current gnorm 2.842170943040e-14 lambda=6.1787855254724169e-07</span></div><div style="margin:0px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)"><span style="font-variant-ligatures:no-common-ligatures">      Line search: Cubic step no good, shrinking lambda, current gnorm 2.842170943040e-14 lambda=2.6831903567985152e-07</span></div><div style="margin:0px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)"><span style="font-variant-ligatures:no-common-ligatures">      Line search: Cubic step no good, shrinking lambda, current gnorm 2.842170943040e-14 lambda=1.1651983473611860e-07</span></div><div style="margin:0px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)"><span style="font-variant-ligatures:no-common-ligatures">      Line search: Cubic step no good, shrinking lambda, current gnorm 2.842170943040e-14 lambda=5.0599733967314922e-08</span></div><div style="margin:0px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)"><span style="font-variant-ligatures:no-common-ligatures">      Line search: Cubic step no good, shrinking lambda, current gnorm 2.842170943040e-14 lambda=2.1973366898757625e-08</span></div><div style="margin:0px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)"><span style="font-variant-ligatures:no-common-ligatures">      Line search: Cubic step no good, shrinking lambda, current gnorm 2.842170943040e-14 lambda=9.5421223580158174e-09</span></div><div style="margin:0px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)"><span style="font-variant-ligatures:no-common-ligatures">      Line search: Cubic step no good, shrinking lambda, current gnorm 2.842170943040e-14 lambda=4.1437481801087470e-09</span></div><div style="margin:0px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)"><span style="font-variant-ligatures:no-common-ligatures">      Line search: Cubic step no good, shrinking lambda, current gnorm 2.842170943040e-14 lambda=1.7994580593128418e-09</span></div><div style="margin:0px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)"><span style="font-variant-ligatures:no-common-ligatures">      Line search: Cubic step no good, shrinking lambda, current gnorm 2.842170943040e-14 lambda=7.8143004026450871e-10</span></div><div style="margin:0px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)"><span style="font-variant-ligatures:no-common-ligatures">      Line search: Cubic step no good, shrinking lambda, current gnorm 2.842170943040e-14 lambda=3.3934267301617141e-10</span></div><div style="margin:0px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)"><span style="font-variant-ligatures:no-common-ligatures">      Line search: Cubic step no good, shrinking lambda, current gnorm 2.842170943040e-14 lambda=1.4736245574944127e-10</span></div><div style="margin:0px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)"><span style="font-variant-ligatures:no-common-ligatures">      Line search: Cubic step no good, shrinking lambda, current gnorm 2.842170943040e-14 lambda=6.3993405755577026e-11</span></div><div style="margin:0px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)"><span style="font-variant-ligatures:no-common-ligatures">      Line search: Cubic step no good, shrinking lambda, current gnorm 2.842170943040e-14 lambda=2.7789683331288042e-11</span></div><div style="margin:0px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)"><span style="font-variant-ligatures:no-common-ligatures">      Line search: Cubic step no good, shrinking lambda, current gnorm 2.842170943040e-14 lambda=1.2067907474762995e-11</span></div><div style="margin:0px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)"><span style="font-variant-ligatures:no-common-ligatures">      Line search: Cubic step no good, shrinking lambda, current gnorm 2.842170943040e-14 lambda=5.2405919521750200e-12</span></div><div style="margin:0px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)"><span style="font-variant-ligatures:no-common-ligatures">      Line search: Cubic step no good, shrinking lambda, current gnorm 2.842170943040e-14 lambda=2.2757718408626572e-12</span></div><div style="margin:0px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)"><span style="font-variant-ligatures:no-common-ligatures">      Line search: Cubic step no good, shrinking lambda, current gnorm 2.842170943040e-14 lambda=9.8827337043745462e-13</span></div><div style="margin:0px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)"><span style="font-variant-ligatures:no-common-ligatures">      Line search: unable to find good step length! After 27 tries </span></div><div style="margin:0px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)"><span style="font-variant-ligatures:no-common-ligatures">      Line search: fnorm=2.8421709430404007e-14, gnorm=2.8421709430404007e-14, ynorm=2.0164282119435693e-15, minlambda=9.9999999999999998e-<wbr>13, lambda=9.8827337043745462e-13, initial slope=-8.0779356694631465e-28</span></div><span class="HOEnZb"><font color="#888888"><div><span style="font-variant-ligatures:no-common-ligatures"><br></span></div><div><br></div><div><br><div>
<span class="m_7374607929684575007Apple-style-span" style="border-collapse:separate;font-variant-ligatures:normal;font-variant-east-asian:normal;line-height:normal;border-spacing:0px">-gideon</span>

</div>

<br></div></font></span></div></div></div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener</div>
</div></div>