# [petsc-users] Question regarding preconditioning in L-BFGS

Barry Smith bsmith at mcs.anl.gov
Wed Jul 1 13:26:42 CDT 2015

```> On Jul 1, 2015, at 1:19 AM, Michael White <mrwhite at umn.edu> wrote:
>
> Hello,
>
> I am not quite sure how to use the L-BFGS implementation in PETSc with a preconditioner that approximates the Jacobian.

The documentation in the manual pages is terrible for this.

> As far as I understand it, L-BFGS is like Newton's Method but doesn't require the user to input the Jacobian matrix.

Correct. BFGS builds a rank-k approximation to the (inverse) of the Jacobian at each iteration k. By default in PETSc for the zero iteration it uses the identity as the initial approximation of the (inverse) of the Jacobian which is generally not so good. However instead of using the identity it can use a matrix (which approximates the Jacobian) for the  initial approximation of the (inverse) of the Jacobian and then build a rank k update to that approximation. Essentially you can think of this as running the basic BFGS algorithm on the new problem B*F(u) where B is the preconditioner for the Jacobian you provided at the first iteration. (Note that if you provide the true Jacobian as your "approximate" Jacobian then the first iteration (but not the later iterations) is exactly the same as the first iteration with Newtons' method).

> However, for my application, I do have a good preconditioner that approximates the Jacobian matrix.

You don't mean this. A "good preconditioner" cannot approximate the Jacobian matrix. A good preconditioner needs to approximate the inverse of the Jacobian.
So either

1) you have a "good preconditioner" that is, an operator that approximates the inverse of the Jacobian or

2) or a sparse matrix that approximates the Jacobian from which you hope a reasonable preconditioner can be constructed.

Based on your other text I am guessing you have 2.

> My question is where to input such a preconditioner. I have 3 possible guesses about the correct way to do it.
>
> 1. Use SNESSetJacobian to provide a function which computes the preconditioner. I'm unsure if this information is even used though, since L-BFGS builds its own approximation to the inverse Jacobian as it goes.
>
> 2. Use SNESQNSetScaleType with SNES_QN_SCALE_JACOBIAN to set my preconditioner as an initial approximation to the Jacobian somehow?

You must use 1) and 2) together.  What happens is QN computes the preconditioner B at the first iteration and uses that in combination with the rank k "update" to approximate the future Jacobians.

Barry

>
> 3. Use an SNESSetNPC with my preconditioner as a linear preconditioner?
>
> Anyone that could point me in the right direction would be greatly appreciated.
>
> Best regards,
> Michael White
>
>

```