Personally I do it for the reason that theorbtwo stated. I know how to do it with atan (and make the well-known power series converge), and the easiest way is to do 45 degrees and multiply by 4. Then I try to convert it to Perl, notice that there is no atan function, and use atan2.
That said, noting that I can do it directly with atan2 won't convince me not to reach for 4*atan2(1,1) for several reasons:
- I don't have this memorized, just the derivation of how it should work. I have more years of math than Perl, and so the derivation I know is the one that comes up immediately.
- Perl's documentation doesn't indicate whether atan(0,-1) will give you PI or -PI (or blow up because someone decided that "in the range of -PI to PI" means an open interval, not a half-closed one). I therefore don't know whether to trust it in future implementations of Perl.
- Even though I have had it pointed out to me that Perl's implementation gives you PI, I don't know whether I can trust that trivia in future implementations of atan2 that I may encounter in other languages. This goes doubly because I know enough about how one might try to implement atan2 to come up with plausible implementations which break at (0,-1).
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
|
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
|
|