midpoint function

Midpoint