Minimization achived with BFBD using gradient expression

Both gradient expression and gradient finite-differences approximation do not match in some coefficients but I assume its because they are close to zero and the approximation may differ.