[sage-support] Re: Arbitrary precision in cython

2008-12-22 Thread William Stein
On Mon, Dec 22, 2008 at 3:37 PM, John Cremona wrote: > > 2008/12/22 William Stein : >> >> On Mon, Dec 22, 2008 at 1:51 PM, M. Yurko wrote: >>> >>> First, about my issues with PARI's precision. I just tested the >>> following: >>> -pari(-10).eint1().n(150) >>> and got 2492.22897624187775411641609

[sage-support] Re: Arbitrary precision in cython

2008-12-22 Thread John Cremona
2008/12/22 William Stein : > > On Mon, Dec 22, 2008 at 1:51 PM, M. Yurko wrote: >> >> First, about my issues with PARI's precision. I just tested the >> following: >> -pari(-10).eint1().n(150) >> and got 2492.2289762418777541164160993503173813223839 which is >> inaccurate after the 14th decimal p

[sage-support] Re: Arbitrary precision in cython

2008-12-22 Thread William Stein
On Mon, Dec 22, 2008 at 1:51 PM, M. Yurko wrote: > > First, about my issues with PARI's precision. I just tested the > following: > -pari(-10).eint1().n(150) > and got 2492.2289762418777541164160993503173813223839 which is > inaccurate after the 14th decimal place. As Stein said, Its quite > like

[sage-support] Re: Arbitrary precision in cython

2008-12-22 Thread M. Yurko
First, about my issues with PARI's precision. I just tested the following: -pari(-10).eint1().n(150) and got 2492.2289762418777541164160993503173813223839 which is inaccurate after the 14th decimal place. As Stein said, Its quite likely that I didn't call PARI correctly, as this is the first time

[sage-support] Re: Arbitrary precision in cython

2008-12-22 Thread Robert Bradshaw
On Dec 22, 2008, at 8:28 AM, M. Yurko wrote: > When I timed these functions over 1 through 700 at 53 bits of > precision, the python one took 5.46 sec., the double precision cython > one took only .02 sec., and the arbitrary precision one took 6.77 sec. > After looking at the .c file that cython

[sage-support] Re: Arbitrary precision in cython

2008-12-22 Thread John Cremona
2008/12/22 William Stein : > > On Mon, Dec 22, 2008 at 9:57 AM, John Cremona wrote: >> >> 2008/12/22 M. Yurko : >>> >>> It is the exponential integral, but I want greater than double >>> precision. I tried PARI, and it reports the number in arbitrary >>> precision, but it is only seems to be accu

[sage-support] Re: Arbitrary precision in cython

2008-12-22 Thread William Stein
On Mon, Dec 22, 2008 at 9:57 AM, John Cremona wrote: > > 2008/12/22 M. Yurko : >> >> It is the exponential integral, but I want greater than double >> precision. I tried PARI, and it reports the number in arbitrary >> precision, but it is only seems to be accurate to double precision as >> all di

[sage-support] Re: Arbitrary precision in cython

2008-12-22 Thread John Cremona
2008/12/22 M. Yurko : > > It is the exponential integral, but I want greater than double > precision. I tried PARI, and it reports the number in arbitrary > precision, but it is only seems to be accurate to double precision as > all digits after are completely wrong. Also, I'm trying to compare a

[sage-support] Re: Arbitrary precision in cython

2008-12-22 Thread M. Yurko
It is the exponential integral, but I want greater than double precision. I tried PARI, and it reports the number in arbitrary precision, but it is only seems to be accurate to double precision as all digits after are completely wrong. Also, I'm trying to compare a few a acceleration ideas for the

[sage-support] Re: Assigning

2008-12-22 Thread Georg Muntingh
Thanks a lot, both for the explanation and the solution! globals() did the trick for me. Georg. On Dec 22, 4:19 pm, "Mike Hansen" wrote: > On Mon, Dec 22, 2008 at 6:12 AM, Timothy Clemans > > wrote: > > > sage: sage0("var('a b c')") > > (a, b, c) > > sage: sage0("a = b/c") > > > b > > That's n

[sage-support] Re: Arbitrary precision in cython

2008-12-22 Thread William Stein
On Mon, Dec 22, 2008 at 8:40 AM, John Cremona wrote: > > That looks very like the exponential integral you are computing. If > so, you can use Sage's function Ei() which calls scipy's > special.exp1(). Watch out, since scipy is double precision only. Pari has a real-only exponential integral t

[sage-support] Re: Arbitrary precision in cython

2008-12-22 Thread John Cremona
That looks very like the exponential integral you are computing. If so, you can use Sage's function Ei() which calls scipy's special.exp1(). John Cremona 2008/12/22 M. Yurko : > > Alright, below is the original python implementation of the function: > > def python(x,bits): >i = 1 >sum_c

[sage-support] Re: Comparing expressions and equations

2008-12-22 Thread William Stein
On Sun, Dec 21, 2008 at 6:26 PM, evans wrote: > > All these are identical (unless there are typos)... > > x^2 + ((2-y)/3)x + 3 = 0 > > x^2 + (2/3-y/3)x + 3 = 0 > > x^2 + (\frac{2}{3}-\frac{y}{3}) x + 3 = 0 > > x^2 + \frac{(2-y)}{3}x + 3 = 0 > > x^2 + \frac{(2-y)}{3} * x + 3 = 0 > > 3 + x^2 + \fra

[sage-support] Re: Arbitrary precision in cython

2008-12-22 Thread M. Yurko
Alright, below is the original python implementation of the function: def python(x,bits): i = 1 sum_current = RealNumber(x,min_prec=bits) sum_last = 0 term = sum_current add_term = (ln(x)+euler_gamma).n(bits) while sum_current != sum_last: i+=1 term = term*

[sage-support] Re: Arbitrary precision in cython

2008-12-22 Thread Mike Hansen
Hello, On Mon, Dec 22, 2008 at 6:10 AM, M. Yurko wrote: > > Thanks for your help. I tried your first and last suggestions, but > they yielded code that was slower than the original python > implementation. However, I'll take a look at sage.rings.real_mpfr and > try to use mpfr directly. Well, I

[sage-support] Re: Assigning

2008-12-22 Thread Mike Hansen
On Mon, Dec 22, 2008 at 6:12 AM, Timothy Clemans wrote: > > sage: sage0("var('a b c')") > (a, b, c) > sage: sage0("a = b/c") > > b That's not quite right as it creates 'a' in a different session. There are a few variations depending on exactly what you want to do. If you want to assign something

[sage-support] Re: Assigning

2008-12-22 Thread Timothy Clemans
sage: sage0("var('a b c')") (a, b, c) sage: sage0("a = b/c") b - c On Mon, Dec 22, 2008 at 9:03 AM, Georg Muntingh wrote: > > A quick question: If one is given a variable name as a string s, how > can one assign a sy

[sage-support] Re: Arbitrary precision in cython

2008-12-22 Thread M. Yurko
Thanks for your help. I tried your first and last suggestions, but they yielded code that was slower than the original python implementation. However, I'll take a look at sage.rings.real_mpfr and try to use mpfr directly. On Dec 22, 1:44 am, "William Stein" wrote: > On Sun, Dec 21, 2008 at 1:44

[sage-support] Assigning

2008-12-22 Thread Georg Muntingh
A quick question: If one is given a variable name as a string s, how can one assign a symbolic expression to it? Here is what I try that doesn't work: var('a b c') s = "a" eval(s + " = b/c") Traceback (most recent call last): ... a = b/c ^ SyntaxError: invalid syntax --~--~--

[sage-support] Re: Comparing expressions and equations

2008-12-22 Thread Harald Schilly
On Dec 22, 3:26 am, evans wrote: > What I need is something that could take any two of these equations > and tell me if they are equal or not. ... One thing i can think of is to store them in expressions, the left hand sides, and take differences. Then a test if it is zero. (or store the entire

[sage-support] Comparing expressions and equations

2008-12-22 Thread evans
All these are identical (unless there are typos)... x^2 + ((2-y)/3)x + 3 = 0 x^2 + (2/3-y/3)x + 3 = 0 x^2 + (\frac{2}{3}-\frac{y}{3}) x + 3 = 0 x^2 + \frac{(2-y)}{3}x + 3 = 0 x^2 + \frac{(2-y)}{3} * x + 3 = 0 3 + x^2 + \frac{(2-y)}{3}x + 5 = 2 What I need is something that could take any tw