Midpoint Displacement Algorithm 1D Implementation