Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: math module for Decimals

0 views
Skip to first unread message

Raymond L. Buvel

unread,
Dec 29, 2008, 10:59:00 AM12/29/08
to pytho...@python.org
Since the interest is more in extended precision than in decimal
representation, there is another module that may be of interest.

http://calcrpnpy.sourceforge.net/clnum.html

It interfaces to the Class Library for Numbers (CLN) library to provide
both arbitrary precision floating point and complex floating point
numbers and the usual math functions.

While I am the author of this module, I agree with Mark that a module
based on MPFR would be better since you have better control over
precision and rounding.

I have looked at Sage (which uses MPFR) but it is a huge integrated
package so you can't just import what you need into one of your usual
Python scripts.

I wrote the clnum module mainly to support arbitrary precision in an RPN
calculator available from the same SourceForge project. However, it
also works nicely as a stand-alone module.

At this time, there is no Windows installer available for Python 2.6
because I don't use Windows at home and the person who normally builds
the installer for me is no longer interested. If someone wants to
follow the published instructions and send me the resulting installer, I
will put it up on SourceForge.

Ray

Jerry Carl wrote:

>> 1. mpmath?
> 2. sympy?
> 3. Sage?

Haven't tried those, i guess i have some studying to do.

> > x=Decimal.__mod__(x,Decimal('2')*pi())

> > Works fine for what i need, but i am sure it's not the right way to do
> > it.

> I don't know of any better way to deal with large arguments.
> The main problem is that the reduction step can introduce fairly
> large errors: for example, if you're using a value of pi
> that's accurate to 10**-20, say, then reducing something of
> magnitude 10**5*pi will give a result with error of around
> 10**-15. As far as I know, this problem is essentially
> unavoidable, and it's the reason why implementing sin for inputs
> like 10**999999999 isn't feasible.

Good point. No tool will work in all parts of the universe (which is
especially true for the universal ski wax).

Let me check the 3 modules you listed above!

Steve Holden

unread,
Dec 29, 2008, 11:22:17 AM12/29/08
to pytho...@python.org
Raymond L. Buvel wrote:
> Since the interest is more in extended precision than in decimal
> representation, there is another module that may be of interest.
>
> http://calcrpnpy.sourceforge.net/clnum.html
>
> It interfaces to the Class Library for Numbers (CLN) library to provide
> both arbitrary precision floating point and complex floating point
> numbers and the usual math functions.
>
> While I am the author of this module, I agree with Mark that a module
> based on MPFR would be better since you have better control over
> precision and rounding.
>
> I have looked at Sage (which uses MPFR) but it is a huge integrated
> package so you can't just import what you need into one of your usual
> Python scripts.
>
> I wrote the clnum module mainly to support arbitrary precision in an RPN
> calculator available from the same SourceForge project. However, it
> also works nicely as a stand-alone module.
>
> At this time, there is no Windows installer available for Python 2.6
> because I don't use Windows at home and the person who normally builds
> the installer for me is no longer interested. If someone wants to
> follow the published instructions and send me the resulting installer, I
> will put it up on SourceForge.
>
I'm not sure why nobody has mentioned gmpy, except possibly because it
advertises its alpha status and doesn't have many active developers.

regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/

rlb...@gmail.com

unread,
Dec 29, 2008, 11:42:59 AM12/29/08
to

The main reason is that it doesn't support the functions the OP wanted
(sin, cos, log, etc.). This was one of the reasons I developed clnum
(in addition to needing complex numbers).

Ray

0 new messages