in reply to Re^4: Euler's identity in Raku
in thread Euler's identity in Raku
I'd not expect perl to return exactly zero to sin(pi) and I don't get it, but 1.22464679914735e16
The reliance on the sine and cosine trig functions can be seen at https://www.math.toronto.edu/mathnet/questionCorner/complexexp.html.
For the case under consideration in this thread, the imaginary component should be sin(3.1415926535897931 * log(2.7182818284590451))
log(2.7182818284590451) is calculated to be exactly 1 and, as already noted, sin(3.1415926535897931) is calculated to be 1.2246467991473532e16.
I don't know how the MPC library is coming up with 2.8954204500590832e16, but I'm about to ask them about that, and I'll update this post when I get the answer.
UPDATE: 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:
Cheers,
Rob
The reliance on the sine and cosine trig functions can be seen at https://www.math.toronto.edu/mathnet/questionCorner/complexexp.html.
For the case under consideration in this thread, the imaginary component should be sin(3.1415926535897931 * log(2.7182818284590451))
log(2.7182818284590451) is calculated to be exactly 1 and, as already noted, sin(3.1415926535897931) is calculated to be 1.2246467991473532e16.
I don't know how the MPC library is coming up with 2.8954204500590832e16, but I'm about to ask them about that, and I'll update this post when I get the answer.
UPDATE: 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:
I don't see much point in investigating further when such a minute alteration to the arguments can make such a large relative difference, especially when we consider that the absolute difference is so minute.sisyphus@sisyphus5desktop:~$ perl MMath::Complex E "say sin(pi * 1) +;" 1.22464679914735e16 sisyphus@sisyphus5desktop:~$ perl MMath::Complex E "say sin(pi * 0. +99999999999999994);" 5.66553889764798e16
Cheers,
Rob


Replies are listed 'Best First'.  

Re^6: Euler's identity in Raku
by p6steve (Sexton) on Jun 07, 2021 at 22:02 UTC  
by syphilis (Archbishop) on Jun 08, 2021 at 01:32 UTC 
In Section
Seekers of Perl Wisdom