The Museum of HP Calculators

HP Forum Archive 21

 HP 50g Takes hours to compute a convergent seriesMessage #1 Posted by Matthew Richards on 9 May 2013, 1:20 p.m. I almost called HP support thinking my 50g was broken. I was following the tutorials in the manual and when I tried to find the sum of 1/k^2 from 1 to infinity, the calculator took over 15 min, so I stopped it and rebooted it. I tried again and let it go for an hour before I canceled it. I then let it run all night and today it rebooted and complained that the batteries were low. Today I tried it attached to my USB with new batteries. After 2 hours I canceled it and started to call HP, but I paused and thought about the modes that could cause this problem. I had it set to approximate mode. It hit me... This thing was trying to approximate the area under the curve using some type of Riemann's sum within who knows what error bound. I changed it to exact mode and it solved it in about 1 second. Would this thing have ever found an approximate answer? I also had the number format set to standard. If I change the format to fixed and some smaller precision, will the 50g increase the error to reduce the number of terms and reduce the computation time? I'm going to try it, but I was curious if anyone knew how this thing worked when approximating.

 Re: HP 50g Takes hours to compute a convergent seriesMessage #2 Posted by Joe Horn on 10 May 2013, 6:07 a.m.,in response to message #1 by Matthew Richards Integration, not summation, is controlled by the display mode. Setting FIX to something small will not change how fast a sum is computed. Furthermore, in approximate mode, the Greek Sigma function doesn't do any kind of mathematical simplification or thinking at all; it just loops from a to b and adds all the terms together. If flag -21 is clear and flag -22 is set, then a summation from 1 to to infinity will take an infinite amount of time. In other words, Don't Do That. If you want the 50g to do any kind of symbolic simplification, you must be in exact mode. Otherwise it'll just crank it numerically by brute force looping, which is great for summations that exact mode doesn't know how to simplify. Need an approximate summation to infinity that can't be simplified? Then instead of using infinity, just use a number that's large enough to get a useful answer but not so large that it takes too long. Infinity never makes sense in approximate mode. Hope that helps!

 Re: HP 50g Takes hours to compute a convergent seriesMessage #3 Posted by Eddie W. Shore on 11 May 2013, 10:13 a.m.,in response to message #2 by Joe Horn For calculations involving infinite sums, I use an upper limit of 250-500 to get a reasonable estimation - the time takes a few seconds instead of forever.

 Re: HP 50g Takes hours to compute a convergent seriesMessage #4 Posted by Thomas Klemm on 11 May 2013, 6:46 p.m.,in response to message #3 by Eddie W. Shore Quote: I use an upper limit of 250-500 to get a reasonable estimation That might not be enough in this case: $\sum_{n=1}^{500}\frac{1}{n^2}=1.64293606551...$ $\sum_{n=1}^{\infty}\frac{1}{n^2}=1.64493406684...$ Kind regards Thomas

 Re: HP 50g Takes hours to compute a convergent seriesMessage #5 Posted by C.Ret on 12 May 2013, 3:20 p.m.,in response to message #4 by Thomas Klemm Are you sure that summing 100, 500 or 600 terms makes a difference compare to an infinity ? Looking at this graph, I am not sure ? It is looking really similar. But of course this is only my point of view (or a scaling problem).

 Re: HP 50g Takes hours to compute a convergent seriesMessage #6 Posted by Thomas Klemm on 13 May 2013, 12:46 a.m.,in response to message #5 by C.Ret We can estimate the error by integrating 1/x2 from N to infinity which leads to: 1/N. Thus you'd need to add a million terms to get 6 correct places. While this might still be done in a reasonable amount of time it takes probably too long to get 12 correct places. The estimated error for your examples is: ```100: 0.0100 500: 0.0020 600: 0.0017 ``` You might not notice a difference by just looking at a graph. Kind regards Thomas

 Re: HP 50g Takes hours to compute a convergent seriesMessage #7 Posted by Gjermund Skailand on 13 May 2013, 6:04 a.m.,in response to message #6 by Thomas Klemm I suggest you try my hpgcc2 library at hpcalc.org. It is a numeric library, it will not calculate any infinite sums, but it should speed up the calculaton of sums by 50x to 100x http://www.hpcalc.org/hp49/graphics/plotting/int1d.zip Best regards Gjermund

 Re: HP 50g Takes hours to compute a convergent seriesMessage #8 Posted by Thomas Klemm on 13 May 2013, 6:54 a.m.,in response to message #7 by Gjermund Skailand You might as well be interested in this recent thread about Riemann's Zeta Function (HP 50g) as $\sum_{n=1}^{\infty}\frac{1}{n^2}=\zeta(2)$ Cheers Thomas Edited: 13 May 2013, 7:00 a.m.

 Re: HP 50g Takes hours to compute a convergent seriesMessage #9 Posted by Thomas Klemm on 13 May 2013, 7:23 a.m.,in response to message #7 by Gjermund Skailand From the readme.txt: Quote: Calculate sum(i=1 to 1000000) in about 10s. That's still ~115 days just to calculate the sum from 1 to 1012. Keep in mind that we didn't calculate 1/n2 for each term yet. Compare that to the result using Rieman's Zeta function: ``` s | Zeta(s) | time(s) | exact value ---------+----------------------+----------+----------------- 2. | 1.64493406685 | 0.479 | pi^2/6 ``` Sometimes it's worth to think a little on how to compute a result. Cheers Thomas Edited: 13 May 2013, 7:29 a.m.

 Re: HP 50g Takes hours to compute a convergent seriesMessage #10 Posted by Matthew Richards on 14 May 2013, 10:33 a.m.,in response to message #9 by Thomas Klemm This is great information, thank you. I'm sure it's very obvious to everyone that I'm very new to the calculus and advanced math world. I've been programming professionally for over 20 years and never had an opportunity to finish my undergrad. I work for a research lab and they asked me to continue my education and start working on a graduate degree. Now I'm back in school (Engineering Physics) and I'm starting from the ground up (The U of I only accepted a few of my liberal arts classes, which is probably a good thing). Most of my coworkers are engineers and they praise the HP calculators. One coworker gave me an HP-67 that I restored. I bought a 35s and a 50g and I'm slowly learning these amazing machines. I'm taking Calc 3 this summer and I've started studying vector calculus in preparation. I'm trying to augment my studies, and make it more interesting, by learning how to do the operations on the 50g and 35s and figure out how the calculator is doing what it does. I realized after I posted that the calculator probably was just doing a sum out to some number of partial sums. At first I thought it might be using an integral and then calculating the integral using a Riemann's sum, but it probably makes more sense that it's just summing the partial sums. It seems like an impossible task to have the calculator determine if the series is geometric or something else and find the radius of convergence to sum with a/(1-r). I suppose it could divide the sums to find the ratio, but that doesn't always work. Also thinking about it, I would imagine the calculator has to be doing some type of convergence tests and then finding the sum, but I'm surprised that it would just start calculating the sums to infinity without giving some error or stopping when it reaches a number that is correct within certain error. What if the series diverges (1/n) or it's an alternating series [(-1)^n/n]? Realize, I'm using a very limited amount of knowledge to figure out a black box (literally) that was designed by geniuses (like the people in this forum) with intelligence far greater than my own. Someday I hope to understand some portion of this math.

 Re: HP 50g Takes hours to compute a convergent seriesMessage #11 Posted by Thomas Klemm on 14 May 2013, 3:30 p.m.,in response to message #10 by Matthew Richards Hi Matthew Good luck with your studies and I hope you enjoy them together with your multiple HP calculators. To me they were always a good help in understanding mathematical problems: writing a program to solve a problem still makes me understand it better. You brought up a problem which obviously isn't easy to solve. While WolframAlpha provides a list of convergence tests: The ratio test is inconclusive. The root test is inconclusive. By the comparison test, the series converges. you may not expect too much from the HP-50g. For its size it's a rather powerful calculator but still has limitations and it's important to find these since that gives you the confidence when using a tool. Kind regards Thomas

Go back to the main exhibit hall