<div dir="ltr"><div dir="ltr">On Fri, Oct 9, 2020 at 4:53 AM baikadi pranay <<a href="mailto:pranayreddy865@gmail.com">pranayreddy865@gmail.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr">Hello,<br>I have a couple of questions regarding how SNESSetFunction,SNESSetJacobian and SNESSolve work together. I am trying to solve a nonlinear system of the form A(x)x=b(x). I am using Fortran90. The way I intend to solve the above equation is as follows:<br>Step 1: initialize x with an initial guess</div><div>Step 2: Solve using SNESSolve for (x^i, i is the iteration number, i=1,2,3...)</div><div>Step 3: Calculate the update and check if it is less than tolerance</div><div>Step 4: If yes, end the loop. Else the jacobian matrix and function should be updated using x^(i) and go back to step 2.<br></div></div></blockquote><div><br></div><div>You are describing the Picard iteration:</div><div><br></div><div>  <a href="https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/SNES/SNESSetPicard.html">https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/SNES/SNESSetPicard.html</a></div><div><br></div><div>You can do this, but it will converge more slowly than Newton. We usually advise using Newton.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>The part which is a little confusing to me is in understanding how to update the jacobian matrix and the function F (= A(x)x-b(x)). <br><br>1) Should I explicitly call the subroutines Form Function and FormJacobian by using x^i as the input argument or is this automatically taken care of when I go back to step 2 and call SNESSolve?<br></div></div></blockquote><div><br></div><div>No. SNES calls these automatically.</div><div><br></div><div>  Thanks,</div><div><br></div><div>     Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>2) If the answer to the above question is yes, I do not fully understand the role played by the functions SNESSetFunction and SNESSetJacobian.<br><br>I apologize if I am not clear in my explanation. I would be glad to elaborate on any section of my question. Please let me know if you need any further information from my side.<br><br>Thank you,<br>Sincerely,<br>Pranay.</div></div><div hspace="streak-pt-mark" style="max-height:1px"><img alt="" style="width: 0px; max-height: 0px; overflow: hidden;" src="https://mailfoogae.appspot.com/t?sender=acHJhbmF5cmVkZHk4NjVAZ21haWwuY29t&type=zerocontent&guid=af74088e-1b2d-4959-a8dc-d23913da4f3e"><font color="#ffffff" size="1">ᐧ</font></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>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><br></div><div><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div></div></div>