calc_ab function

Calculate slope and intercept