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: as for Calc and the math library Date: Sun, 11 Aug 2024 07:58:23 +0300 Message-ID: <86zfpjirkg.fsf@gnu.org> References: <87bk20yoya.fsf@dataswamp.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32030"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Emanuel Berg Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Aug 11 06:59:18 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 1sd0fl-0008Cd-IC for ged-emacs-devel@m.gmane-mx.org; Sun, 11 Aug 2024 06:59:17 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sd0f3-0000fx-NT; Sun, 11 Aug 2024 00:58:35 -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 1sd0ev-0000f3-W0 for emacs-devel@gnu.org; Sun, 11 Aug 2024 00:58:26 -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 1sd0eu-0002mJ-W8; Sun, 11 Aug 2024 00:58:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=75fpsp/inQfq/42JWqBtgpVRBQIOVnEbVQojXCrOxgQ=; b=ggw0QRtMQL1bHxrvQbv6 bqRh9VrgU4o9+gsDItAlwGYqE/udyCcI1+hZE2Na+EomH2Pl8jm9Y6ygepj0bVs5mceptuyCBbZoo acxfpLw66ys0W57Qka42DI5upckMhG4riQyLuZn+aV3MKhqMlnwXE3MFjMrpG5kp3r4NUcDslUvsI Gunlp3cW6grZA/bsl5yt1/GbKs4WXntcR+lHszse1voAXUtTIYi76ohfVx3YI9jGelxYnh+euLe7b FHbpjMNCQ6hQPfeuydn32K93EsHvgOAy1b75EuU4eKR9eY1R/PzeTk8YU9xu6xnkF7DrUXVG+JQLW hAxiPKHJnCbHww==; In-Reply-To: <87bk20yoya.fsf@dataswamp.org> (message from Emanuel Berg on Sun, 11 Aug 2024 00:48:13 +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:322628 Archived-At: > From: Emanuel Berg > Date: Sun, 11 Aug 2024 00:48:13 +0200 > > We don't have > > (defun distance-point (min max) > (+ min (/ (- max min) 2.0)) ) Once again, if we want this and other functions for a math library in Emacs, we should make sure the algorithms used are solid and stable, and in particular don't cause errors unless the result really cannot be expressed as a valid number. For example, in the above, the expression (- min max) could overflow when min/2 - max/2 that it calculates is a valid number. If Emacs is to have a math library, the library must use high-quality mathematical and numerical algorithms that are well-known and described in many textbooks on this subject matter. This high quality should start from the simplest calculations, and go all the way to the most complex ones. For example, even summing many float values naïvely will eventually lose accuracy. E.g., try adding 10 values of 1e-16 followed by the value of 1, that is (+ 1.0 1.e-16 1.e-16 1.e-16 1.e-16 1.e-16 1.e-16 1.e-16 1.e-16 1.e-16 1.e-16) Doing this naïvely will lose all the small values, as if they were not there at all. So even such seemingly-simple operations might need non-trivial algorithm to avoid losing accuracy when it could be kept.