Eigen levenbergmarquardt in Stan

Wiling to do a curve fitting within Stan, I came along Eigen’s Levenberg-Marquardt Algorithm.
I nice way to use the routines are shown in:

I would code my optimization function directly in the routine as shown in the stackoverflow example.

Now my question is:

Are the derivates required? In other words what does the function signature in Stan may look like?
Is the var implementation required or is just implementing the double version enough?

(I suppose the derivatives are not needed, since min f^2 force them be to 0)

For Stan, we need derivatives of functions w.r.t. any arguments that depend on parameters.

If you’re asking what we require to accept a new function in Stan, we need derivatives w.r.t. all input arguments that aren’t required to be data. This can lead to a lot of combinatorics as the type of each argument is independent. The exception is our higher-order functions like ODE solvers—those have some arguments that are required to be data.