RE: Re: sum question

• To: mathgroup at smc.vnet.net
• Subject: [mg91240] RE: [mg91210] Re: sum question
• From: "Kopp, Philip F" <philip-kopp at uiowa.edu>
• Date: Mon, 11 Aug 2008 06:05:55 -0400 (EDT)
• References: <15975876.1218319650981.JavaMail.root@m08>,<op.ufm5apsq2c6ksp@bobbys-imac>

```Thanks to everyone who has offered help, but I have performed my task with
a different code.  I no longer need any suggestions here.

________________________________________
From: DrMajorBob [drmajorbob at att.net]
Sent: Saturday, August 09, 2008 5:41 PM
To: Bill Rowe; mathgroup at smc.vnet.net; Kopp, Philip F
Subject: [mg91240] Re: [mg91210] Re: sum question

Sadly, if Bill Rowe's guess is correct, rationalizing gives an EXACT
answer which, most likely, is completely wrong. That is, changing the code
as suggested doesn't change the fact that there's a lot of doubt as to the
value of your sum, as it has NO significant digits.

If the decimal numbers in question originated as exact quantities
(rational fractions, for instance) you may need to try computing in that
original form, not with the intermediate Reals you're now using.

If one of those numbers was x = 2.22144, for instance, Rationalize might
return

Rationalize[x]

2.22144

or

Rationalize[x, 0]

82187392/36997325

But it might have originated as

N[Pi Sin[Pi/4]]

2.22144

2.22144, Pi Sin[Pi/4], 82187392/36997325, and N[Pi Sin[Pi/4]] are very
different. The first and second are exact but different, while the first
and last are not even the same to machine precision.

Using Pi Sin[Pi/4] in your summation may be a lot slower, but it will also
be far more exact.

If you make that trade-off for thousands of entries, you may end with a
sum that's prohibitively slow to compute. But using the decimals may give
nothing but zero-precision, hence meaningless, answers.

Bobby

On Sat, 09 Aug 2008 06:47:43 -0500, Bill Rowe <readnews at sbcglobal.net>
wrote:

> 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.
>
>

--
DrMajorBob at longhorns.com

```

• Prev by Date: Re: Suggestions for selling a copy of Mathematica V6 wanted
• Next by Date: Re: More Inquiries
• Previous by thread: Re: sum question
• Next by thread: Purchasing Mathematica