[petsc-dev] TAO method selection (was "coding style")

Munson, Todd tmunson at mcs.anl.gov
Fri Aug 19 06:13:30 CDT 2016


The only provable way to test for linearity of a function is using
code analysis.

A quick hack that should work okay is to evaluate the gradient at
two (or more) random points and calculate the distance between
the gradients.  Note: this is not a good test for piecewise 
linear functions, as you would need the random points to
lie in different regions to detect that the gradient is
not constant.

Something similar can be used for quadratics.  Here you evaluate
the Hessian at two random points.  You really want to calculate
the distance between the matrices.  I did not find that method 
in the PETSc documentation.  Therefore, I would compare the
values of Hessian vector products, H1*y - H2*y where y is
a random vector.

These hacks really prove that the function is not linear or 
not quadratic, but cannot truly establish that the function
is linear or quadratic.


> On Aug 19, 2016, at 2:40 AM, Marco Zocca <zocca.marco at gmail.com> wrote:
> How does a numerical method test for linearity (or in general order of
> nonlinearity) of an operator? By comparing function value with the
> first two Taylor terms, within machine precision?
> I suspect only code analysis ("reification", as in analysis of the
> expression syntax tree) would be feasible and reliable for general
> problems.

More information about the petsc-dev mailing list