updated differentiate function. fixed right boundary bug, adjusted tests