% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/HelperFunctions.R
\name{approx_grad}
\alias{approx_grad}
\title{Finite-difference Gradient Computer}
\usage{
approx_grad(x, fn, eps = sqrt(.Machine$double.eps))
}
\arguments{
\item{x}{Numeric vector of function arguments}

\item{fn}{Function returning list(objective, gradient)}

\item{eps}{Numeric scalar, finite difference tolerance}
}
\value{
Numeric vector of finite-difference approximated gradient values in
  the current optimizer sign convention
}
\description{
Computes a finite-difference approximation derived from the objective in
\code{fn} at \code{x}, returned in the sign convention currently used by
\code{efficient_bfgs}.
}
\details{
Used within \code{efficient_bfgs} when \code{fn} does not supply a usable
gradient. In the main \code{lgspline()} correlation-optimization path,
\code{stats::optim()} is used instead when no analytic REML gradient is
available. Internally this helper returns the negated central-difference
approximation rather than the raw derivative.
}
\keyword{internal}
