implemented divided differences, rearranged functions