Raymond Hettinger wrote:

> Frequency of usage:   Math provides ∑ and ∏ because they are common. It 
> doesn't provide a special operator for sqrt(c**2 - b**2) because the latter 
> is less fundamental and less common.

Here's some more information. Below is an example of an area, where
sqrt(c**2 - b**2) is both fundamental and common. And that it might be
helpful for Python to provide a (named) function for this operation.
Whether or not, or how, a symbolic expression should be provided is
another question.

This one example by itself does not refute Raymond's argument. I
certainly think caution is required, in promoting the needs of one
group of users at the expense of another. Best avoided, if possible.

GORY DETAILS
Don Knuth, in METAFONT, implemented special '++' and '+-+' operators,
that he called Pythagorean addition and subtraction. The latter is
precisely Raymond's sqrt(c**2 - b**2), but calculated more efficiently
and accurately.

This is described on page 66 of Don Knuth's METAFONT Book.
https://ctan.org/tex-archive/systems/knuth/dist/mf/mfbook.tex

The `^|++|' operation is called {\sl^{Pythagorean addition}\/}; $a\pyth+b$
is the same thing as $\sqrt{\stt a^2+b^2}$. Most of the ^{square root}
operations in computer programs could probably be avoided if $++$ were
more widely available, because people seem to want square roots primarily
when they are computing distances. Notice that $a\pyth+b\pyth+c=
\sqrt{\stt a^2+b^2+c^2}$; we have the identity $(a\pyth+b)\pyth+c=a\pyth+(
b\pyth+c)$ as well as $a\pyth+b=b\pyth+a$. It is better to use Pythagorean
addition than to calculate $\sqrt{\stt a^2+b^2}$, because the computation
of $a^2$ and $b^2$ might produce numbers that are too large even when
$a\pyth+b$ is rather small. There's also an inverse operation,
^{Pythagorean subtraction}, which is denoted by `^|+-+|'; the quantity
$a\mathbin{+{-}+}b$ is equal to $\sqrt{\stt a^2-b^2}$.

ASIDE - wikipedia
In https://en.wikipedia.org/wiki/Pythagorean_addition, wikipedia using
the symbol \oplus for Pythagorean addition, and does not mention
Pythagorean subtraction.

ASIDE- \pyth and Python
Don Knuth uses \pyth as a macro (shorthand) for Pythagorean. It's got
nothing to do with Python. The METAFONT book goes back to 1986, which
predates Pyth-on by about 5 years. That said, Pythagoras was the
founder of a new way of life, and Python is a new way of programming.

-- 
Jonathan
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to