I get ValueError: math domain error
when trying to compute the angle between two vectors using math.acos
:
import numpy as np
from math import acos, sqrt
x1 = np.array([12.001, 13.001, 14.001])
x2 = np.array([-12.001, -13.001, -14.001])
mom1 = sqrt(x1.dot(x1))
mom2 = sqrt(x2.dot(x2))
son = x1.dot(x2)
c = son / mom1 / mom2
theta_rad = acos(c)
And I get:
ValueError: math domain error