From: Marcin Borkowski <mbork@mbork.pl>
To: Emanuel Berg <moasenwood@zoho.eu>
Cc: help-gnu-emacs@gnu.org, Ingemar Holmgren <dag.h@hotmail.se>
Subject: Re: Calculator: no exponent, full number ?
Date: Thu, 06 Jun 2019 17:47:44 +0200 [thread overview]
Message-ID: <875zpibtr3.fsf@mbork.pl> (raw)
In-Reply-To: <86tvd3sig6.fsf@zoho.eu>
On 2019-06-06, at 01:47, Emanuel Berg via help-gnu-emacs <help-gnu-emacs@gnu.org> wrote:
> (defun hypotenuse (c1 c2)
> (sqrt (+ (* c1 c1) (* c2 c2))) )
Just for the fun, let me mention that this is not a very good algorithm
for computing the Pythagorean sum - it may happen that both the operands
and the result lie within the bounds for the given type, but this
calculation blows up because of large squares overflowing. Also, it is
slow because of the need to compute square roots.
Interestingly, there exists a clever algorithm that does not have these
problems. It is used (among others) in Donald Knuth's METAFONT. The
algorithm is described in the paper (using Emanuel's favorite
format;-)):
@ARTICLE{5390405,
author={C. {Moler} and D. {Morrison}},
journal={IBM Journal of Research and Development},
title={Replacing Square Roots by Pythagorean Sums},
year={1983},
volume={27},
number={6},
pages={577-581},
keywords={},
doi={10.1147/rd.276.0577},
ISSN={0018-8646},
month={Nov},
}
Best,
--
Marcin Borkowski
http://mbork.pl
next prev parent reply other threads:[~2019-06-06 15:47 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-04 19:43 Calculator: no exponent, full number ? jonetsu
2019-06-04 22:42 ` Emanuel Berg via help-gnu-emacs
2019-06-05 11:15 ` Emanuel Berg via help-gnu-emacs
2019-06-05 4:11 ` Marcin Borkowski
2019-06-05 4:26 ` Emanuel Berg via help-gnu-emacs
2019-06-05 13:53 ` jonetsu
2019-06-05 23:47 ` Emanuel Berg via help-gnu-emacs
2019-06-06 14:50 ` Nick Dokos
2019-06-26 4:09 ` Xavier Maillard
2019-06-06 15:47 ` Marcin Borkowski [this message]
2019-06-06 16:50 ` Emanuel Berg via help-gnu-emacs
2019-06-06 17:04 ` tomas
2019-06-06 17:11 ` Emanuel Berg via help-gnu-emacs
2019-06-06 17:25 ` tomas
2019-06-07 19:36 ` Marcin Borkowski
2019-06-14 12:20 ` Van L
2019-06-14 13:26 ` Robert Pluim
2019-06-14 19:57 ` Stefan Monnier
2019-06-15 9:29 ` Van L
2019-06-14 19:43 ` Emanuel Berg via help-gnu-emacs
2019-06-15 9:23 ` Van L
-- strict thread matches above, loose matches on Subject: below --
2019-06-06 17:28 Joe Trivers via help-gnu-emacs
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=875zpibtr3.fsf@mbork.pl \
--to=mbork@mbork.pl \
--cc=dag.h@hotmail.se \
--cc=help-gnu-emacs@gnu.org \
--cc=moasenwood@zoho.eu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.