HP 34s summation question « Next Oldest | Next Newest »

 ▼ Richard Berler Member Posts: 109 Threads: 38 Joined: Dec 2012 12-31-2012, 11:38 PM I was surprised to find that the hp 34s's onboard summation function was much slower at calculating from 1-600 the sum of 4/(n*(n+2))than a simple program for that sum on my hp 15C LE (the 15C has no onboard summation function). The hp 15C LE took 6.3 seconds while the 34s onboard summation function took about 16 seconds. I ran the same program that I ran on the 15C on the 34s and then came up with the sum in about 2.7 seconds. Should I be surprised that my simple program on the 34s comes up with the answer about 6 times as fast as with the onboard summation function? ▼ Paul Dale Posting Freak Posts: 3,229 Threads: 42 Joined: Jul 2006 01-01-2013, 01:11 AM The secret behind the slowness of the built in summation function is that is isn't naïvely summing the returned terms as I suspect your program is. It uses the Kahan Sum algorithm instead which provides better numerical results by utilising both a register for the sum and a register for the lower order digits correction term. the cost is of course, more operations and hence it will be slower. It doesn't provide double the number of digits of accuracy but it does provide somewhat more than just summing the terms and it comes into its own when lots of small numbers are summed to produce a larger result. The source code is an interesting read, but don't try to analyse it using algebra -- the correction term is universally zero in that case. In a floating point world, it isn't however and this is the important point and why the result will be more accurate. Essentially, it boiled down to a choice of fast or accurate. I chose the latter. This is universally the trade off made on the 34S. The results must be correct even if they take longer. - Pauli Paul Dale Posting Freak Posts: 3,229 Threads: 42 Joined: Jul 2006 01-01-2013, 01:14 AM Your function probably isn't the best example but check the lowest order digits. Ideally, you want to sum this series in reverse so the small terms accumulate before the larger ones. - Pauli Thomas Klemm Senior Member Posts: 735 Threads: 34 Joined: May 2007 01-01-2013, 02:54 AM Quote: calculating from 1-600 the sum of 4/(n*(n+2)) As this is a telescoping series the result is simply:    Thus no real need to use a summation function. Kind regards Thomas

 Possibly Related Threads... Thread Author Replies Views Last Post HP Prime Error: Summation Upper Bound > 1000 HP Pioneer 2 1,160 10-25-2013, 11:32 AM Last Post: steindid WP-34S (Prime Number Test) question Barry Mead 3 1,381 10-20-2013, 05:28 PM Last Post: Dieter WP-34S: question - Initialization of local registers Marcel Samek 8 2,137 07-07-2013, 09:57 PM Last Post: Steve Simpkin [WP 34s] Summation Function (Sigma) Paul C 11 2,339 01-29-2013, 07:42 AM Last Post: C.Ret Question about WP-34S firmware Nigel J Dowrick 4 1,263 08-25-2012, 06:14 PM Last Post: Paul Dale WP-34S Programming Question Matt Agajanian 2 1,057 08-04-2012, 02:04 PM Last Post: Matt Agajanian WP 34S programming question Nigel J Dowrick 35 6,674 04-10-2012, 02:23 AM Last Post: Walter B [wp 34s] wp 34s picture and scan Jeroen Van Nieuwenhove 2 951 10-27-2011, 09:02 PM Last Post: Les Wright WP 34S : [->] command question Miguel Toro 6 1,542 08-27-2011, 01:50 AM Last Post: Marcus von Cube, Germany 50g won't plot summation function, but emulator will. Hal Bitton in Boise 2 1,000 04-12-2011, 07:14 PM Last Post: Hal Bitton in Boise

Forum Jump: