Re: sum question
- To: mathgroup at smc.vnet.net
- Subject: [mg91210] Re: sum question
- From: Bill Rowe <readnews at sbcglobal.net>
- Date: Sat, 9 Aug 2008 07:47:43 -0400 (EDT)
On 8/8/08 at 7:14 AM, philip-kopp at uiowa.edu (Kopp, Philip F) wrote: >Hi, I am trying to work with a rather large sum(>200 terms) in >Mathematica , but the program displays some odd behavior. When I >multiply each term in the sum by 1, I get 1 for the answer. When I >change 1 to 1.0, I get an incredibly large number for the answer. >There seems to be some problem with using decimal numbers in this >large sum. I tried Rationalize[1.0], and it works. What I am really >trying to do is multiply each term by a different number(all less >than one) that I calculated in another program. These numbers are >in decimal form, so I run into the same problem. When I try >rationalize here, it doen't fix the problem. Your description above suggests the issue is due to numeric issues that arise when using machine precision numbers. I would guess the terms in you sum likely involve say differences of two nearly equal things where or some similar operation that will be very sensitive o round off issues. Your description indicates a solution. That is using exact arithmetic. The file of decimal numbers can be converted to exact numbers using Rationalize. Of course the cost of doing this will be an overall decrease in execution speed. If you need more specific suggestions, you will have to provide more detail such as example data and the Mathematica code you are currently using.