[Tutor] the binary math "wall"
Ricardo Aráoz
ricaraoz at gmail.com
Wed Apr 21 19:24:14 CEST 2010
Lowell Tackett wrote:
> >From the virtual desk of Lowell Tackett
>
>
>
> --- On Wed, 4/21/10, Dave Angel <davea at ieee.org> wrote:
>
>
>> From: Dave Angel <davea at ieee.org>
>> Subject: Re: [Tutor] the binary math "wall"
>> To: "Lowell Tackett" <lowelltackett at yahoo.com>
>> Cc: tutor at python.org, "Steven D'Aprano" <steve at pearwood.info>
>> Date: Wednesday, April 21, 2010, 12:31 PM
>> Lowell Tackett wrote:
>>
>>> From the virtual desk of Lowell Tackett
>>>
>>>
>>>
> *Whole buncha stuff snipped*
>
>> Anyway, in your case binary floating point is
>> irrelevant. You've got to do your own error analysis
>> of every step in the calculation to understand how much you
>> can trust the result. And it's unlikely the "errors"
>> in the math package will be the limiting factor.
>>
>> DaveA
>>
>>
>>
>
> The sense of all this is beginning to emerge (perhaps). Emile has just made a good point, simply convert all to whole values (using a subset algorithm that keeps track of the number of decimal "slips" that have accumulated-for later reconversion), crunch merrily away, and get good results.
>
> Maybe that's valid, maybe not. But I do know that this much is happening; I'm now beginning to quantify very novel and wide ranging ideas way outside "the box" I'd originally approached the challenge with. That's the bigger value of this entire exercise, I think. Naively thinking that the computer was benign and forgiving, I'd first opted for the most transparent and 'at hand' solutions...there was much to be learned.
>
> I know a coupla things now...I'm gonna solve this dilemma, and largely with the help of all who've weighed in. The solution may ultimately not be close to what has been suggested, but isn't that the fun of it all?
>
> Secondly, there has accumulated [here] quite an array of novel (to me) thinking that I'm going to return to more and more as I tackle other, different projects, for the pedagogical value that will linger.
>
Check python help docs for module decimal, there you have an example on
how to code a sin() and cos() functions with arbitrary precision
(depends on your context precision) using decimal values. Might be what
you are looking for (of course you would have to express your angles in
radians throughout all of your calculations and if needed convert at the
end.
HTH
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100421/36e39334/attachment.html>
More information about the Tutor
mailing list