Your skill will accomplishwhat the force of many cannot PerlMonks

### Euler's identity in Raku

by tomasz (Acolyte)
 on Jun 03, 2021 at 05:11 UTC Need Help??

tomasz has asked for the wisdom of the Perl Monks concerning the following question:

```say e ** (pi * i)
-1+1.2246467991473532e-16i
Why is the fancy part not 0?

Replies are listed 'Best First'.
Re: Euler's identity in Raku
by syphilis (Archbishop) on Jun 03, 2021 at 05:27 UTC
Why is the fancy part not 0?

Because the estimation used for "pi" is not exactly equal to pi.
For the imaginary part of the result to be zero, you need to multiply "i" by exactly pi.

Cheers,
Rob
Wouldn't e have to be pure also?
Wouldn't e have to be pure also?

You're correct - the inexactness of "e" is also influencing the result.

UPDATE: BTW, in perl we can reproduce you're original result with:
```>perl -MMath::Complex -le "print exp(1) ** (pi * i);"
-1+1.22460635382238e-16i
Oops ... hang on ... that's not exactly the same. (I'm not all that familiar with Raku, so I'm not sure what accounts for that difference.)

Cheers,
Rob
A reply falls below the community's threshold of quality. You may see it by logging in.
Re: Euler's identity in Raku
by perlfan (Vicar) on Jun 04, 2021 at 00:45 UTC
rakumonks.org is still available and cheap, just sayin'
It has been long established that Raku/Perl6 is NOT off-topic here and every post is welcome, as long as it follows board rules.

You may not like it, but by definition, "Perl6" hobbyists are part of Perlmonks and part of the Perl community.

I do not welcome your attempts to cast them out of the Perl community in general and out of Perlmonks especially. I also ask you to reconsider your view that they are "freeloading", as they do put far less strain on this forum and whatever community than your incessant complaints about Perl 6 posts, which are mostly constrained to announcements anyway.

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

In 2016 that thing still called itself Perl 6. It hasn't done so in years.

(written by me back in 2016, the first part is still true and the second eventually happened) The only reason the Not-at-all-Perl 6 has so far put little strain on this forum is that next to no one uses the language, next to no one posts about it and next to no one cares. Therefore the number of posts that would be sure to confuse everyone with incompatible yet confusingly similar syntax is sufficiently small that they do not cause a problem. If the language ever gets followers and the number of posts grows we will end up with loads of "your code doesn't work for me, I get syntax errors" due to people running Perl code in For-God's-sake-rename-the-thing 6 and vice versa.

Even things that have been long established need to be reviewed from time to time.

Jenda
1984 was supposed to be a warning,
not a manual!

it doesn't look so (it doesn't look up at all)

They mean the domain name is available/unused. As of right now, all three of big ones are: com, net, org.

Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11133457]
Approved by GrandFather
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2024-05-22 05:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?

No recent polls found