I am trying to find roots of a function using Newton and using its derivative. But I am not sure how to define its derivative in a way that Newton doesn\'t throw an IndexErr