question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add support for computing the hypotenuse via `hypot`

See original GitHub issue

This RFC requests to include a new API in the array API specification for the purpose of computing the hypotenuse.

Based on array comparison data, the API is available across all major array libraries in the PyData ecosystem (note: TensorFlow implements hypot in its experimental numpy namespace).

While hypot can be implemented in userland using existing array API functions (e.g., sqrt(x1*x1 + x2*x2)), this function is typically implemented in a specialized manner to help prevent over/underflow.

Furthermore, need for this API arose when adding complex number support to the array API specification, particularly with regard to adding complex number support to abs, where the absolute value (magnitude) of a complex number is computed as hypot(real(z), imag(z)).

As this API already exists in the ecosystem and satisfies needs (e.g., numerical stability and complex number support), this API seems a good candidate for inclusion in the standard.

Issue Analytics

  • State:open
  • Created 10 months ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
kgrytecommented, Dec 1, 2022

In terms of API, all supporting libraries implement as a standard element-wise binary function: hypot(x1, x2), where x1 and x2 follow conventional broadcast rules.

0reactions
rgommerscommented, Dec 5, 2022

It does in order for the specification to be able to define special case behavior.

As discussed last Thursday, the special cases for abs can be put in the abs description. This is implemented in gh-546.

We’re already nearing the end of 2022, and are close to finalizing the 2022 standard. hypot is not urgent enough to squeeze it in now, so let’s defer deciding on that till later. There’s a larger queue of suggested new APIs that needs considering in Q1.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Math.hypot() - JavaScript - MDN Web Docs
Calculating the hypotenuse of a right triangle, or the magnitude of a complex number, uses the formula Math.sqrt(v1*v1 + v2*v2) , where v1 ......
Read more >
Python math.hypot() Method - W3Schools
Find the hypotenuse of a right-angled triangle where perpendicular and ... From Python 3.8, this method is used to calculate the Euclidean norm...
Read more >
What is the hypot() function in Swift? - Educative.io
Overview. The longest side of a right-angle triangle, and the side opposite to the right angle, is known as the hypotenuse in geometry....
Read more >
3 Ways to Find the Length of the Hypotenuse - wikiHow
1. Learn the Pythagorean Theorem. The Pythagorean Theorem describes the relationship between the sides of a right triangle. It states that for any...
Read more >
Python: Calculate the hypotenuse of a right angled triangle
Python Exercises, Practice and Solution: Write a Python program to calculate the hypotenuse of a right angled triangle.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found