in reply to Deriving pi and e
Interesting... but in real life one would simply say:
print atan2(1,1) * 4, "\n";
print exp(1);
•Re: Re: Deriving pi and e
by merlyn (Sage) on Oct 25, 2003 at 12:40 UTC

I'm not sure why people keep propogating the one where you have to multiply by 4. It's much simpler to say:
my $pi = atan2(0,1);
In other words, don't create a vector that points at 45 degrees and multiply by 4... create
a vector that points at 180 degrees!
 [reply] [d/l] 

 [reply] [d/l] [select] 

I agree. Actually, it's imo better to define atan2(0,1)=Pi,
so that atan2's range would be [Pi,Pi), not (Pi,Pi] (not that this would matter at all).
Actually, even my prof at complex functions course defined it this way: log(1)=i*Pi.
I use 4*atan2(1,1) instead of atan2(0,1) or 2*atan2(1,0),
because I got used to bc and basic, where you have to write 4*a(1), and 4*atn(1) resp.,
because there is no atan2 function.
 [reply] 

Er, I suspect the reason is that people forget that you can do that with atan2. (You can't do that with a normal atan, IIRC...)
In any case, yes, it is a little silly.
Warning: Unless otherwise stated, code is untested. Do not use without understanding. Code is posted in the hopes it is useful, but without warranty. All copyrights are relinquished into the public domain unless otherwise stated. I am not an angel. I am capable of error, and err on a fairly regular basis. If I made a mistake, please let me know (such as by replying to this node).
 [reply] 

Well, your method is logical but one advantage of atan(1,1)*4 would be that there is reduced scope to get the argument order or signs wrong. (1,1) is easy to remember but (0,1) could get mixed up with (1,0), (1,0) or (0,1) by the sieveheaded amongst us. Never underestimate sieveheadedness!
:D
 [reply] 

Others cooling their heels in the Monastery: (6) As of 20240224 23:05 GMT
