Feedback on hypot and hypot2

David Bruant bruant.d at gmail.com
Mon Aug 13 14:36:38 PDT 2012


Le 13/08/2012 19:56, Christian Mayer a écrit :
> Am 13.08.2012 11:16, schrieb David Bruant:
>> I'd like to talk about naming as well. "hypot" (for "Hypotenuse") is an
>> accurate name for the 2 dimension case, but much less for 3 dimensions
>> as far as I know (the English wikipedia page [2] doesn't mention the 3D
>> case either) and even less for N-dimension.
>> I think it would make sense to rename it. Maybe "euclidianDistance" (too
>> long?), "distance" [3] (accurate mathematically, but may sound vague in
>> the broader context of JavaScript), "eucl" (too cryptic?), other?
> The correct mathematical name would be "norm".
I'm glad we agree that "hypot" is inaccurate.

> And there are different ways a function could work and it still would be
> a norm (see this section on the wikipedia page you've posted:
> https://en.wikipedia.org/wiki/Distance#Distance_in_Euclidean_space;
"In the Euclidean space Rn, the distance between two points is usually
given by the Euclidean distance (2-norm distance). Other distances,
based on other norms, are sometimes used instead."
Euclidean distance (aka 2-norm distance) definition maps the one of the
function currently named "hypot", specifically computing the squareroot
of the sum of squares, so I don't see how "norm" is more correct in that
case than "distance".

> "norm" is a mathematical construct that gives a few guarantees:
> https://en.wikipedia.org/wiki/Norm_%28mathematics%29)
>
> Three norms are used quite often so they'd profit from a native function:
> * 1-norm (usually the fastest to compute)
> * 2-norm (hypot in the 2d case; usually the squared value is enough as
>           well as faster to compute, so it's much more often used in
>           numerical algorithms)
> * infinity-norm (the least used variant)
It seems that what you're asking for is something different than the
current hypot function definition.

David


More information about the es-discuss mailing list