Plumb in optimization with analytic derivatives