emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

hypotenuse (was: Re: Adding a generic mathematical library)


From: Christopher Dimech
Subject: hypotenuse (was: Re: Adding a generic mathematical library)
Date: Sun, 21 Jul 2024 17:12:10 +0200

> Sent: Monday, July 22, 2024 at 3:00 AM
> From: "Eli Zaretskii" <eliz@gnu.org>
> To: incal@dataswamp.org
> Cc: emacs-devel@gnu.org
> Subject: Re: hypotenuse (was: Re: Adding a generic mathematical library)
>
> > Date: Sun, 21 Jul 2024 17:44:47 +0300
> > From: Eli Zaretskii <eliz@gnu.org>
> > Cc: emacs-devel@gnu.org
> >
> > > (defun hypotenuse (c1 c2)
> > >   (sqrt (+ (* c1 c1) (* c2 c2))) )
> >
> > This is not the best way of computing hypot: squaring a number could
> > overflow or underflow, and you get bad result.  Try
> >
> >     (hypotenuse 1.e-600 1.e-600)
> > or
> >     (hypotenuse 1.e600 1.e600)
> >
> > and you will see it.
>
> Sorry, that should have been 1.e-300 and 1.e300 instead.

I have a solution to the problem in fortran, but not in elisp.  I could
include it.  Its implementation required serious concentration.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]