From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: hypotenuse (was: Re: Adding a generic mathematical library) Date: Sun, 21 Jul 2024 18:42:10 +0300 Message-ID: <86plr6bvl9.fsf@gnu.org> References: <8734o9sdig.fsf@posteo.net> <87wmllqq66.fsf@posteo.net> <87plrdqnhc.fsf@posteo.net> <87le21qldj.fsf_-_@posteo.net> <878qy1at52.fsf@dataswamp.org> <87plr6u8al.fsf_-_@dataswamp.org> <86wmleby8w.fsf@gnu.org> <86sew2bxii.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="11391"; mail-complaints-to="usenet@ciao.gmane.io" Cc: incal@dataswamp.org, emacs-devel@gnu.org To: Christopher Dimech Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Jul 21 17:42:40 2024 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1sVYhr-0002pc-OM for ged-emacs-devel@m.gmane-mx.org; Sun, 21 Jul 2024 17:42:39 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVYhU-0007GV-A8; Sun, 21 Jul 2024 11:42:16 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sVYhS-0007GF-Cr for emacs-devel@gnu.org; Sun, 21 Jul 2024 11:42:14 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sVYhR-0002mV-46; Sun, 21 Jul 2024 11:42:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=rLno1rFuHadXTP+PZujzKEFgUQ58puFgroYZjp0lghw=; b=TRfblY87gK0a F2yc8FOHRlOQaljodM3ji0D9yLMee2HkSnVQpbAPNYG4ZBHcrHjG+i3sDCr4I/yOVBTiKivG1QuWA kxcvj5Cm+EwPRXLR6XevBz5bCp4qxoIw3qqYhbqs1173qnsqoQbr96w/Y8lWd4IRd/vnvbJ3kuXRi sgNJ14ScGJZUGUkEgWm9+Mg0HxtJgu4Td0FGPvcTdXTkpt1Kg15vVb1An2+D2qgyFtQ8jO2Ur1Vuj 79s4tHkl+b2tP1cUATD45FU8fM/1Zt//mVZabmD3r0xgzPQ6VS+OvBXTL9okxQWikrbazAzL+ibky B8uOO8akvWTDVuLCQvLk0A==; In-Reply-To: (message from Christopher Dimech on Sun, 21 Jul 2024 17:12:10 +0200) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:321898 Archived-At: > From: Christopher Dimech > Cc: incal@dataswamp.org, emacs-devel@gnu.org > Date: Sun, 21 Jul 2024 17:12:10 +0200 > Sensitivity: Normal > > > Sent: Monday, July 22, 2024 at 3:00 AM > > From: "Eli Zaretskii" > > 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 > > > 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. AFAIK, every libm already includes a similar implementation, so we should just expose it to Lisp (again, assuming this function is indeed required to be part of Emacs).