<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;"><br><div><br><blockquote type="cite"><div>On Mar 7, 2023, at 12:19 PM, Angus, Justin Ray <angus1@llnl.gov> wrote:</div><br class="Apple-interchange-newline"><div><meta charset="UTF-8"><div class="WordSection1" style="page: WordSection1; caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">Hi Matthew,<o:p></o:p></div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;"><o:p> </o:p></div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">Thank you for the reply. But my question was really related to what Barry had said – the BT method will use the full step as long as it leads to some decease in the function norm. The full step does indeed satisfy this condition, but the BT method does not seem to be using the full step. Why?<o:p></o:p></div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;"><o:p> </o:p></div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">Is it because the step value is larger than the default maxstep? I don’t know what that value is or how to find it.</div></div></div></blockquote><div><br></div>   The easiest way is to run in a debugger and put in a break point for SNESLineSearchApply_BT(). Step to see exactly what decision it is making</div><div><br></div><div>   You can see the parameters used by running with -snes_view_pre (here pre means to display the parameters before the solve is done). </div><div><br></div><div>   The line search default values are set in SNESLineSearchCreate() in src/snes/linesearch/interface/linesearch.c  It defaults to a huge value linesearch->maxstep      = 1e8;</div><div><br></div><div>   If you use VSCode or some other programming environment you can set it up to find things in the PETSc source easily <a href="https://petsc.org/release/docs/manual/other/#visual-studio-code-users">https://petsc.org/release/docs/manual/other/#visual-studio-code-users</a></div><div><br></div><div>  Barry</div><div><br></div><div><br></div><div><br><blockquote type="cite"><div><div class="WordSection1" style="page: WordSection1; caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;"><o:p></o:p></div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;"><o:p> </o:p></div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">-Justin<o:p></o:p></div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;"><o:p> </o:p></div><div style="border-style: solid none none; border-top-width: 1pt; border-top-color: rgb(181, 196, 223); padding: 3pt 0in 0in;"><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;"><b><span style="font-size: 12pt;">From:<span class="Apple-converted-space"> </span></span></b><span style="font-size: 12pt;">Matthew Knepley <<a href="mailto:knepley@gmail.com" style="color: blue; text-decoration: underline;">knepley@gmail.com</a>><br><b>Date:<span class="Apple-converted-space"> </span></b>Tuesday, March 7, 2023 at 9:16 AM<br><b>To:<span class="Apple-converted-space"> </span></b>"Angus, Justin Ray" <<a href="mailto:angus1@llnl.gov" style="color: blue; text-decoration: underline;">angus1@llnl.gov</a>><br><b>Cc:<span class="Apple-converted-space"> </span></b>Barry Smith <<a href="mailto:bsmith@petsc.dev" style="color: blue; text-decoration: underline;">bsmith@petsc.dev</a>>, "<a href="mailto:petsc-dev@mcs.anl.gov" style="color: blue; text-decoration: underline;">petsc-dev@mcs.anl.gov</a>" <<a href="mailto:petsc-dev@mcs.anl.gov" style="color: blue; text-decoration: underline;">petsc-dev@mcs.anl.gov</a>><br><b>Subject:<span class="Apple-converted-space"> </span></b>Re: [petsc-dev] SNESNEWTONLS<o:p></o:p></span></div></div><div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;"><o:p> </o:p></div></div><div><div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">On Tue, Mar 7, 2023 at 12:03 PM Angus, Justin Ray via petsc-dev <<a href="mailto:petsc-dev@mcs.anl.gov" style="color: blue; text-decoration: underline;">petsc-dev@mcs.anl.gov</a>> wrote:<o:p></o:p></div></div><div><blockquote style="border-style: none none none solid; border-left-width: 1pt; border-left-color: rgb(204, 204, 204); padding: 0in 0in 0in 6pt; margin-left: 4.8pt; margin-right: 0in;" type="cite"><div><div><div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">Hi Barry,<o:p></o:p></div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;"> <o:p></o:p></div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">Very helpful.<o:p></o:p></div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;"> <o:p></o:p></div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">I’m still having some trouble with reconciling your answer to question number 2 based on some recent observations I have had. I’ve shared 1 slide concerning that observation, which I will briefly describe below.<o:p></o:p></div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;"> <o:p></o:p></div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">I have a code that uses petsc but also has a native JFNK solver that works in the standard textbook way and always uses the full newton step. I recently found that the SNES newton solver in petsc with default options was failing on step 1 of a simulation, while our native solver worked fine. The fix for petsc was to switch from backtracking line search to basic.<o:p></o:p></div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;"> <o:p></o:p></div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">Based in the information in the slide, can you make sense of this behavior?<o:p></o:p></div></div></div></div></blockquote><div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;"><o:p> </o:p></div></div><div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">Sure. It is completely possible to converge using full steps when you do not converge using BT. All of the convergence proofs<o:p></o:p></div></div><div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">are predicated on starting "close enough" to the solution. You can start far away, take full steps, and by chance get into the basin of<o:p></o:p></div></div><div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">convergence. BT, that is trying to guarantee convergence, will fail. There are a very small number of cases for which we can<o:p></o:p></div></div><div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">guarantee global convergence.<o:p></o:p></div></div><div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;"><o:p> </o:p></div></div><div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">  Thanks,<o:p></o:p></div></div><div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;"><o:p> </o:p></div></div><div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">     Matt<o:p></o:p></div></div><div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;"> <o:p></o:p></div></div><blockquote style="border-style: none none none solid; border-left-width: 1pt; border-left-color: rgb(204, 204, 204); padding: 0in 0in 0in 6pt; margin-left: 4.8pt; margin-right: 0in;" type="cite"><div><div><div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">-Justin<o:p></o:p></div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;"> <o:p></o:p></div><div style="border-style: solid none none; border-top-width: 1pt; border-top-color: rgb(181, 196, 223); padding: 3pt 0in 0in;"><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;"><b><span style="font-size: 12pt;">From:<span class="Apple-converted-space"> </span></span></b><span style="font-size: 12pt;">Barry Smith <<a href="mailto:bsmith@petsc.dev" target="_blank" style="color: blue; text-decoration: underline;">bsmith@petsc.dev</a>><br><b>Date:<span class="Apple-converted-space"> </span></b>Tuesday, March 7, 2023 at 8:52 AM<br><b>To:<span class="Apple-converted-space"> </span></b>"Angus, Justin Ray" <<a href="mailto:angus1@llnl.gov" target="_blank" style="color: blue; text-decoration: underline;">angus1@llnl.gov</a>><br><b>Cc:<span class="Apple-converted-space"> </span></b>"<a href="mailto:petsc-dev@mcs.anl.gov" target="_blank" style="color: blue; text-decoration: underline;">petsc-dev@mcs.anl.gov</a>" <<a href="mailto:petsc-dev@mcs.anl.gov" target="_blank" style="color: blue; text-decoration: underline;">petsc-dev@mcs.anl.gov</a>><br><b>Subject:<span class="Apple-converted-space"> </span></b>Re: [petsc-dev] SNESNEWTONLS</span><o:p></o:p></div></div><div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;"> <o:p></o:p></div></div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;"> <o:p></o:p></div><div><p class="MsoNormal" style="margin: 0in 0in 12pt; font-size: 11pt; font-family: Calibri, sans-serif;"><o:p> </o:p></p><blockquote style="margin-top: 5pt; margin-bottom: 5pt;" type="cite"><div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">On Mar 7, 2023, at 11:36 AM, Angus, Justin Ray via petsc-dev <<a href="mailto:petsc-dev@mcs.anl.gov" target="_blank" style="color: blue; text-decoration: underline;">petsc-dev@mcs.anl.gov</a>> wrote:<o:p></o:p></div></div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;"> <o:p></o:p></div><div><div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">Hello,<o:p></o:p></div></div><div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;"> <o:p></o:p></div></div><div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">I’ve been using the default newton line search nonlinear solver in petsc. I recently discovered that the default line search method is bt – backtracking. I have two questions.<o:p></o:p></div></div><div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;"> <o:p></o:p></div></div><ol start="1" type="1" style="margin-bottom: 0in; margin-top: 0in;"><li class="m-3083750946028205497msolistparagraph" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">How exactly does the backtracking line search use the L2 norm of the function to modify the newton step? What is the formula?<o:p></o:p></li></ol></div></blockquote><div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;"> <o:p></o:p></div></div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">   <a href="https://urldefense.us/v3/__https:/petsc.org/main/src/snes/linesearch/impls/bt/linesearchbt.c.html*SNESLINESEARCHBT__;Iw!!G2kpM7uM-TzIFchu!gRMzIDCT2gk_bmfyFDMW_2hqc18xUq_eOd-GQOXGkPsHzw_F01t55J_ab98JKVI$" target="_blank" style="color: blue; text-decoration: underline;">https://petsc.org/main/src/snes/linesearch/impls/bt/linesearchbt.c.html#SNESLINESEARCHBT</a><o:p></o:p></div></div><div><p class="MsoNormal" style="margin: 0in 0in 12pt; font-size: 11pt; font-family: Calibri, sans-serif;"><o:p> </o:p></p><blockquote style="margin-top: 5pt; margin-bottom: 5pt;" type="cite"><div><ol start="1" type="1" style="margin-bottom: 0in; margin-top: 0in;"><li class="m-3083750946028205497msolistparagraph" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;"><span style="font-size: 12pt;"> </span><o:p></o:p></li><li class="m-3083750946028205497msolistparagraph" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">Why is backtracking default? I would think that the basic method, which is a standard Newton method, would be default.<o:p></o:p></li></ol></div></blockquote><div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;"> <o:p></o:p></div></div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">   All SNES Newton line searches use the full Newton step if it satisfies the Wolf conditions (there is some decrease in the function norm) and if the full Newton step is selected there is no nontrivial extra costs from using a line search (since the line search is never done) so there is no reason not to default to using SNESLINESEARCHBT. While using ONLY the full-step there may not convergence for many situations.  Hence our default.<o:p></o:p></div></div><div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;"> <o:p></o:p></div></div><div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;"> <o:p></o:p></div></div><div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;"> <o:p></o:p></div></div><div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;"> <o:p></o:p></div></div><div><p class="MsoNormal" style="margin: 0in 0in 12pt; font-size: 11pt; font-family: Calibri, sans-serif;"><o:p> </o:p></p><blockquote style="margin-top: 5pt; margin-bottom: 5pt;" type="cite"><div><ol start="2" type="1" style="margin-bottom: 0in; margin-top: 0in;"><li class="m-3083750946028205497msolistparagraph" style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;"><span style="font-size: 12pt;"> </span><o:p></o:p></li></ol><div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;"> <o:p></o:p></div></div><div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">-Justin<o:p></o:p></div></div></div></blockquote></div><p class="MsoNormal" style="margin: 0in 0in 12pt; font-size: 11pt; font-family: Calibri, sans-serif;"><o:p> </o:p></p></div></div></div></blockquote></div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;"><br clear="all"><o:p></o:p></div><div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;"><o:p> </o:p></div></div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">--<span class="Apple-converted-space"> </span><o:p></o:p></div><div><div><div><div><div><div><div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;">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<o:p></o:p></div></div><div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;"><o:p> </o:p></div></div><div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;"><a href="https://urldefense.us/v3/__http:/www.cse.buffalo.edu/*knepley/__;fg!!G2kpM7uM-TzIFchu!j3AGZCLzChJI9AkGBKcae0TA2fNh_B_Y_Isx1koEbyAOIQVPHznYaIG73_xzqJw$" target="_blank" style="color: blue; text-decoration: underline;">https://www.cse.buffalo.edu/~knepley/</a></div></div></div></div></div></div></div></div></div></div></div></blockquote></div><br></body></html>