From unknown Sun Jun 22 11:39:18 2025 X-Loop: help-debbugs@gnu.org Subject: bug#41279: 26.3; Calc: sum(gcd(0,n),n,-1,-1) evaluates to -1 Resent-From: David Ongaro Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 15 May 2020 04:54:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 41279 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 41279@debbugs.gnu.org X-Debbugs-Original-To: Received: via spool by submit@debbugs.gnu.org id=B.158951839814220 (code B ref -1); Fri, 15 May 2020 04:54:02 +0000 Received: (at submit) by debbugs.gnu.org; 15 May 2020 04:53:18 +0000 Received: from localhost ([127.0.0.1]:35621 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jZSLW-0003hI-EA for submit@debbugs.gnu.org; Fri, 15 May 2020 00:53:18 -0400 Received: from lists.gnu.org ([209.51.188.17]:53376) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jZSLS-0003h8-Do for submit@debbugs.gnu.org; Fri, 15 May 2020 00:53:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44004) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZSLS-0008EI-5g for bug-gnu-emacs@gnu.org; Fri, 15 May 2020 00:53:14 -0400 Received: from cosmopolitan.ops.eusc.inter.net ([2001:1560:3:255::151]:60694) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZSLQ-0003HS-MM for bug-gnu-emacs@gnu.org; Fri, 15 May 2020 00:53:13 -0400 X-Trace: 4c7c64617669642e6f6e6761726f4068616d627572672e64657c3137342e32312e 3130372e3134397c316a5a534c472d3030303249722d33457c3135383935313833 3832 Received: from cosmopolitan.ops.eusc.inter.net ([10.151.10.15] helo=localhost) by cosmopolitan.ops.eusc.inter.net with esmtpsa (Exim 4.93.0.4) id 1jZSLG-0002Ir-3E for bug-gnu-emacs@gnu.org; Fri, 15 May 2020 06:53:02 +0200 User-Agent: Microsoft-MacOutlook/16.37.20051002 Date: Thu, 14 May 2020 21:52:56 -0700 From: David Ongaro Message-ID: Thread-Topic: 26.3; Calc: sum(gcd(0,n),n,-1,-1) evaluates to -1 Mime-version: 1.0 Content-type: text/plain; charset="UTF-8" Content-transfer-encoding: quoted-printable X-SA-Exim-Connect-IP: 174.21.107.149 X-SA-Exim-Mail-From: david.ongaro@hamburg.de X-SA-Exim-Scanned: No (on cosmopolitan.ops.eusc.inter.net); SAEximRunCond expanded to false Received-SPF: pass client-ip=2001:1560:3:255::151; envelope-from=david.ongaro@hamburg.de; helo=cosmopolitan.ops.eusc.inter.net X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-Spam-Score: -1.6 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.6 (--) By accident I noticed that this algebraic expression yields 6 instead of 8 which would be correct: =C2=A0=C2=A0=C2=A0=C2=A0sum(sum(gcd(n, k), k, -1, 1), n, -1, 1) =3D> 6 I could narrow it down to this, which yields -1 instead of 1 =C2=A0=C2=A0=C2=A0=C2=A0sum(gcd(0, n), n , -1, -1) =3D> -1 Notably gcd(0, -1) evaluates to 1 as it should be. Also we have =C2=A0=C2=A0=C2=A0=C2=A0sum(gcd(n, 0), n, -1, -1) =3D> -1 but =C2=A0=C2=A0=C2=A0=C2=A0sum(sum(gcd(n, k), k, 0, 0), n, -1, -1) =3D> -1 =C2=A0=C2=A0=C2=A0=C2=A0sum(sum(gcd(n, k), k, -1, -1), n, 0, 0) =3D> 1 which violates gcd(n, k) =3D gcd(k, n). We also have =C2=A0=C2=A0=C2=A0=C2=A0sum(sum(gcd(n, k) =3D 1, k, -1, 1), n, -1, 1) =3D> 7 =C2=A0=C2=A0=C2=A0=C2=A0sum(sum(abs(gcd(n, k)), k, -1, 1), n, -1, 1) =3D> 8 which seems to confirm that it's not just the sum function but the combination of sum and gcd which might introduce the problem. To reproduce you can simply enter Calc embedded mode with C-x 8 e in a buffer with this email content, put the point on a corresponding formular and reevaluate with SPACE. I'd appreciate if this could be fixed. David In GNU Emacs 26.3 (build 1, x86_64-apple-darwin18.2.0, NS appkit-1671.20 Ve= rsion 10.14.3 (Build 18D109)) of 2019-09-02 built on builder10-14.porkrind.org Windowing system distributor 'Apple', version 10.3.1894 Recent messages: previous-line: Beginning of buffer [2 times] (Switching Calc Embedded mode to new formula.) [5 times] Working... [3 times] (Canceled) C-c C-c is undefined [2 times] (Switching Calc Embedded mode to new formula.) [9 times] user-error: Beginning of history; no preceding item [3 times] Quit Making completion list... [2 times] user-error: Beginning of history; no preceding item Configured using: 'configure --with-ns '--enable-locallisppath=3D/Library/Application Support/Emacs/${version}/site-lisp:/Library/Application Support/Emacs/site-lisp' --with-modules' Configured features: NOTIFY ACL GNUTLS LIBXML2 ZLIB TOOLKIT_SCROLL_BARS NS MODULES THREADS Important settings: =C2=A0=C2=A0value of $LC_ALL: en_US.utf-8 =C2=A0=C2=A0value of $LC_CTYPE: UTF-8 =C2=A0=C2=A0value of $LANG: en_US.utf-8 =C2=A0=C2=A0locale-coding-system: utf-8-unix Major mode: Fundamental Minor modes in effect: =C2=A0=C2=A0tooltip-mode: t =C2=A0=C2=A0global-eldoc-mode: t =C2=A0=C2=A0electric-indent-mode: t =C2=A0=C2=A0mouse-wheel-mode: t =C2=A0=C2=A0tool-bar-mode: t =C2=A0=C2=A0menu-bar-mode: t =C2=A0=C2=A0file-name-shadow-mode: t =C2=A0=C2=A0global-font-lock-mode: t =C2=A0=C2=A0font-lock-mode: t =C2=A0=C2=A0blink-cursor-mode: t =C2=A0=C2=A0auto-composition-mode: t =C2=A0=C2=A0auto-encryption-mode: t =C2=A0=C2=A0auto-compression-mode: t =C2=A0=C2=A0buffer-read-only: t =C2=A0=C2=A0line-number-mode: t =C2=A0=C2=A0transient-mark-mode: t Load-path shadows: None found. Features: (shadow sort mail-extr emacsbug message rmc puny seq byte-opt gv bytecomp byte-compile cconv dired dired-loaddefs format-spec rfc822 mml mml-sec password-cache epa derived epg epg-config gnus-util rmail rmail-loaddefs mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils calc-arith calc-prog calc-yank calccomp calcalg2 calc-misc calc-comb calc-map calc-alg calc-aent cl-seq calc-menu easymenu calc-embed cl-loaddefs cl-lib calc-ext calc calc-loaddefs calc-macs elec-pair time-date tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type mwheel term/ns-win ns-win ucs-normalize mule-util term/common-win tool-bar dnd fontset image regexp-opt fringe tabulated-list replace newcomment text-mode elisp-mode lisp-mode prog-mode register page menu-bar rfn-eshadow isearch timer select scroll-bar mouse jit-lock font-lock syntax facemenu font-core term/tty-colors frame cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese composite charscript charprop case-table epa-hook jka-cmpr-hook help simple abbrev obarray minibuffer cl-preloaded nadvice loaddefs button faces cus-face macroexp files text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote threads kqueue cocoa ns multi-tty make-network-process emacs) Memory information: ((conses 16 243141 10243) (symbols 48 24190 1) (miscs 40 99 401) (strings 32 37828 1759) (string-bytes 1 996761) (vectors 16 38186) (vector-slots 8 766279 17952) (floats 8 49 73) (intervals 56 315 13) (buffers 992 15)) From unknown Sun Jun 22 11:39:18 2025 X-Loop: help-debbugs@gnu.org Subject: bug#41279: 26.3; Calc: sum(gcd(0,n),n,-1,-1) evaluates to -1 References: In-Reply-To: Resent-From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 15 May 2020 10:20:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 41279 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: David Ongaro Cc: 41279@debbugs.gnu.org Received: via spool by 41279-submit@debbugs.gnu.org id=B41279.158953797821723 (code B ref 41279); Fri, 15 May 2020 10:20:01 +0000 Received: (at 41279) by debbugs.gnu.org; 15 May 2020 10:19:38 +0000 Received: from localhost ([127.0.0.1]:35913 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jZXR9-0005e7-4k for submit@debbugs.gnu.org; Fri, 15 May 2020 06:19:38 -0400 Received: from mail1464c50.megamailservers.eu ([91.136.14.64]:43388 helo=mail268c50.megamailservers.eu) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jZXR6-0005ds-Hj for 41279@debbugs.gnu.org; Fri, 15 May 2020 06:19:25 -0400 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1589537957; bh=6f7rHVEPLWKcNrB3Q8oOPMgShf6jcWcI/8XrpFwmS1I=; h=From:Subject:Date:Cc:To:From; b=JKfNQl22vrnV74y5oCUa4IHRzYe8C3c2eJxYWjp+/AuECXBcPj2nUdlkDH1jn8Cu6 rdr+eDwAyjQnZIGndwnMVjCtADGWA0qxRb9S/bWosPq9H0/m1fJ0sWF21Vb+TYQ/ke ONtGrr8viHkwIUVjp2KV0gRhcVjTbgEXgPuPhtvU= Feedback-ID: mattiase@acm.or Received: from stanniol.lan (c-4e4ae655.032-75-73746f71.bbcust.telenor.se [85.230.74.78]) (authenticated bits=0) by mail268c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id 04FAJFr2027086; Fri, 15 May 2020 10:19:16 +0000 From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.14\)) Message-Id: <7D48D15C-1F8E-41C8-9B1C-650215C8101D@acm.org> Date: Fri, 15 May 2020 12:19:14 +0200 X-Mailer: Apple Mail (2.3445.104.14) X-CTCH-RefID: str=0001.0A782F18.5EBE6C3F.00A2, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: 0.000 X-CTCH-Rules: X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-CSC: 0 X-CHA: v=2.3 cv=BZ+mLYl2 c=1 sm=1 tr=0 a=klNLuyVZdLUgl+K5Uafb2A==:117 a=klNLuyVZdLUgl+K5Uafb2A==:17 a=kj9zAlcOel0A:10 a=M51BFTxLslgA:10 a=ghBovyFD5biq_iQvZ9IA:9 a=MEnuKdxVvYCi6RlQ:21 a=TG2vjweC-eppCdnI:21 a=CjuIK1q_8ugA:10 X-Spam-Score: 1.2 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Thank you for reporting this. It seems that Calc first simplifies gcd(0,n) to n and then computes sum(n,n,-1,-1) = -1. We could either make gcd(0,x)=gcd(x,0)=|x|, or try preventing sum from simplifyin [...] Content analysis details: (1.2 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 URIBL_BLOCKED ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [URIs: megamailservers.eu] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) 0.3 KHOP_HELO_FCRDNS Relay HELO differs from its IP's reverse DNS X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) Thank you for reporting this. It seems that Calc first simplifies = gcd(0,n) to n and then computes sum(n,n,-1,-1) =3D -1. We could either make gcd(0,x)=3Dgcd(x,0)=3D|x|, or try preventing sum = from simplifying its operand first, or both. For the smallest possible change, what about the hack below? --- a/lisp/calc/calc-comb.el +++ b/lisp/calc/calc-comb.el @@ -241,8 +241,8 @@ calcFunc-gcd (calcFunc-gcd (math-neg a) b)) ((Math-looks-negp b) (calcFunc-gcd a (math-neg b))) - ((Math-zerop a) b) - ((Math-zerop b) a) + ((Math-zerop a) (math-abs b)) + ((Math-zerop b) (math-abs a)) ((and (Math-ratp a) (Math-ratp b)) (math-make-frac (math-gcd (if (eq (car-safe a) 'frac) (nth 1 a) = a) From unknown Sun Jun 22 11:39:18 2025 X-Loop: help-debbugs@gnu.org Subject: bug#41279: 26.3; Calc: sum(gcd(0,n),n,-1,-1) evaluates to -1 Resent-From: David Ongaro Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 15 May 2020 17:45:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 41279 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Cc: 41279@debbugs.gnu.org Received: via spool by 41279-submit@debbugs.gnu.org id=B41279.15895646638267 (code B ref 41279); Fri, 15 May 2020 17:45:01 +0000 Received: (at 41279) by debbugs.gnu.org; 15 May 2020 17:44:23 +0000 Received: from localhost ([127.0.0.1]:38675 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jZeNj-00029H-Mt for submit@debbugs.gnu.org; Fri, 15 May 2020 13:44:23 -0400 Received: from longisland.ops.eusc.inter.net ([84.23.254.153]:36516) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jZeNi-000293-D7 for 41279@debbugs.gnu.org; Fri, 15 May 2020 13:44:23 -0400 X-Trace: 4c7c64617669642e6f6e6761726f4068616d627572672e64657c3137342e32312e 3130372e3134397c316a5a654e592d303030344a772d52397c3135383935363436 3533 Received: from longisland.ops.eusc.inter.net ([10.153.10.15] helo=localhost) by longisland.ops.eusc.inter.net with esmtpsa (Exim 4.93.0.4) id 1jZeNY-0004Jw-R9; Fri, 15 May 2020 19:44:13 +0200 User-Agent: Microsoft-MacOutlook/16.37.20051002 Date: Fri, 15 May 2020 10:44:07 -0700 From: David Ongaro Message-ID: <20621430-4DFE-4E40-A616-9D404DDBB2BF@hamburg.de> Thread-Topic: bug#41279: 26.3; Calc: sum(gcd(0,n),n,-1,-1) evaluates to -1 References: <7D48D15C-1F8E-41C8-9B1C-650215C8101D@acm.org> In-Reply-To: <7D48D15C-1F8E-41C8-9B1C-650215C8101D@acm.org> Mime-version: 1.0 Content-type: text/plain; charset="UTF-8" Content-transfer-encoding: quoted-printable X-SA-Exim-Connect-IP: 174.21.107.149 X-SA-Exim-Mail-From: david.ongaro@hamburg.de X-SA-Exim-Scanned: No (on longisland.ops.eusc.inter.net); SAEximRunCond expanded to false X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) On 15.05.20, 03:19, "Mattias Engdeg=C3=A5rd" wrote: > Thank you for reporting this. It seems that Calc first simplifies gcd(0,n= ) to n and then computes sum(n,n,-1,-1) =3D -1. > We could either make gcd(0,x)=3Dgcd(x,0)=3D|x|, or try preventing sum from si= mplifying its operand first, or both. > For the smallest possible change, what about the hack below? I see, so the simplest reproduction of the bug doesn't involve the sum, but= just the evaluation of gcd(0, x) or gcd(x, 0). Your fix seems sensible to m= e, I don't see why you consider it a 'hack'. The simplification gcd(0, x)=3Dgc= d(x, 0)=3Dabs(x) seems legit and matches the gcd definition "The largest posit= ive integer that divides each of the integers". From unknown Sun Jun 22 11:39:18 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: David Ongaro Subject: bug#41279: closed (Re: bug#41279: 26.3; Calc: sum(gcd(0,n),n,-1,-1) evaluates to -1 ) Message-ID: References: <6029B2F2-E131-46D8-A32A-57B158477DEA@acm.org> X-Gnu-PR-Message: they-closed 41279 X-Gnu-PR-Package: emacs Reply-To: 41279@debbugs.gnu.org Date: Fri, 15 May 2020 18:22:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1589566922-20335-1" This is a multi-part message in MIME format... ------------=_1589566922-20335-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #41279: 26.3; Calc: sum(gcd(0,n),n,-1,-1) evaluates to -1 which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 41279@debbugs.gnu.org. --=20 41279: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D41279 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1589566922-20335-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 41279-done) by debbugs.gnu.org; 15 May 2020 18:21:59 +0000 Received: from localhost ([127.0.0.1]:38703 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jZey6-0005Hk-TY for submit@debbugs.gnu.org; Fri, 15 May 2020 14:21:59 -0400 Received: from mail212c50.megamailservers.eu ([91.136.10.222]:58538 helo=mail194c50.megamailservers.eu) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jZey4-0005HR-R9 for 41279-done@debbugs.gnu.org; Fri, 15 May 2020 14:21:58 -0400 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1589566910; bh=6hTM6/4lee8QoEyRUFUjwMCR5PTpBS28QXa3Q/VIq4E=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=LS9AtMix4FZco9QnWDhCxsePkRDQRKw60PAV25cdiciJR+lc51niF8BefCPrmW/Os 9XN3ORAXBYUsRK18J+u8ozJRbuZ2fCMSapyiOLFZEqDYx2lf6srDRmGC5LCEdXgraJ kaVGYlE5TDczZvySVdxzwsQQqhurwH+EcD+CKnmE= Feedback-ID: mattiase@acm.or Received: from stanniol.lan (c-4e4ae655.032-75-73746f71.bbcust.telenor.se [85.230.74.78]) (authenticated bits=0) by mail194c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id 04FILmaw027570; Fri, 15 May 2020 18:21:49 +0000 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.14\)) Subject: Re: bug#41279: 26.3; Calc: sum(gcd(0,n),n,-1,-1) evaluates to -1 From: =?utf-8?Q?Mattias_Engdeg=C3=A5rd?= In-Reply-To: <20621430-4DFE-4E40-A616-9D404DDBB2BF@hamburg.de> Date: Fri, 15 May 2020 20:21:47 +0200 Content-Transfer-Encoding: quoted-printable Message-Id: <6029B2F2-E131-46D8-A32A-57B158477DEA@acm.org> References: <7D48D15C-1F8E-41C8-9B1C-650215C8101D@acm.org> <20621430-4DFE-4E40-A616-9D404DDBB2BF@hamburg.de> To: David Ongaro X-Mailer: Apple Mail (2.3445.104.14) X-CTCH-RefID: str=0001.0A782F29.5EBEDD41.000B, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: 0.000 X-CTCH-Rules: X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-CSC: 0 X-CHA: v=2.3 cv=KsozJleN c=1 sm=1 tr=0 a=klNLuyVZdLUgl+K5Uafb2A==:117 a=klNLuyVZdLUgl+K5Uafb2A==:17 a=kj9zAlcOel0A:10 a=M51BFTxLslgA:10 a=rTYYZ9R0T1RneXnqtekA:9 a=CjuIK1q_8ugA:10 X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: 41279-done Cc: 41279-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) 15 maj 2020 kl. 19.44 skrev David Ongaro : > I see, so the simplest reproduction of the bug doesn't involve the = sum, but just the evaluation of gcd(0, x) or gcd(x, 0). Your fix seems = sensible to me, I don't see why you consider it a 'hack'. The = simplification gcd(0, x)=3Dgcd(x, 0)=3Dabs(x) seems legit and matches = the gcd definition "The largest positive integer that divides each of = the integers". Quite, but there is a small possibility that further simplification = relies on the gcd(0,x)=3Dx behaviour. You never know with Calc: it is = complex and everything seems interconnected. After all, abs is often an = obstacle in algebraic transforms; you often end up splitting cases. That said, it's probably the right thing to do. Now pushed to master, = which means that you need to build a development snapshot from source, = or apply the change (60cd6cce55) to your Emacs. ------------=_1589566922-20335-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 15 May 2020 04:53:18 +0000 Received: from localhost ([127.0.0.1]:35621 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jZSLW-0003hI-EA for submit@debbugs.gnu.org; Fri, 15 May 2020 00:53:18 -0400 Received: from lists.gnu.org ([209.51.188.17]:53376) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jZSLS-0003h8-Do for submit@debbugs.gnu.org; Fri, 15 May 2020 00:53:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44004) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZSLS-0008EI-5g for bug-gnu-emacs@gnu.org; Fri, 15 May 2020 00:53:14 -0400 Received: from cosmopolitan.ops.eusc.inter.net ([2001:1560:3:255::151]:60694) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZSLQ-0003HS-MM for bug-gnu-emacs@gnu.org; Fri, 15 May 2020 00:53:13 -0400 X-Trace: 4c7c64617669642e6f6e6761726f4068616d627572672e64657c3137342e32312e 3130372e3134397c316a5a534c472d3030303249722d33457c3135383935313833 3832 Received: from cosmopolitan.ops.eusc.inter.net ([10.151.10.15] helo=localhost) by cosmopolitan.ops.eusc.inter.net with esmtpsa (Exim 4.93.0.4) id 1jZSLG-0002Ir-3E for bug-gnu-emacs@gnu.org; Fri, 15 May 2020 06:53:02 +0200 User-Agent: Microsoft-MacOutlook/16.37.20051002 Date: Thu, 14 May 2020 21:52:56 -0700 Subject: 26.3; Calc: sum(gcd(0,n),n,-1,-1) evaluates to -1 From: David Ongaro To: Message-ID: Thread-Topic: 26.3; Calc: sum(gcd(0,n),n,-1,-1) evaluates to -1 Mime-version: 1.0 Content-type: text/plain; charset="UTF-8" Content-transfer-encoding: quoted-printable X-SA-Exim-Connect-IP: 174.21.107.149 X-SA-Exim-Mail-From: david.ongaro@hamburg.de X-SA-Exim-Scanned: No (on cosmopolitan.ops.eusc.inter.net); SAEximRunCond expanded to false Received-SPF: pass client-ip=2001:1560:3:255::151; envelope-from=david.ongaro@hamburg.de; helo=cosmopolitan.ops.eusc.inter.net X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-Spam-Score: -1.6 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.6 (--) By accident I noticed that this algebraic expression yields 6 instead of 8 which would be correct: =C2=A0=C2=A0=C2=A0=C2=A0sum(sum(gcd(n, k), k, -1, 1), n, -1, 1) =3D> 6 I could narrow it down to this, which yields -1 instead of 1 =C2=A0=C2=A0=C2=A0=C2=A0sum(gcd(0, n), n , -1, -1) =3D> -1 Notably gcd(0, -1) evaluates to 1 as it should be. Also we have =C2=A0=C2=A0=C2=A0=C2=A0sum(gcd(n, 0), n, -1, -1) =3D> -1 but =C2=A0=C2=A0=C2=A0=C2=A0sum(sum(gcd(n, k), k, 0, 0), n, -1, -1) =3D> -1 =C2=A0=C2=A0=C2=A0=C2=A0sum(sum(gcd(n, k), k, -1, -1), n, 0, 0) =3D> 1 which violates gcd(n, k) =3D gcd(k, n). We also have =C2=A0=C2=A0=C2=A0=C2=A0sum(sum(gcd(n, k) =3D 1, k, -1, 1), n, -1, 1) =3D> 7 =C2=A0=C2=A0=C2=A0=C2=A0sum(sum(abs(gcd(n, k)), k, -1, 1), n, -1, 1) =3D> 8 which seems to confirm that it's not just the sum function but the combination of sum and gcd which might introduce the problem. To reproduce you can simply enter Calc embedded mode with C-x 8 e in a buffer with this email content, put the point on a corresponding formular and reevaluate with SPACE. I'd appreciate if this could be fixed. David In GNU Emacs 26.3 (build 1, x86_64-apple-darwin18.2.0, NS appkit-1671.20 Ve= rsion 10.14.3 (Build 18D109)) of 2019-09-02 built on builder10-14.porkrind.org Windowing system distributor 'Apple', version 10.3.1894 Recent messages: previous-line: Beginning of buffer [2 times] (Switching Calc Embedded mode to new formula.) [5 times] Working... [3 times] (Canceled) C-c C-c is undefined [2 times] (Switching Calc Embedded mode to new formula.) [9 times] user-error: Beginning of history; no preceding item [3 times] Quit Making completion list... [2 times] user-error: Beginning of history; no preceding item Configured using: 'configure --with-ns '--enable-locallisppath=3D/Library/Application Support/Emacs/${version}/site-lisp:/Library/Application Support/Emacs/site-lisp' --with-modules' Configured features: NOTIFY ACL GNUTLS LIBXML2 ZLIB TOOLKIT_SCROLL_BARS NS MODULES THREADS Important settings: =C2=A0=C2=A0value of $LC_ALL: en_US.utf-8 =C2=A0=C2=A0value of $LC_CTYPE: UTF-8 =C2=A0=C2=A0value of $LANG: en_US.utf-8 =C2=A0=C2=A0locale-coding-system: utf-8-unix Major mode: Fundamental Minor modes in effect: =C2=A0=C2=A0tooltip-mode: t =C2=A0=C2=A0global-eldoc-mode: t =C2=A0=C2=A0electric-indent-mode: t =C2=A0=C2=A0mouse-wheel-mode: t =C2=A0=C2=A0tool-bar-mode: t =C2=A0=C2=A0menu-bar-mode: t =C2=A0=C2=A0file-name-shadow-mode: t =C2=A0=C2=A0global-font-lock-mode: t =C2=A0=C2=A0font-lock-mode: t =C2=A0=C2=A0blink-cursor-mode: t =C2=A0=C2=A0auto-composition-mode: t =C2=A0=C2=A0auto-encryption-mode: t =C2=A0=C2=A0auto-compression-mode: t =C2=A0=C2=A0buffer-read-only: t =C2=A0=C2=A0line-number-mode: t =C2=A0=C2=A0transient-mark-mode: t Load-path shadows: None found. Features: (shadow sort mail-extr emacsbug message rmc puny seq byte-opt gv bytecomp byte-compile cconv dired dired-loaddefs format-spec rfc822 mml mml-sec password-cache epa derived epg epg-config gnus-util rmail rmail-loaddefs mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils calc-arith calc-prog calc-yank calccomp calcalg2 calc-misc calc-comb calc-map calc-alg calc-aent cl-seq calc-menu easymenu calc-embed cl-loaddefs cl-lib calc-ext calc calc-loaddefs calc-macs elec-pair time-date tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type mwheel term/ns-win ns-win ucs-normalize mule-util term/common-win tool-bar dnd fontset image regexp-opt fringe tabulated-list replace newcomment text-mode elisp-mode lisp-mode prog-mode register page menu-bar rfn-eshadow isearch timer select scroll-bar mouse jit-lock font-lock syntax facemenu font-core term/tty-colors frame cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese composite charscript charprop case-table epa-hook jka-cmpr-hook help simple abbrev obarray minibuffer cl-preloaded nadvice loaddefs button faces cus-face macroexp files text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote threads kqueue cocoa ns multi-tty make-network-process emacs) Memory information: ((conses 16 243141 10243) (symbols 48 24190 1) (miscs 40 99 401) (strings 32 37828 1759) (string-bytes 1 996761) (vectors 16 38186) (vector-slots 8 766279 17952) (floats 8 49 73) (intervals 56 315 13) (buffers 992 15)) ------------=_1589566922-20335-1--