According to Wolfram Alpha and the Sage computer algebra system, the following identity holds: $$ \cos\left(\arctan\left(\frac{l_1-l_2}{d}\right)\right) = \frac{1}{\sqrt{1 + \frac{(l_1-l_2)^2}{d^2}}} $$
However, when I tried to verify it with an arbitrary example in NumPy, I noticed a rather large difference in the actual values computed by both sides of the idenitity. I have used the following code:
l1 = 10; l2 = 8; d = 17
from numpy import arctan2, cos, sin, sqrt
alpha = arctan2((l1-l2),d)
left = cos(alpha)
right = sqrt(1 + ((l1-l2)**2)/(d**2))
Evaluating the results for left
and right
yielded the following:
left = 0.99315060432287616
right = 1.0
It is tempting to write this off as simply being a numerical error, but since I have very little experience in how large numerical errors can get, I am not so sure. Is this possible or am I missing something (obvious)?
right
is incorrectly entered. it should beright = 1/sqrt()
When I enter the formulas into my Ti-89 I get a match out to 12 digits at 0.99315... $\endgroup$