Kahan summation algorithm – Printable Version +- HP Forums (http://www.hpmuseum.org/forum) +– Forum: HP Calculators (and very old HP Computers) (/forum-3.html) +— Forum: General Forum (/forum-4.html) +— Thread: Kahan summation algorithm (/thread-2668.html) Kahan summation algorithm – Thomas Klemm – 12-19-2014 10:12 PM For details please consult Wikipedia. Program for the HP-42S: Code: 00 { 19-Byte Prgm } 01 LBL "KAHAN" 02 + 03 ENTER 04 RCL+ ST Z 05 STO- ST Z 06 X<> ST Z 07 + 08 END Worked example: $$10^{10}+\pi+e$$ CLST E10 ENTER 0 PI XEQ “KAHAN” 1 E↑X R/S y: 10,000,000,005.9 x: -0.04012551795 This is the correctly rounded result. The classic addition is not the same: E10 PI + 1 E↑X + y: 0 x: 10,000,000,005.8 Cheers Thomas RE: Kahan summation algorithm – Gerald H – 12-20-2014 10:47 AM Thank you. Never seen this before. RE: Kahan summation algorithm – Werner – 12-21-2014 09:52 AM What I have never seen mentioned is the fact that this algorithm is meant for binary floating point. Try adding x=y= 1e12-2 You’ll get s := 2e12 c := -2, while it should be -4 BTW my version reads: Code: *LBL "K+" + RCL+ ST Y STO- ST Y X<>Y RCL+ ST L END same size. Werner

http://www.talkingelectronics.com/

Welcome to Talking Electronics!

 Click to go to Interactive Site See Colin Mitchell on YouTube: For all enquiries, please contact Colin Mitchell on: 0417 329788 (from overseas:  +61  417 329788) Before placing any order or for any technical questions etc, please email me: Colin Mitchell:

by Eric hpcalc.org