Sponsored Links

Kamis, 30 November 2017

Sponsored Links

Hipot tester - 5 kV AC |Hypot III 3705 - Associated Research
src: img.directindustry.com

Hypot is a mathematical function defined to calculate the length of the hypotenuse of a right-angle triangle. It was designed to avoid errors arising due to limited-precision calculations performed on computers.


Video Hypot



Motivation and usage

Calculating the length of the hypotenuse of a triangle is possible using the square root function on the sum of two squares, but hypot(xy) avoids problems that occur when squaring very large or very small numbers.

The magnitude of the hypotenuse from (0, 0) to (xy) can be calculated using:

r = x 2 + y 2 {\displaystyle r={\sqrt {x^{2}+y^{2}}}\,}

This operation is also known as Pythagorean addition.

However the squares of very large or small values of x and y may exceed the range of machine precision when calculated on a computer, leading to an inaccurate result caused by arithmetic underflow and/or arithmetic overflow. The hypot function was designed to calculate the result without causing this problem.

The hypot function is often used together with the atan2 function to convert from Cartesian coordinates to polar coordinates:

 r = hypot(xy)        ? = atan2(yx)

Maps Hypot



Implementation

The difficulty with the naive implementation is that x2 or y2 may overflow or underflow, unless the intermediate result is computed with extended precision. A common implementation technique is to exchange the values, if necessary, so that |x| >= |y|, and then use the equivalent form:

r = x 2 + y 2 = x 2 ( 1 + ( y / x ) 2 ) = | x | 1 + ( y / x ) 2 {\displaystyle {\begin{aligned}r&={\sqrt {x^{2}+y^{2}}}\\&={\sqrt {x^{2}(1+(y/x)^{2})}}\\&=|x|{\sqrt {1+(y/x)^{2}}}\end{aligned}}}

The computation of y/x cannot overflow. If y/x underflows, the final result is equal to |x|, which is correct within the precision of the calculation. The square root is computed of a value between 1 and 2. Finally, the multiplication by |x| cannot underflow, and overflows only when the result is too large to represent.

Pseudocode

To save memory space, we may overwrite x here to avoid allocating a new double r.


Used Associated Research Test Equipment For Sale | AccuSource ...
src: accusrc.com


Programming language support

The function is present in several programming languages:

  • C99
  • C++11
  • D (programming language)
  • Fortran 2008
  • Julia (programming language)
  • Swift (programming language)
  • Python
  • Apple's PowerPC Numerics
  • MATLAB
  • Pascal
  • PHP
  • Java (since version 1.5)
  • Ruby
  • Go
  • Rust
  • JavaScript
  • Some C90 and C++ libraries have provided a hypot function.

Associated Research 3665 Ac/dc Hypot Iii With A Built-in ...
src: d2ydh70d4b5xgv.cloudfront.net


See also

  • Alpha max plus beta min algorithm, a faster algorithm yielding an approximate result

Associated Research 3705 Hypot III for sale $1095.00 | In Stock ...
src: accusrc.com


References

Source of the article : Wikipedia

Comments
0 Comments