I am trying to compute the nth order (lets say, 30th) derivative of simple functions like sin or cos but its diverging, here is my code: