<div class="gmail_quote">On Fri, Jun 17, 2011 at 12:59, Tian(ICT) <span dir="ltr"><<a href="mailto:rongtian@ncic.ac.cn">rongtian@ncic.ac.cn</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div><font size="2">Appreciate the quick answering. I DID get the identical
solution, exact to all digital numbers (w and w/o
-snes_mf_operator).</font></div></blockquote><div><br></div><div>Please run both ways with -snes_view -snes_monitor and send the output.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div><font size="2">so second quick question: if the mesh happen to be structured
(say one square element), can finite differenced Jacobian be the exactly same as
the analytic one?</font></div></blockquote><div><br></div><div>Suppose there is no grid at all. Let f(x) = 3*x, the 3 is arbitrary. This is the simplest case because the function is actually linear, thus df(x,y) = 3*y. Now we compare</div>
<div><br></div><div>z1 = f(x + eps*y) - f(x) / eps = (3*(x + eps*y) - 3*x)/eps;</div><div><br></div><div>z2 = df(x,y) = 3*y;</div><div><br></div><div>Since floating point arithmetic is not associative, these are not the same. For example, taking x=1, y=2, eps = 1e-8, we have</div>
<div><br></div><div>z1 = 6.000000052353016</div><div>z2 = 6.000000000000000</div><div><br></div><div>If it's not exact for a linear scalar problem with all coefficients, inputs, and (exact) outputs exactly representable in floating point arithmetic, then it's pretty unlikely to be exact for any PDE.</div>
<div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div><font size="2"> Or the exactly same solution whether -snes_mf_operator
or not implies something wrong in my code?</font></div></blockquote></div><br><div>It's more likely that the same algorithm is used in both cases, -snes_view should tell us what's happening.</div>