Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
Re^2: Seeing if two numbers have the same sign ($x / abs $x)by WoodyWeaver (Monk) |
on Jan 11, 2008 at 20:11 UTC ( [id://661973]=note: print w/replies, xml ) | Need Help?? |
<obsMathRef> lodin's observation and syphilis' cantrip come from the same underlying mathematical principles.
Triangle equality: (Note here || is "norm", not or.)
Angle between two vectors: (That the second theorem implies the first is left as an exercise for the reader. :-)
For one dimensional vectors ("numbers") the norm is the absolute value, and there are only two "directions" -- out along the positive axis and out along the negative axis. So syphilis is applying the triangle equality, while lodin is computing the cosine directly (note cos 0 = 1 -> "same sign" while cos 180 degrees = -1 -> "opposite sign"). We now return to our regular interpretation of line noise as script. --woody
In Section
Seekers of Perl Wisdom
|
|