Re: math module for Decimals

2009-01-06 Thread Fredrik Johansson
On Jan 6, 8:29 pm, Mark Dickinson wrote: > Note that it's still subject to the same limitations as anything > else for trig_function(really huge argument), of course: > > >>> import mpmath > >>> mpmath.cos(mpmath.mpf('1e9')) > > [... still waiting for a result 30 minutes later ...] > > (n

Re: math module for Decimals

2009-01-06 Thread Fredrik Johansson
On Dec 28 2008, 4:55 pm, jerry.carl...@gmail.com wrote: > > - are you usingDecimalfor the base-10-ness or the > >   extra precisionDecimalprovides?  Or significant zeros? > >   Or compatibility with existingDecimalcode, or what? > > Oh boy, now I will finally prove myself illiterate... well, so be

Re: how to get the thighest bit position in big integers?

2008-10-06 Thread Fredrik Johansson
On Oct 5, 5:26 pm, [EMAIL PROTECTED] wrote: > Hi, > > My question to the group: Does anyone know of a non-hackish way to > determine the required bit position in python? I know that my two > ideas > can be combined to get something working. But is there a *better* way, > that isn't that hackish? N

Re: About Rational Number (PEP 239/PEP 240)

2007-12-15 Thread Fredrik Johansson
On Dec 15, 2007 10:05 PM, Lie <[EMAIL PROTECTED]> wrote: > Random ramble past here: > Actually, my vision would be not only fractions, but also rooted > number (square root, cube root, etc), it could be possible to > implement a type where a number consist of a rooted number times a > multiplier pl

Re: Trouble getting loop to break

2007-11-25 Thread Fredrik Johansson
On Nov 25, 2007 2:47 PM, Dick Moores <[EMAIL PROTECTED]> wrote: > Wow. your f() is ingenious, Frederik. Thanks very much. > > Any more tricks up your sleeve? You did say a post or so ago, > "Further improvements are possible." The next improvement would be to find a recurrence formula for the term

Re: Trouble getting loop to break

2007-11-25 Thread Fredrik Johansson
On Nov 25, 2007 9:00 AM, Dick Moores <[EMAIL PROTECTED]> wrote: > Fredrik, > > I'm afraid I'm just too dumb to see how to use your first suggestion > of cached_factorials. Where do I put it and def()? Could you show me, > even on-line, what to do? > You (

Re: Next float?

2007-11-22 Thread Fredrik Johansson
On Nov 22, 2007 4:04 AM, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > Is there a simple, elegant way in Python to get the next float from a > given one? By "next float", I mean given a float x, I want the smallest > float larger than x. > > Bonus points if I can go in either direction (i.e. the "pr

Re: Trouble getting loop to break

2007-11-20 Thread Fredrik Johansson
On Nov 20, 2007 10:00 PM, Dick Moores <[EMAIL PROTECTED]> wrote: > And also with the amazing Chudnovsky algorithm for pi. See > Nice! I'd like to suggest two improvements for speed. First, the Chudnovsky algorithm uses lots of factorials, and it's rather ine

Re: Trouble getting loop to break

2007-11-20 Thread Fredrik Johansson
On Nov 20, 2007 8:41 AM, Dick Moores <[EMAIL PROTECTED]> wrote: > I'm writing a demo of the infinite series > > x**0/0! + x**1/1! + x**2/2! + x**3/3! + ... = e**x (x is non-negative) > > It works OK for many x, but for many the loop doesn't break. Is there > a way to get it to break where I wan

Re: Help with sympy, please

2007-11-18 Thread Fredrik Johansson
On Nov 19, 2007 2:23 AM, Dick Moores <[EMAIL PROTECTED]> wrote: > OK, I tried mpmath again, and to my surprise, it went well! > > === > #!/usr/bin/env python > #coding=utf-8 > from mpmath import * > mpf.dps = 50 > n = 1 > k = 0 > prod = mpf(1) > while k < 10: >

Re: Help with sympy, please

2007-11-18 Thread Fredrik Johansson
On Nov 19, 2007 2:09 AM, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > On Sun, 18 Nov 2007 16:05:15 -0800, Dick Moores <[EMAIL PROTECTED]> > declaimed the following in comp.lang.python: > > > TypeError: unsupported operand type(s) for /: 'float' and 'Float' > > > > > What restrict

Re: Help with sympy, please

2007-11-18 Thread Fredrik Johansson
On Nov 19, 2007 2:03 AM, Dick Moores <[EMAIL PROTECTED]> wrote: > At 04:26 PM 11/18/2007, Fredrik Johansson wrote: > >On Nov 19, 2007 1:05 AM, Dick Moores <[EMAIL PROTECTED]> wrote: > >Hi Dick, I recognize you from python-list, where you had a question > >about mpm

Re: Help with sympy, please

2007-11-18 Thread Fredrik Johansson
On Nov 19, 2007 1:05 AM, Dick Moores <[EMAIL PROTECTED]> wrote: > At 03:42 PM 11/18/2007, Dennis Lee Bieber wrote: > >On Sun, 18 Nov 2007 13:02:01 -0800, Dick Moores <[EMAIL PROTECTED]> > >declaimed the following in comp.lang.python: > > > > > > > > This gets: > > > Traceback (most recent call last

Re: mpmath puzzle

2007-11-14 Thread Fredrik Johansson
On Nov 14, 2007 8:21 PM, <[EMAIL PROTECTED]> wrote: > You could also use the Decimal module to keep things accurate. Some > people like numpy or scipy for the more complex math problems they do. Unlike mpmath, the decimal module doesn't support non-integer powers (except for square roots), and no

re: mpmath puzzle

2007-11-14 Thread Fredrik Johansson
Dick Moores wrote: > For 1234 ** 10.9, why the wrong result from mpmath.power()? > > > #!/usr/bin/env python > #coding=utf-8 > from mpmath import * > > mpf.dps = 32 > > x = mpf(1234) > y = mpf(10.9) > > print power(x,y) > print "4.95832786481550414774152344

Going past the float size limits?

2007-10-28 Thread Fredrik Johansson
jimmy.musselwhite at gmail.com wrote: > Hello all > It would be great if I could make a number that can go beyond current > size limitations. Is there any sort of external library that can have > infinitely huge numbers? Way way way way beyond say 5x10^350 or > whatever it is? > I'm hitting that "

Re: A brief question.

2005-07-02 Thread Fredrik Johansson
On 7/3/05, Tom Anderson <[EMAIL PROTECTED]> wrote: > That's one way. I'd do: > > root = value ** 0.5 > > Does that mean we can expect Guido to drop math.sqrt in py3k? :) I'd rather like to see a well implemented math.nthroot. 64**(1/3.0) gives 3.9996, and this error could be avoided.

Re: Modules for inclusion in standard library?

2005-06-27 Thread Fredrik Johansson
but I would probably use it if it was in the standard library. -- Fredrik Johansson -- http://mail.python.org/mailman/listinfo/python-list