note
syphilis
<I>I'd not expect perl to return exactly zero to sin(pi) and I don't get it, but 1.22464679914735e-16</I><br><br>
The reliance on the sine and cosine trig functions can be seen at [https://www.math.toronto.edu/mathnet/questionCorner/complexexp.html].
<br>For the case under consideration in this thread, the imaginary component should be <c>sin(3.1415926535897931 * log(2.7182818284590451))</c>
<br><c>log(2.7182818284590451)</c> is calculated to be exactly 1 and, as already noted, <c>sin(3.1415926535897931)</c> is calculated to be 1.2246467991473532e-16.
<br><br>I don't know how the MPC library is coming up with <c>2.8954204500590832e-16</c>, but I'm about to ask them about that, and I'll update this post when I get the answer.
<br><br><b>UPDATE:</b> I've changed my mind - the value returned for these inputs is very sensitive to minute changes in the evaluation of those inputs. For example:
<c>
sisyphus@sisyphus5-desktop:~$ perl -MMath::Complex -E "say sin(pi * 1);"
1.22464679914735e-16
sisyphus@sisyphus5-desktop:~$ perl -MMath::Complex -E "say sin(pi * 0.99999999999999994);"
5.66553889764798e-16
</c>
I don't see much point in investigating further when such a minute alteration to the arguments can make such a large <b>relative</b> difference, especially when we consider that the <b>absolute</b> difference is so minute.
<br><br>Cheers,<br>Rob
11133457
11133495