Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
I'd not expect perl to return exactly zero to sin(pi) and I don't get it, but 1.22464679914735e-16

The reliance on the sine and cosine trig functions can be seen at
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.2246467991473532e-16.

I don't know how the MPC library is coming up with 2.8954204500590832e-16, 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:
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
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.


In reply to Re^5: Euler's identity in Raku by syphilis
in thread Euler's identity in Raku by tomasz

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (2)
As of 2022-05-26 05:38 GMT
Find Nodes?
    Voting Booth?
    Do you prefer to work remotely?

    Results (93 votes). Check out past polls.