<html aria-label="message body"><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;"><div><br></div> At first glance the output is surprising. I believe your understanding is correct and something is going very wrong to produce the output you report. <div><br></div><div> Is there any way you can share the code that produces this output (if you send it to petsc-maint@mcs.anl.gov the code will never be shared outside the PETSc developers who monitor that email).</div><div><br></div><div> Barry</div><div><br id="lineBreakAtBeginningOfMessage"><div><br><blockquote type="cite"><div>On Mar 2, 2026, at 10:09 AM, Matteo Semplice via petsc-users <petsc-users@mcs.anl.gov> wrote:</div><br class="Apple-interchange-newline"><div>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<div><p>Dear all,</p><p> the following output from -snes_test_jacobian_view lokks
clear enough to pinpoint my mistake (I must be putting jacobian
elements in the wrong place), but it nevertheless left me
suprised.</p>
<font face="monospace">0 SNES Function norm 2.945516399303e-01<br>
---------- Testing Jacobian -------------<br>
Testing hand-coded Jacobian, if (for double precision runs) ||J
- Jfd||_F/||J||_F is<br>
O(1.e-8), the hand-coded Jacobian is probably correct.<br>
||J - Jfd||_F/||J||_F = 0.000121529, ||J - Jfd||_F = 0.395752<br>
Hand-coded Jacobian ----------<br>
Mat Object: 4 MPI processes<br>
row 84: (84, 60.) (85, 0.) <font color="#ed5c57">(3446,
-80.) </font> (3447, 0.) <font color="#ed5c57"> (6808,
20.) </font> (6809, 0.) <br>
row 85: (84, 0.00914434) (85, 1.) (3446, 0.)
(3447, 0.) (6808, 0.) (6809, 0.) <br>
<br>
Finite difference Jacobian ----------<br>
Mat Object: 4 MPI processes<br>
type: mpiaij<br>
row 84: (84, 60.) <font color="#ed5c57">(1806, -80.) </font>
<font color="#ed5c57"> (3528, 20.) </font> <br>
row 85: (85, 0.999971)<br>
<br>
Hand-coded minus finite-difference Jacobian with tolerance 1e-05
----------<br>
Mat Object: 4 MPI processes<br>
type: mpiaij<br>
<font color="#ed5c57">row 84:</font> <br>
row 85: (84, 0.00914434) (85, 2.9293e-05)</font><p>The difference of the two matrices shoudl be nonzero in row 84
for all elements 1806, 3528, 3446, 6808. Is it intended that the
difference is shown only for matrix elements that are present in
both the hand-coded and the FD jacobian?</p><p>I would have expected an output like</p><p>row 84: (1806,80.) (3446,-80.), etc</p><p>(This was on
<span style="font-family:monospace"><span style="background-color: rgb(255, 255, 255);">PETSc Release
Version 3.24.2</span>)</span>
</p><p>Thanks</p><p> Matteo</p>
<pre class="moz-signature" cols="72">--
Prof. Matteo Semplice
Università degli Studi dell’Insubria
Dipartimento di Scienza e Alta Tecnologia – DiSAT
Professore Associato
Via Valleggio, 11 – 22100 Como (CO) – Italia
tel.: +39 031 2386316</pre>
</div>
</div></blockquote></div><br></div></body></html>