The acos of a number that exceeds 1 or -1 is complex. This is the ONLY way that can happen, at least unless you have defined your own acos function, or the argument itself is already complex.
>> acos(1 + eps)
ans =
0 + 2.1073e-08i
>> acos(-1 - eps)
ans =
3.1416 - 2.1073e-08i
>> acos(1 + i)
ans =
0.90456 - 1.0613i
And it certainly LOOKS as if those arguments were between -1 and 1, right?
>> 1 + eps
ans =
1
>> -1 - eps
ans =
-1
Surely your eyes could not deceive you. Or could they? My point is, even though the number 1+eps LOOKS like it is 1, and gets reported as being 1 to as close as the command window can show, acos can tell the difference.
So, even though you are absolutely, 110% positive the arguments to acos are always falling in the interval [-1,1], I would bet you are mistaken here. I think I'm going to make money on that bet too. If you get a complex result some of the time, then there are only two ways that can happen (again, unless you have defined your own acos function.)
Best Answer