time-to-botec/js/node_modules/@stdlib/math/base/special/fast/hypot
NunoSempere b6addc7f05 feat: add the node modules
Necessary in order to clearly see the squiggle hotwiring.
2022-12-03 12:44:49 +00:00
..
docs feat: add the node modules 2022-12-03 12:44:49 +00:00
lib feat: add the node modules 2022-12-03 12:44:49 +00:00
package.json feat: add the node modules 2022-12-03 12:44:49 +00:00
README.md feat: add the node modules 2022-12-03 12:44:49 +00:00

hypot

Compute the hypotenuse.

Usage

var hypot = require( '@stdlib/math/base/special/fast/hypot' );

hypot( x, y )

Computes the hypotenuse.

var h = hypot( -5.0, 12.0 );
// returns 13.0

Notes

  • For a sufficiently large x and/or y, computing the hypotenuse will overflow.

    var h = hypot( 1.0e154, 1.0e154 );
    // returns Infinity
    

    Similarly, for sufficiently small x and/or y, computing the hypotenuse will underflow.

    var h = hypot( 1e-200, 1.0e-200 );
    // returns 0.0
    

Examples

var randu = require( '@stdlib/random/base/randu' );
var round = require( '@stdlib/math/base/special/round' );
var hypot = require( '@stdlib/math/base/special/fast/hypot' );

var x;
var y;
var h;
var i;

for ( i = 0; i < 100; i++ ) {
    x = round( randu()*100.0 ) - 50.0;
    y = round( randu()*100.0 ) - 50.0;
    h = hypot( x, y );
    console.log( 'hypot(%d,%d) = %d', x, y, h );
}