auto pow2( double x ){ return x^^2; } assertEqApprox( df( &pow2, 1 ), 2.0, 2e-6 ); assertEqApprox( df( &pow2, 3 ), 6.0, 2e-6 ); assertEqApprox( df( &pow2, -2 ), -4.0, 2e-6 );
See Implementation