[sage-support] need helps in optimizing speed

2008-11-15 Thread pong
I was a bit reluctant to post this question here since "support" shouldn't mean teaching me how to write programs. But Jason Grout suggested me to post it here anyway. Here is a very short script that I want to maximize the speed def lspec(n): return sorted([k if k^2 < 2*n else 2*n/k for k

[sage-support] Re: question about .extend

2008-11-15 Thread Mike Hansen
> Another puzzling thing is that > b=[ ] > %timeit b.extend([2]) > 100 loops, best of 3: 801 ns per loop > > type(b) > > > but then when I run > > %timeit b+[2] > 10 loops, best of 3: 88.9 ms per loop > > That's much slower, in fact if you simple type b and hit enter... SAGE > hangs. This is

[sage-support] Re: Method of Unknown Coefficients

2008-11-15 Thread Craig Citro
> In trying to utilize the method of unknown coefficients I ended up > with this doozy: > > y=A*Exp(3*t)+B*t*Exp(3*t)+C*t^2*Exp(3*t)+D > > How can I get sage to treat A-D as arbitrary constants when > differentiating. You just have to tell sage to think of them as variables: sage: var('A B C D t

[sage-support] Method of Unknown Coefficients

2008-11-15 Thread Josh
This is just a quick question In trying to utilize the method of unknown coefficients I ended up with this doozy: y=A*Exp(3*t)+B*t*Exp(3*t)+C*t^2*Exp(3*t)+D How can I get sage to treat A-D as arbitrary constants when differentiating. --~--~-~--~~~---~--~~ To post

[sage-support] Re: question about .extend

2008-11-15 Thread Robert Bradshaw
On Nov 15, 2008, at 5:02 PM, pong wrote: > > According to diveintopython .extend should be faster than + since the > former does not return a value. > I was curious and tried > > %timeit [ ]+[2] > 100 loops, best of 3: 741 ns per loop > and > > %timeit [ ].extend([2]) > 100 loops, best of

[sage-support] question about .extend

2008-11-15 Thread pong
According to diveintopython .extend should be faster than + since the former does not return a value. I was curious and tried %timeit [ ]+[2] 100 loops, best of 3: 741 ns per loop and %timeit [ ].extend([2]) 100 loops, best of 3: 870 ns per loop so + actually beats .extend slightly. I

[sage-support] Re: Mathematica 7 coming

2008-11-15 Thread Ondrej Certik
On Sat, Nov 15, 2008 at 1:03 AM, Jason Grout <[EMAIL PROTECTED]> wrote: > > William Stein wrote: >>> * Vector and field visualization >> >> New? I wonder how? It seems like they have had this for a long time. > > There are lots of cool visualations you could do with vector fields that > they don

[sage-support] Re: fast arithmetic

2008-11-15 Thread William Stein
On Sat, Nov 15, 2008 at 10:20 AM, Jason Grout <[EMAIL PROTECTED]> wrote: > > pong wrote: >> >> I have turned some codes that I have from PARI/GP into SAGE script but >> I find that they are order of magnitude slower than the original >> codes. Both types of codes are complied (i.e. I have .run in

[sage-support] Re: fast arithmetic

2008-11-15 Thread Jason Grout
Jason Grout wrote: > pong wrote: >> I have turned some codes that I have from PARI/GP into SAGE script but >> I find that they are order of magnitude slower than the original >> codes. Both types of codes are complied (i.e. I have .run in PARI and >> spyx files for SAGE) and running on the same ma

[sage-support] Re: fast arithmetic

2008-11-15 Thread Jason Grout
pong wrote: > > I have turned some codes that I have from PARI/GP into SAGE script but > I find that they are order of magnitude slower than the original > codes. Both types of codes are complied (i.e. I have .run in PARI and > spyx files for SAGE) and running on the same machine. > > I am sure

[sage-support] fast arithmetic

2008-11-15 Thread pong
I have turned some codes that I have from PARI/GP into SAGE script but I find that they are order of magnitude slower than the original codes. Both types of codes are complied (i.e. I have .run in PARI and spyx files for SAGE) and running on the same machine. I am sure that's because I don't kno