Experimenting with midpoint gradient function.
Use 3 or more samples.