Your code is doing a log
of a number that is less than or equal to zero. That's mathematically undefined, so Python's log
function raises an exception. Here's an example:
>>> from math import log
>>> log(-1)
Traceback (most recent call last):
File "<pyshell#59>", line 1, in <module>
log(-1)
ValueError: math domain error
Without knowing what your newtonRaphson2
function does, I'm not sure I can guess where the invalid x[2]
value is coming from, but hopefully this will lead you on the right track.