Using Automatic Di erentiation for Second-Order Matrix-freeMethods in PDE-constrained