implement the finite diff for sd