[sage-support] Re: Coding theory:erasures

2010-04-16 Thread Alec Mihailovs
On Apr 15, 8:45 am, Andrea Gobbi andreamat...@gmail.com wrote:
 Hi!
 I'm using sage for coding theory, and it sems to be great! I have a
 linear code like this:
 MS = MatrixSpace(GF(3),10,27)
 G  = MS([
 [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
 [1,2,0,0,0,0,1,1,2,2,0,0,0,0,1,1,2,2,1,1,1,1,2,2,2,2,0],
 [0,0,1,2,0,0,1,2,1,2,1,1,2,2,0,0,0,0,1,1,2,2,1,1,2,2,0],
 [0,0,0,0,1,2,0,0,0,0,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,0],
 [0,0,0,0,0,0,1,2,2,1,0,0,0,0,0,0,0,0,1,1,2,2,2,2,1,1,0],
 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,2,1,1,2,1,2,2,1,2,1,0],
 [0,0,0,0,0,0,0,0,0,0,1,2,2,1,0,0,0,0,1,2,2,1,1,2,2,1,0],
 [1,1,0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0],
 [0,0,1,1,0,0,1,1,1,1,1,1,1,1,0,0,0,0,1,1,1,1,1,1,1,1,0],
 [0,0,0,0,1,1,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0]]);
 C  = LinearCode(G);
 C.dimension();
 C.length();
 C.minimum_distance();
 C.weight_distribution();
 And I want use the minimum distance (in this case 9) for correct a
 vector with 8 erasures. There are some tools in sage to do this? I try

If the minimum distance is 9, then, I think, only vectors with 4
erasures or less can be decoded correctly. Consider, for example, the
last row with 5 zeros replaced with ones - if 5 erasures were allowed,
then erasing them, we would get the last row, but erasing 4 remaining
zeros in it instead, we would get the first row - so it couldn't be
uniquely decoded.

Alec

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Re: Coding theory:erasures

2010-04-16 Thread Alec Mihailovs
On Apr 16, 10:34 am, David Joyner wdjoy...@gmail.com wrote:

 I think you meant to say If the minimum distance is 9, then, I think,
 only vectors with 4
 errors or less can be decoded correctly. I think erasures (where the
 error positions are assumed to be known) are more complicated.
 In the example of the last row, if you erase the first 8 0's then
 the question is are there any other codewords which have
 the same bits in the non-erased positions.

Yes, I meant errors. I didn't even think about the situation where the
positions are known. In this case, the decoding seems to be rather
simple - find 10 other columns with non-zero determinant of the matrix
constructed from them, and use the inverse of this matrix for
decoding.

Alec

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Re: Coding theory:erasures

2010-04-16 Thread Alec Mihailovs
On Apr 16, 1:39 pm, Alec Mihailovs alec.mihail...@gmail.com wrote:

 simple - find 10 other columns with non-zero determinant of the matrix
 constructed from them, and use the inverse of this matrix for
 decoding.

Or even more simple -if A is the matrix consisting of all non-erased
columns, use A.transpose()*(A*A.transpose()).inverse() for decoding,
applying it to the non-erased part.

Alec

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Re: Coding theory:erasures

2010-04-16 Thread Alec Mihailovs
On Apr 16, 1:50 pm, Alec Mihailovs alec.mihail...@gmail.com wrote:

 Or even more simple -if A is the matrix consisting of all non-erased
 columns, use A.transpose()*(A*A.transpose()).inverse() for decoding,
 applying it to the non-erased part.

And if A*A.transpose() is singular, the same thing, probably, could be
done with the matrix, obtained from A by removing a column, but I'm
not sure - there may be, perhaps, cases, when removing more than 1
column is necessary - that would make the procedure more complicated
(in the worst cases.)

Alec

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Re: Coding theory:erasures

2010-04-16 Thread Alec Mihailovs
On Apr 15, 8:45 am, Andrea Gobbi andreamat...@gmail.com wrote:
 Hi!
 I'm using sage for coding theory, and it sems to be great! I have a
 linear code like this:
 MS = MatrixSpace(GF(3),10,27)
 G  = MS([
 [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
 [1,2,0,0,0,0,1,1,2,2,0,0,0,0,1,1,2,2,1,1,1,1,2,2,2,2,0],
 [0,0,1,2,0,0,1,2,1,2,1,1,2,2,0,0,0,0,1,1,2,2,1,1,2,2,0],
 [0,0,0,0,1,2,0,0,0,0,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,0],
 [0,0,0,0,0,0,1,2,2,1,0,0,0,0,0,0,0,0,1,1,2,2,2,2,1,1,0],
 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,2,1,1,2,1,2,2,1,2,1,0],
 [0,0,0,0,0,0,0,0,0,0,1,2,2,1,0,0,0,0,1,2,2,1,1,2,2,1,0],
 [1,1,0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0],
 [0,0,1,1,0,0,1,1,1,1,1,1,1,1,0,0,0,0,1,1,1,1,1,1,1,1,0],
 [0,0,0,0,1,1,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0]]);
 C  = LinearCode(G);
 C.dimension();
 C.length();
 C.minimum_distance();
 C.weight_distribution();
 And I want use the minimum distance (in this case 9) for correct a
 vector with 8 erasures. There are some tools in sage to do this? I try
 to look to the reference manual but seems that the decoding part is
 not implemented...
  Or someone created a soubrutine that can be used for this problem?
 Sorry for my english,
 Thanks!

The following seems to be working,

def decode(w,erasures=[],num_tries=10):
pos=[i for i in range(27) if not i in erasures]
G1=G.matrix_from_columns(pos)
if G1.rank()!=10:
print Too many erasures
return None
else:
MH=MatrixSpace(GF(3),G1.ncols(),10)
for i in range(num_tries):
R=MH.random_element()
H=G1*R
if H.rank()==10:
break
return vector(GF(3),w.list_from_positions(pos))*R*H.inverse()

For example,

m=V.random_element(); m

(2, 1, 0, 0, 1, 2, 0, 1, 0, 0)

w=m*G; w
(1, 2, 2, 2, 2, 2, 2, 0, 1, 0, 2, 2, 2, 2, 0, 2, 0, 1, 1, 0,
2, 1, 2, 0,
1, 2, 2)

decode(w)

   (2, 1, 0, 0, 1, 2, 0, 1, 0, 0)

decode(w, range(8))

(2, 1, 0, 0, 1, 2, 0, 1, 0, 0)

decode(w,range(15))

Too many erasures

Alec Mihailovs



-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Re: Coding theory:erasures

2010-04-16 Thread Alec Mihailovs
On Apr 16, 4:16 pm, Alec Mihailovs alec.mihail...@gmail.com wrote:
 For example,

 m=V.random_element(); m

                 (2, 1, 0, 0, 1, 2, 0, 1, 0, 0)

It should be

V=VectorSpace(GF(3),10)

before that.

Alec

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Re: Vector solutions, a basic question.

2010-04-16 Thread Alec Mihailovs
On Apr 16, 4:01 pm, Alexander Shyrokov sjc...@gmail.com wrote:
 I have derived the equation, which looks like this:
 ((T - (E -T) *(H.dot(N) - T.dot(N))/(E - T).dot(N) - H) / S) ==  Mp

I'll take a look at it later. But in general, if you have a system of
linear equations, you can write it in a matrix form

A*x=b

in which case the solution can be obtained as

x=A.inverse()*b

That should work better than solve.

Alec

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Re: Coding theory:erasures

2010-04-16 Thread Alec Mihailovs
On Apr 16, 5:05 pm, David Joyner wdjoy...@gmail.com wrote:

 Do you mean A is the matrix of all n^k codewords, but you remove the
 columns corresponding to the erasure positions? I don't know what you
 mean by A.

I meant the submatrix of G - I used something like that in the decode
procedure in another post, just replacing A.transpose() with a random
matrix.

I looked at the C.decode (for C in the original post), and it does
something different - it corrects the errors. Perhaps, the better name
for it would be C.correct ?

Also, perhaps, just simple linsolve can be used (in my decode) if it
exists in Sage and works for overdetermined systems of linear
equations.

Alec

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Re: Coding theory:erasures

2010-04-16 Thread Alec Mihailovs
On Apr 16, 5:28 pm, Alec Mihailovs alec.mihail...@gmail.com wrote:

 Also, perhaps, just simple linsolve can be used (in my decode) if it
 exists in Sage and works for overdetermined systems of linear
 equations.

Yes, I found it - it is called solve_left, and it can be used as
follows,

def decode1(w,erasures=[]):
pos=[i for i in range(27) if not i in erasures]
G1=G.matrix_from_columns(pos)
if G1.rank()!=10:
print Too many erasures
return None
else:
return
G1.solve_left(vector(GF(3),w.list_from_positions(pos)))

However, it is slower than decode,

timeit('decode(w)')
 125 loops, best of 3: 3.87 ms per loop
timeit('decode1(w)')
125 loops, best of 3: 6.98 ms per loop

Alec



-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Re: Coding theory:erasures

2010-04-16 Thread Alec Mihailovs
On Apr 16, 5:28 pm, Alec Mihailovs alec.mihail...@gmail.com wrote:

 I looked at the C.decode (for C in the original post), and it does
 something different - it corrects the errors. Perhaps, the better name
 for it would be C.correct ?

If that is needed, that could be done as

def correct(w,erasures=[],num_tries=10):
return decode(w,erasures,num_tries)*G

For example,

er=vector(GF(3),
[1,2,1,0,2,1,2,0,0,0,2,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])

correct(w+er,[0,1,2,4,5,6,10,11])-w

(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0)

Alec


-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Re: Coding theory:erasures

2010-04-16 Thread Alec Mihailovs
On Apr 16, 8:10 pm, David Joyner wdjoy...@gmail.com wrote:
 Perhaps I don't understand your program, but it appears to not address
 the issue. Here is the algorithm, if I understand the question correctly:

 Let I denote the subset of range(n) which represents the erasures.
 Let v denote the vector in GF(q)^n which you want to decode.
 Let C denote the [n,k,d] code with generator matrix G (so the
 rows of G are a basis for the vector space C over GF(q)).
 For each w in GF(q)^n, let w^I denote those coordinates of w not in I.
 Let L = [] be an empty list.
 For each c in C
   if c^I = v^I then append c to L
 return L

 This gives you the list of codewords desired.

 I don't see how the output of your programs agree with this.

I may be understanding the problem wrong. Originally I thought that
the problem was as follows (in this example): given a message m in
GF(3)^10, we used matrix G to encode it making a vector w in GF(3)^27.
During a transmission, there were 8 or so errors in known positions
(erasures is the list of these positions in my code).
Assuming that we still can restore the original message m, i.e. if it
is unique, the procedure 'decode' gives it from w and the list of the
positions of erasures, and the procedure 'correct' produces the
correct codeword corresponding to it.

Maybe, I still don't understand it right, but it seems as if you are
saying, that the problem is to do a similar thing in cases when the
solution is not unique, producing the list of all the solutions. That
can be done similarly, just using the version of solve_left in
'decode1' producing the list of all solutions (plain solve_left gives
only one solution even if there is more than 1), and then multiplying
each of them by G, as in 'correct',

If I again understood it wrong, could you, please, give a simple
example (with smaller sizes), with the correct answer?

Alec

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Re: Coding theory:erasures

2010-04-16 Thread Alec Mihailovs
On Apr 16, 8:55 pm, Alec Mihailovs alec.mihail...@gmail.com wrote:

 Maybe, I still don't understand it right, but it seems as if you are
 saying, that the problem is to do a similar thing in cases when the
 solution is not unique, producing the list of all the solutions. That
 can be done similarly, just using the version of solve_left in
 'decode1' producing the list of all solutions (plain solve_left gives
 only one solution even if there is more than 1), and then multiplying
 each of them by G, as in 'correct',

Here are the procedures for that -

def decode3(w,erasures=[]):
pos=[i for i in range(27) if not i in erasures]
G1=G.matrix_from_columns(pos)
return
G1.solve_left(vector(GF(3),w.list_from_positions(pos))),G1.kernel().basis_matrix()

def correct1(w,erasures=[],listed=False):
ans=decode3(w,erasures)
ans0,ans1=ans[0]*G,ans[1]*G
if not listed:
return ans0,ans1
else:
return [ans0+c*ans1 for c in VectorSpace(GF(3),ans1.nrows())]

For example,

V=VectorSpace(GF(3),10)
m=V.random_element(); m
(2, 1, 1, 0, 0, 0, 0, 1, 1, 0)
w=m*G; w
(1, 2, 1, 2, 2, 2, 0, 1, 1, 2, 1, 1, 2, 2, 1, 1, 2, 2, 0, 0,
1, 1, 1, 1, 2, 2, 2)
correct1(w,range(14),True)

[(1, 2, 1, 2, 2, 2, 0, 1, 1, 2, 1, 1, 2, 2, 1, 1, 2, 2, 0, 0, 1, 1, 1,
1, 2, 2, 2), (2, 0, 1, 2, 1, 1, 1, 2, 2, 0, 0, 0, 1, 1, 1, 1, 2, 2, 0,
0, 1, 1, 1, 1, 2, 2, 2), (0, 1, 1, 2, 0, 0, 2, 0, 0, 1, 2, 2, 0, 0, 1,
1, 2, 2, 0, 0, 1, 1, 1, 1, 2, 2, 2)]

correct1(w,range(14))

((1, 2, 1, 2, 2, 2, 0, 1, 1, 2, 1, 1, 2, 2, 1, 1, 2, 2, 0, 0, 1, 1, 1,
1, 2, 2, 2), [1 1 0 0 2 2 1 1 1 1 2 2 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0])

correct1(w,[],True)

[(1, 2, 1, 2, 2, 2, 0, 1, 1, 2, 1, 1, 2, 2, 1, 1, 2, 2, 0, 0, 1, 1, 1,
1, 2, 2, 2)]

Alec











-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Re: Coding theory:erasures

2010-04-16 Thread Alec Mihailovs
On Apr 16, 9:48 pm, David Joyner wdjoy...@gmail.com wrote:
 Sorry Alec, maybe there is a language problem here.

Sorry, David, but there may be also a cultural problem as well. You,
obviously, think that, being a moderator of sage-edu, you could reject
your colleagues posts there, as you rejected my post there several
days ago, just by announcing about that in sage-devel, instead of
emailing me personally, as it is normally done. I consider such your
behavior as being unethical. If there is some Sage ethical committee,
I would like to submit that there.

Please feel free to reply to that in sage-flame if you have something
to say about that.

Alec Mihailovs, PhD (from University of Pennsylvania),
teaching math for more than 30 years.

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Re: Vector solutions, a basic question.

2010-04-15 Thread Alec Mihailovs
For example, let the plane's equation is 2*x+3*y+4*z=5, and the line
is given as x,y,z=t-1,2*t-3,2-t. Then the point of their
intersection can be found in Sage as follows,

var('t');
x,y,z=t-1,2*t-3,2-t
plane=2*x+3*y+4*z-5
a=solve(plane,t)[0]
[i.subs(a) for i in x,y,z]

[1, 1, 0]

Alec

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Re: Degree 120 splitting field

2010-04-14 Thread Alec Mihailovs
On Apr 14, 2:08 pm, Rob Beezer goo...@beezer.cotse.net wrote:

 Rinse, repeat.  First iteration is below.  By the time I get to degree
 3 the factorizations are taking about 8 hours.  My question: is there
 a more efficient way to do this?

Divisions are faster than the factorization - divide by (x-a), then by
(x-b), then by (x-c). Now, the last step takes a long time, but it is
not actually necessary - the polynomial is x^2 + (c + b + a)*x + c^2 +
(b + a)*c + b^2 + a*b + a^2, so dividing it by (x-d), we get (x+a+b+c
+d).

Alec

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

To unsubscribe, reply using remove me as the subject.


[sage-support] Re: Yamanouchi words

2010-04-14 Thread Alec Mihailovs
On Apr 14, 12:47 am, Drini pdsanc...@gmail.com wrote:
 I'm confused 
 abouthttp://www.sagemath.org/doc/reference/sage/combinat/yamanouchi.html
 it's documentation for 4.3.5 but it's been the same since 4.3.1

 Is there a class?
 functions?
 or is it just a random note about those words?

The file devel/sage/sage/combinat/yamanouchi.py contains only that
documentation string - nothing else. No classes or functions.

Alec

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

To unsubscribe, reply using remove me as the subject.


[sage-support] Re: multidimensional numerical integration

2010-04-12 Thread Alec Mihailovs
On Apr 12, 8:43 am, karl karl.landstei...@linuxmail.org wrote:

 integrate(  f(x,y) , x,xmin, xmax,y, ymin, ymax) numerically.

One can use dblquad from scipy. For example,

from scipy.integrate import dblquad
dblquad(lambda y,x:x+2*y, 1, 2, lambda x:1-x, lambda x:1+x)
(10.666, 1.1842378929335001e-13)

Check it,

integral(integral(x+2*y,y,1-x,1+x),x,1,2)

32/3

Alec Mihailovs











-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

To unsubscribe, reply using remove me as the subject.


[sage-support] Re: problems with sage and brian simulator

2010-04-12 Thread Alec Mihailovs
On Apr 12, 5:30 am, Uri oriol.caste...@gmail.com wrote:
 I found another way to solve that problem (which seems more practical
 to me). You just have to redefine RealNumber and Integer:

 RealNumber=float
 Integer=int

You could also disable units - i.e. start brian as

import brian_no_units
from brian import *

Then

1*mV
0.001

Alec

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

To unsubscribe, reply using remove me as the subject.


[sage-support] Re: problems with sage and brian simulator

2010-04-12 Thread Alec Mihailovs
On Apr 12, 3:30 pm, Alec Mihailovs alec.mihail...@gmail.com wrote:

 import brian_no_units
 from brian import *

Also, the show command should be replaced with savefig - something
like in the following example,

from matplotlib.pyplot import savefig
eqs = '''
dv/dt = (ge+gi-(v+49*mV))/(20*ms) : volt
dge/dt = -ge/(5*ms) : volt
dgi/dt = -gi/(10*ms) : volt
'''
P = NeuronGroup(4000, eqs, threshold=-50*mV, reset=-60*mV)
P.v = -60*mV+10*mV*rand(len(P))
Pe = P.subgroup(3200)
Pi = P.subgroup(800)
Ce = Connection(Pe, P, 'ge', weight=1.62*mV, sparseness=0.02)
Ci = Connection(Pi, P, 'gi', weight=-9*mV, sparseness=0.02)
M = SpikeMonitor(P)
run(1*second)
raster_plot(M)
savefig('sage1.png')

Alec

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

To unsubscribe, reply using remove me as the subject.


[sage-support] Re: problems with sage and brian simulator

2010-04-12 Thread Alec Mihailovs
By the way, the easy way to install brian package in Sage from the
notebook is to execute the following cell,

%sh
easy_install brian

Then save  quit the worksheet and open it again.

Alec

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

To unsubscribe, reply using remove me as the subject.


[sage-support] Re: problems with sage and brian simulator

2010-04-12 Thread Alec Mihailovs
On Apr 12, 4:32 pm, William Stein wst...@gmail.com wrote:

 You can also just do

 Action - Restart Worksheet

Thank you!

Alec

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

To unsubscribe, reply using remove me as the subject.


[sage-support] Re: problems with sage and brian simulator

2010-04-12 Thread Alec Mihailovs
On Apr 12, 4:03 pm, Alec Mihailovs alec.mihail...@gmail.com wrote:

 Also, the show command should be replaced with savefig - something
 like in the following example,

That could be also done without changing the examples on the brian's
webpage, by redefining show() as

def show():
from matplotlib.pyplot import savefig
return savefig('sage0.png')

Alec

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

To unsubscribe, reply using remove me as the subject.


[sage-support] Re: Problems to susbstitute a function

2010-04-12 Thread Alec Mihailovs
On Apr 12, 5:57 pm, Eckhard Kosin e...@mathematik-service-kosin.de
wrote:

 I think I understand:  After

 expr(x) = sin(x)

 expr is a symbolic expression and can be differentiated and the same
 goes for sin after

 sin(x) = sin(x)

Yes. And the same thing can be done for other functions. In
particular, in your example with h2,

sage: function('f')
sage: h2 = lambda t: sin(f(t))
sage: h2(x)=h2(x)
sage: h2.diff()
x |-- cos(f(x))*D[0](f)(x)

Alec




-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

To unsubscribe, reply using remove me as the subject.


[sage-support] Re: Question about numerical linear algebra.

2010-04-11 Thread Alec Mihailovs
On Apr 11, 1:22 pm, Thierry Dumont tdum...@math.univ-lyon1.fr wrote:
   In the preceding examples, if you compare as given by U,Sig,V=A.SVD()
 and U given by U,s,Vh=svd(A) they are transposed :-(

U is the same, Sig is a diagonal matrix with diagonal entries being
elements of vector s, and V is Hermitian transposed to Vh, as it
supposed to be according to the help pages - it should be
U*Sig*V.conjugate().transpose() == A

Alec

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

To unsubscribe, reply using remove me as the subject.


[sage-support] Re: (1 - i) == -(i + 1) ??

2010-04-11 Thread Alec Mihailovs
On Apr 11, 4:51 pm, Mike Witt msg...@gmail.com wrote:
 [m...@vector ~]$ sage
 --
 | Sage Version 4.3.1, Release Date: 2010-01-20                       |
 | Type notebook() for the GUI, and license() for information.        |
 --
 sage: (1-I)/(sqrt(2)-1)
 -(I + 1)/(sqrt(2) - 1)

In Sage 4.3.4 (in Windows) that I am using,

(1-I)/(sqrt(2)-1)
(-I + 1)/(sqrt(2) - 1)

Alec

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

To unsubscribe, reply using remove me as the subject.


[sage-support] Re: Question about numerical linear algebra.

2010-04-11 Thread Alec Mihailovs
On Apr 11, 1:22 pm, Thierry Dumont tdum...@math.univ-lyon1.fr wrote:

   -Qusetion: is there some dictionary, some documentation about how
 the scipy functions are mapped to sage? and what can be directly used?

What can be used can be seen by typing A. and hitting Tab key. The
documentation for every method is available by entering A.(name of the
method)? , for example, A.SVD? and Tab, and the source is available as
A.SVD?? and then Tab.

Alec

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

To unsubscribe, reply using remove me as the subject.


[sage-support] Re: Problems to susbstitute a function

2010-04-10 Thread Alec Mihailovs
On Apr 10, 10:37 am, Eckhard Kosin e...@mathematik-service-kosin.de
wrote:

 I tried to understand my mistake and I realised that I have difficulties
 to distinguish between symbolic expressions and functions and when to
 use either.

The general rule is that it is better to use expressions if possible
instead of functions. That, in particular, saves on typing - one can
type, say, r instead of r(x).

 sage: f = function('f')

That is the same as if you just typed

function('f')

It is the best declaration of a function, because after that you can
use it as f(x), f(t), f(a+b*x, c+d*t) etc.

 sage: g = function('g', x)
 sage: type(g)
 type 'sage.symbolic.expression.Expression'

Writing g=function('g'', x), the right hand side is already not a
function - it is an expression g(x), and that line assigns g to that
expression. If you type g after that, it will produce g(x).

 sage: type(g(x))
 type 'sage.symbolic.expression.Expression'

What happens here is that g is already an expression g(x), and g(x)
substitutes x in that expression instead of x, which is deprecated,
but produces the same result.

 sage: h1 = sin(f(x))
 sage: type(h1)
 type 'sage.symbolic.expression.Expression'
 sage: h2 = lambda t: sin(f(t))
 sage: type(h2)
 type 'function'
 sage: h1.diff(x)
 cos(f(x))*D[0](f)(x)
 sage: h2.diff(x)
 ---
 AttributeError                            Traceback (most recent call
 last)

h2 is a function, but not a symbolic function. Symbolic functions can
be differentiated using diff, but usual function can't. It can be done
by producing an expression first, and then differentiating,

h2(x).diff()
cos(f(x))*D[0](f)(x)

h2(x).diff() if the same as h2(x).diff(x) - if there is only one
variable in the expression, it doesn't have to be mentioned in the
diff call.

 What's the difference between f and g?  Why can I differentiate a
 symbolic expression, but not a function?  As a mathematician I expected
 the other way :-(

Functions also can be differentiated - if they are symbolic - in
particular, the functions defined using the following syntax,

h3(x)=sin(f(x))
h3
x |-- sin(f(x))
h3.diff()
x |-- cos(f(x))*D[0](f)(x)

 The tutorial states that S(x) = sin(x) defines a
 callable symbolic expression.  But I get

 sage: S(x) = sin(x)
 sage: type(S)
 type 'sage.symbolic.expression.Expression'
 sage: type(S(x))
 type 'sage.symbolic.expression.Expression'

 Is there a difference between a callable symbolic expression and a
 symbolic expression?  

The difference can be seen using 'callable',

callable(S)
True

 Why can I type

 sage: S.diff()
 x |-- cos(x)

 but

 sage: sin.diff()
 ---
 AttributeError ...

Because S is a symbolic function, and sin is not.

type(sin)
   class 'sage.functions.trig.Function_sin'

The word 'symbolic' is missing. That, perhaps, can be considered as a
bug, or as a suggestion - make sin symbolic.

Alec Mihailovs

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

To unsubscribe, reply using remove me as the subject.


[sage-support] Re: Arrangements().list() nice format

2010-04-10 Thread Alec Mihailovs
For example,

sage: set=['adam', 'eva', 'otto', 'emil']
sage: a=Arrangements(set,4)
sage: for x in range(0,a.cardinality(),2): print a[x],a[x+1]
:
['adam', 'eva', 'otto', 'emil'] ['adam', 'eva', 'emil', 'otto']
['adam', 'otto', 'eva', 'emil'] ['adam', 'otto', 'emil', 'eva']
['adam', 'emil', 'eva', 'otto'] ['adam', 'emil', 'otto', 'eva']
['eva', 'adam', 'otto', 'emil'] ['eva', 'adam', 'emil', 'otto']
['eva', 'otto', 'adam', 'emil'] ['eva', 'otto', 'emil', 'adam']
['eva', 'emil', 'adam', 'otto'] ['eva', 'emil', 'otto', 'adam']
['otto', 'adam', 'eva', 'emil'] ['otto', 'adam', 'emil', 'eva']
['otto', 'eva', 'adam', 'emil'] ['otto', 'eva', 'emil', 'adam']
['otto', 'emil', 'adam', 'eva'] ['otto', 'emil', 'eva', 'adam']
['emil', 'adam', 'eva', 'otto'] ['emil', 'adam', 'otto', 'eva']
['emil', 'eva', 'adam', 'otto'] ['emil', 'eva', 'otto', 'adam']
['emil', 'otto', 'adam', 'eva'] ['emil', 'otto', 'eva', 'adam']

Alec

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

To unsubscribe, reply using remove me as the subject.


[sage-support] Re: Gap packages

2010-04-10 Thread Alec Mihailovs
On Apr 10, 9:06 am, Stochastix laurent.decreusef...@gmail.com wrote:
 I downloaded and installed sage 4.3.5 on my MacBook Pro. Everything
 went like a charm. I'm interested in using the simplicial homology GAP
 packages available at

 http://www.cis.udel.edu/~dumas/Homology/

 It doesn't seem to be in the optional GAP packages available for SAGE.
 Can I install it directly in SAGE or should I have a stand-alone
 installation of GAP ?

I just installed it in my Cygwin's Sage as follows - downloaded the
binary package for cygwin from the link you gave, put it in sage's
local/lib/gap-4.4.12 folder, extracted it:

$ cd sage-4.3.4*/local/lib/gap*
$ tar xvzf homology*

then in Sage's notebook (in Firefox),

gap.RequirePackage('homology')
true

complex=gap([[1,2],[2,3],[3,4],[4,5],[1,5]])

complex.SimplicialHomology()
[ [ 0 ], [ 1 ] ]

gap(SimplicialHomology(SCNot2ConnectedGraphs(7),9))
[ [ 120 ] ]

Seems to be working OK.

Alec Mihailovs




-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

To unsubscribe, reply using remove me as the subject.


[sage-support] Re: Arrangements().list() nice format

2010-04-10 Thread Alec Mihailovs
Another way,

sage: set=['adam', 'eva', 'otto', 'emil']
sage: a=Arrangements(set,4).list()
sage: for i in zip(a[0:-1:2],a[1:-1:2]): i
:
(['adam', 'eva', 'otto', 'emil'], ['adam', 'eva', 'emil', 'otto'])
(['adam', 'otto', 'eva', 'emil'], ['adam', 'otto', 'emil', 'eva'])
(['adam', 'emil', 'eva', 'otto'], ['adam', 'emil', 'otto', 'eva'])
(['eva', 'adam', 'otto', 'emil'], ['eva', 'adam', 'emil', 'otto'])
(['eva', 'otto', 'adam', 'emil'], ['eva', 'otto', 'emil', 'adam'])
(['eva', 'emil', 'adam', 'otto'], ['eva', 'emil', 'otto', 'adam'])
(['otto', 'adam', 'eva', 'emil'], ['otto', 'adam', 'emil', 'eva'])
(['otto', 'eva', 'adam', 'emil'], ['otto', 'eva', 'emil', 'adam'])
(['otto', 'emil', 'adam', 'eva'], ['otto', 'emil', 'eva', 'adam'])
(['emil', 'adam', 'eva', 'otto'], ['emil', 'adam', 'otto', 'eva'])
(['emil', 'eva', 'adam', 'otto'], ['emil', 'eva', 'otto', 'adam'])

Alec

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

To unsubscribe, reply using remove me as the subject.


[sage-support] Re: Problems to susbstitute a function

2010-04-10 Thread Alec Mihailovs
On Apr 10, 10:37 am, Eckhard Kosin e...@mathematik-service-kosin.de
wrote:

 sage: sin.diff()
 ---
 AttributeError ...

There is an interesting way to fix that,

sin(x)=sin(x)
sin.diff()
x |-- cos(x)

Alec

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

To unsubscribe, reply using remove me as the subject.


[sage-support] Re: points on elliptic curves mod N

2010-04-10 Thread Alec Mihailovs
On Apr 10, 8:27 pm, Robert Bradshaw rober...@math.washington.edu
wrote:
 This particular point however seems to have order 3 on both E(GF(67))  
 and E(GF(89)).

E=EllipticCurve([1,R(1)])

seems to be working,

7*E([0,1])

Traceback (click to the left of this block for traceback)
...
ZeroDivisionError: Inverse of 5092 does not exist

Alec

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

To unsubscribe, reply using remove me as the subject.


[sage-support] Re: Problems to susbstitute a function

2010-04-09 Thread Alec Mihailovs
For example,

var('t R_u c')
map(function,('R_b', 'psi', 'm_z'))
r = R_b(t)*sin(psi(t))
z = R_b(t)*cos(psi(t))+m_z(t)
Dr, Dz = r.diff(t), z.diff(t)
v=vector([Dr,Dz]) * vector([cos(psi(t)),sin(psi(t))])
w=v.simplify_trig()
w.substitute_function(m_z,lambda t:-sqrt(R_b(t)^2-R_u^2))

2*sin(psi(t))*cos(psi(t))*D[0](R_b)(t) -
sin(psi(t))*R_b(t)*D[0](R_b)(t)/sqrt(-R_u^2 + R_b(t)^2) -
(2*sin(psi(t))^2*R_b(t) - R_b(t))*D[0](psi)(t)

Alec Mihailovs

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

To unsubscribe, reply using remove me as the subject.


[sage-support] Re: Inverses of Large Sparse Matrices

2010-04-09 Thread Alec Mihailovs
On Apr 9, 1:53 pm, Leo Maloney leo.b.malo...@gmail.com wrote:
 I'm trying to compute the inverse of a 5000 x 5000 sparse matrix.  I'm
 getting an EOF error after it runs for about 5 hours, and then it
 states that sage is trying to access unallocated memory.  Is there a
 way I can increase the memory for this computation?  Every time I
 Google it, all I can find is the benefits sage(plant) has on memory.

As other people commented, that should be faster if the original
matrix was dense.

In general, it is possible to write a procedure for inverting a
matrix, writing the answer on the disk incrementally, appending it to
a file - that may be slower, but removes the restriction on the RAM
size (but one would need to have enough space on the hard drive
instead) - I am not volunteering though.

Alec

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

To unsubscribe, reply using remove me as the subject.


[sage-support] Re: Inverses of Large Sparse Matrices

2010-04-09 Thread Alec Mihailovs
On Apr 9, 8:59 pm, William Stein wst...@gmail.com wrote:

 A 5000x5000 matrix just isn't really that big, IMHO...

That's true - should work in just few seconds - I meant REALLY big
matrices - actually, sometimes such a thing should work faster even
for not that big matrices - in case if the virtual memory located on
disk is used - it is faster to write on disk directly.

Alec

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Re: Inverses of Large Sparse Matrices

2010-04-09 Thread Alec Mihailovs
On Apr 9, 8:59 pm, William Stein wst...@gmail.com wrote:

 A 5000x5000 matrix just isn't really that big, IMHO...

Actially, thinking about that, who knows what size its elements could
be, if they are rational... They may be really big.

Alec

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

To unsubscribe, reply using remove me as the subject.


[sage-support] Re: Eigenvectors of a matrix

2010-04-09 Thread Alec Mihailovs
For M, you could do something like

M=matrix([[1,1+i],[1-i,-1]])/sqrt(3)
html.table(maxima(M).eigenvectors().sage())

or

html.table([[r,(M-matrix(2,2,r)).right_kernel().basis_matrix()] for r
in M.eigenvalues()])

And numerically the eigenvectors could be found as

matrix(M.numpy(dtype=complex)).eigenvectors_right()

Alec

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

To unsubscribe, reply using remove me as the subject.


[sage-support] Re: Invoking Lisp from within Sage

2010-04-09 Thread Alec Mihailovs

On Apr 10, 1:32 am, Adam Getchell adam.getch...@gmail.com wrote:
 Hi all,

 I realize this maybe a bit of an insane question, but I'm looking for a way
 to use ecl within sage besides:

 ./sage -ecl

For example,

lisp((def x 1)(defun f (x)(+ x 1))(f 2))
3

Alec Mihailovs

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

To unsubscribe, reply using remove me as the subject.


[sage-support] Re: standard deviations in sage

2010-04-07 Thread Alec Mihailovs
On Apr 7, 12:56 pm, Marshall Hampton hampto...@gmail.com wrote:

 with RDF!  I think this is because many operations over RDF get sent
 to numpy and scipy, and the conversions aren't defined for RR.  This
 seems like a bug to me.

By the way, % also doesn't work with 2 RDFnumbers

sage: RDF(3)%RDF(5)

Traceback (click to the left of this block for traceback)
...
TypeError: unsupported operand type(s) for %:
'sage.rings.real_double.RealDoubleElement' and
'sage.rings.real_double.RealDoubleElement'

Alec

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

To unsubscribe, reply using remove me as the subject.


[sage-support] Re: Difference between sage and pyhton calculations

2010-04-06 Thread Alec Mihailovs

On Apr 5, 11:56 pm, Eugene Goldberg omegat...@gmail.com wrote:

 Python 2.6.5 (r265:79063, Mar 23 2010, 04:49:54)
  6e-6 % 10e-6

 6.0002e-06

 Sage Version 4.3.5, Release Date: 2010-03-28
 sage: 6e-6 % 10e-6
 -4.00e-6

 I'm sure sage is wrong.. :(

As William Stein said, Sage is not wrong - it just uses a differed
definition of %. If one wants to have the same answer as Python does
(always nonnegative), then function math.fmod can be used. For
example,

sage: from math import fmod
sage: fmod(6e-6,10e-6)
6.0002e-06

Or use Python floats,

sage: float(6e-6) % float(10e-6)
6.0002e-06

In both cases the result is a Python float. To make it a Sage's real
number, one can use RR,

sage: RR(_)
6.00e-6

Alec Mihailovs

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

To unsubscribe, reply using remove me as the subject.


[sage-support] Re: Difference between sage and pyhton calculations

2010-04-06 Thread Alec Mihailovs
On Apr 6, 2:00 am, Robert Bradshaw rober...@math.washington.edu
wrote:

 I would be in favor of following Python's conventions here--they at  
 least seem more natural to me (after all, % is related to floor  
 division not round division. :)

Also, currently 2==2., 3==3., but 2%3 is 2 and 2.%3. is
-1.00,
also 2%3. is 2 and 2.%3 is -1.00.

Alec

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Re: Can't solve equation with square roots...

2010-04-06 Thread Alec Mihailovs
On Apr 6, 9:09 am, Danread5 danre...@me.com wrote:

 sage: d = sqrt(x^2 + 5^2)
 sage: D = sqrt((20-x)^2 + 10^2)
 sage: T = d + D; T
 sqrt(x^2 + 25) + sqrt((x - 20)^2 + 100)
 sage: diff(T, x)
 (x - 20)/sqrt((x - 20)^2 + 100) + x/sqrt(x^2 + 25)
 sage: solve((x - 20)/sqrt((x - 20)^2 + 100) + x/sqrt(x^2 + 25) == 0,
 x)
 [x == 20*sqrt(x^2 + 25)/(sqrt(x^2 + 25) + sqrt(x^2 - 40*x + 500))]

 For some reason, Sage isn't solving completely for x, or isn't
 'seeing' the x^2...

 Any help gladly appreciated!

This problem can be easily solved mentally -

Find the point on the x-axis, the sum of distances of which to (0, 5)
and (20, -10) is minimal.

Of course, it is the point of intersection of the line connecting
these points and the x-axis.

Now, it is obvious from the picture including also vertical lines at
x=0 and x =20, that the 2 triangles are similar. The left triangle has
height 5, and the right one has hight 10, twice greater, so their
sides on the x-axis also have the same ratio, 1:2, i.e. the length of
the horizontal side of the left triangle is 1/3 of the distance from 0
to 20, i.e. 20/3.

Alec

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Re: derivative instance

2010-04-05 Thread Alec Mihailovs
A: Yes.
 Q: Are you sure?
 A: Because it reverses the logical flow of conversation.
 Q: Why is top posting annoying in email?

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

To unsubscribe, reply using remove me as the subject.


[sage-support] Re: nested for statements?

2010-04-05 Thread Alec Mihailovs
On Apr 5, 4:48 pm, Harald Schilly harald.schi...@gmail.com wrote:

 you can also format it as an html table, read the output of
 html.table? for more information ;)

That can be done as

U=Integers(40)
u=filter(lambda n: gcd(n,40)==1, U)
r=range(1,len(u))
html.table([r]+[map(lambda j: k^j, r) for k in u], header=True)

Alec

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

To unsubscribe, reply using remove me as the subject.


[sage-support] Re: nested for statements?

2010-04-05 Thread Alec Mihailovs
On Apr 5, 5:11 pm, Alec Mihailovs alec.mihail...@gmail.com wrote:

 html.table([r]+[map(lambda j: k^j, r) for k in u], header=True)

Or even more simple,

html.table([r]+[[k^j for j in r] for k in u],header=True)

Alec

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

To unsubscribe, reply using remove me as the subject.


[sage-support] Re: nested for statements?

2010-04-05 Thread Alec Mihailovs
On Apr 5, 5:11 pm, Alec Mihailovs alec.mihail...@gmail.com wrote:

 u=filter(lambda n: gcd(n,40)==1, U)

Also, that can be done as

u=[n for n in U if gcd(n,40)==1]

Alec

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

To unsubscribe, reply using remove me as the subject.


[sage-support] Re: nested for statements?

2010-04-05 Thread Alec Mihailovs
On Apr 5, 8:26 pm, Dana Ernst ernst.tr...@gmail.com wrote:
 Wow, thanks for all the feedback.  I learned a lot today!

 On Apr 5, 2010, at 5:31 PM, Alec Mihailovs wrote:

  u=[n for n in U if gcd(n,40)==1]

By the way, one has to be careful using some of the methods of U. In
particular,

sage: u1=U.list_of_elements_of_multiplicative_group()
sage: u==u1
True
but

sage: type(u[0])

  type 'sage.rings.integer_mod.IntegerMod_int' 

type(u1[0])

 type 'int' 

and using u1 instead of u would produce a different result.

Alec



-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

To unsubscribe, reply using remove me as the subject.


[sage-support] Re: Interface to openssl hash functions?

2010-04-05 Thread Alec Mihailovs
On Apr 5, 10:50 am, William Stein wst...@gmail.com wrote:

 I would make sure to install the openssl development packages, then
 force a rebuild from source of Python in Sage.

    sage -f python-2.6.4.p7

I can confirm that that works in Sage 4.3 in VirtualBox on Windows,

sage -i openssl-0.9.8d.p1
sage -f python-2.6.4.p7

Alec Mihailovs

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

To unsubscribe, reply using remove me as the subject.


[sage-support] Re: List of standard functions?

2010-04-03 Thread Alec Mihailovs
On Apr 3, 11:55 am, Simon King simon.k...@nuigalway.ie wrote:

   sage: F = [f for f in globals().values() if callable(f)]

I would write it as

filter(callable, globals().values())

Alec

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

To unsubscribe, reply using remove me as the subject.


[sage-support] Re: derivative instance

2010-04-03 Thread Alec Mihailovs
On Apr 3, 2:32 pm, pallab pallabb...@gmail.com wrote:
 Is there any way to check whether a symbolic expression is a
 derivative. Like,

 isinstance(diff(f(x),x),what to put?)

 gives True

 and

 isinstance(f(x),what to put?)

 gives false, assuming f is not a derivative itself.

One can do the following, for example,

def is_diff(expr):
try:
return isinstance(expr.operator(),
sage.symbolic.operators.FDerivativeOperator)
except (AttributeError):
return False

Alec Mihailovs

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

To unsubscribe, reply using remove me as the subject.


[sage-support] Re: Print only outputs?

2010-04-03 Thread Alec Mihailovs

On Apr 2, 11:47 pm, William Stein wst...@gmail.com wrote:

 That's pretty clever!  

Thank you!

 Is amazing how flexible the notebook is, since
 it uses HTML instead of ReST...  (yes, I know, it's flexible enough to
 support cross-site scripting attacks too).

That's the same as with other CAS. In particular, I can write a line
of code in the Maple worksheet, with autoexecute, which would format
the hard drive (erasing all files on it), immediately after opening
that worksheet, and there nothing could be done by the person opening
that worksheet to prevent that (other than opening it in a secure
mode, i.e. with switch -Z if I remember correctly, which not that many
people use.)

Alec

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

To unsubscribe, reply using remove me as the subject.


[sage-support] Re: Is there an efficient method of producing indexed variables?

2010-04-02 Thread Alec Mihailovs
On Apr 2, 1:45 pm, Franco Saliola sali...@gmail.com wrote:

 sage: a = SymbolicVariables('a')
 ...
 Here is a very simple implementation of SymbolicVariables.

     class SymbolicVariables(SageObject):
         def __init__(self, prefix='x'):
             self._prefix = prefix
         def __getitem__(self, i):
             return var(%s%s%(self._prefix, i))

 Thoughts?

It would be conveniet if that would work with more than 1 index, too.
In this particular example, a[1,2] produces something strange if
typeset is turned on in the notebook.

Also, in Maple matrices and vectors with symbolic entries can be
defined as

Matrix(2, symbol=a);

 [a[1, 1]a[1, 2]]
 [  ]
 [a[2, 1]a[2, 2]]

Vector(3, symbol=b);

[b[1]]
[]
[b[2]]
[]
[b[3]]


Alec

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

To unsubscribe, reply using remove me as the subject.


[sage-support] Re: Print only outputs?

2010-04-02 Thread Alec Mihailovs
On Apr 2, 1:19 am, Jason Grout jason-s...@creativetrax.com wrote:
 Also, a quick hack to hide all input cells (except the one after the one
 that you evaluate this command in) is:

 jsmath(script$('.cell_input').hide();/script)

 This is definitely not official, but it works with the current notebook.
   It doesn't affect the Print link, though.

If one executes the following in a cell:

html('style type=text/cssdiv.cell_input_print {display: none}/
style')

and then clicks Print (at the lhs of the Worksheet button at the top),
all input cells will be hidden in the hew html page opened.

Alec Mihailovs

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

To unsubscribe, reply using remove me as the subject.


[sage-support] Re: Seeking Cython-101 lesson

2010-03-22 Thread Alec Mihailovs
On Mar 17, 8:42 pm, kstueve kevin.stu...@gmail.com wrote:
  I can buy you
 lunch/dinner (under $20) for your time, as well as provide interesting
 conversation about primes.

I live at the East coast. But I find that $20 offer kinda insulting.
You, probably understand that people with a PhD (like me) get paid at
least $200/hour or more, and will try to avoid any interesting
conversation meaning that we have to listen to that, at any cost.

Alec Mihailovs

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

To unsubscribe from this group, send email to 
sage-support+unsubscribegooglegroups.com or reply to this email with the words 
REMOVE ME as the subject.


[sage-support] Re: Seeking Cython-101 lesson

2010-03-21 Thread Alec Mihailovs
On Mar 19, 1:27 pm, Pierre pierre.guil...@gmail.com wrote:
 (101 is american numbering meaning in fact first lecture of the first
 year)

It's close, but not exactly. In American colleges and universities,
the first digit mean the year, so courses with numbers started with 1,
are supposed to be taken by freshmen, and 101 is usually a general
education course taken by non-majors. Say Biology 101 means a general
education biology course for non-biologists, and Math 101 is a general
education course for non-mathematicians, as well as for people not
taking any other math courses.

Alec Mihailovs

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

To unsubscribe from this group, send email to 
sage-support+unsubscribegooglegroups.com or reply to this email with the words 
REMOVE ME as the subject.


[sage-support] Re: sage on slitaz linux?

2010-03-20 Thread Alec Mihailovs
On Mar 19, 4:51 am, bb bblo...@arcor.de wrote:
 I tried to compile sage from source on slitaz, a very small and
 ultrafast starting linux and slitaz might be installed to a bootable USB.
 No success.

You could just use Sage live CD (bootable). If it boots from a CD, it
would boot from USB as well, I guess.

It is rather small, contains Sage 4.3.1 on Puppy Linux, and is
available from

http://mira.sunsite.utk.edu/sagemath/livecd/index.html

as well on other mirrors.

Alec Mihailovs

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

To unsubscribe from this group, send email to 
sage-support+unsubscribegooglegroups.com or reply to this email with the words 
REMOVE ME as the subject.


[sage-support] Re: atan2 throws divide by zero

2010-03-19 Thread Alec Mihailovs
Also, simplification might be improved. In particular,

sage: atan(sin(1)/cos(1)).full_simplify()

arctan(sin(1)/cos(1))

while

atan(tan(1)).simplify()

1

Alec Mihailovs

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

To unsubscribe from this group, send email to 
sage-support+unsubscribegooglegroups.com or reply to this email with the words 
REMOVE ME as the subject.


[sage-support] Re: atan2 throws divide by zero

2010-03-18 Thread Alec Mihailovs
On Mar 17, 8:38 pm, G B g.c.b.at.w...@gmail.com wrote:

 atan2(-pi,0) --  RuntimeError: power::eval(): division by zero

 Any ideas how to get around this?

A simple workaround is

sage: from sympy import atan2
sage: atan2(-pi,0)

-pi/2

Alec Mihaiovs

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

To unsubscribe from this group, send email to 
sage-support+unsubscribegooglegroups.com or reply to this email with the words 
REMOVE ME as the subject.


[sage-support] Re: help with chanin dirivatives

2010-03-18 Thread Alec Mihailovs
On Mar 15, 8:58 am, wxu...@sohu.com wrote:
 Hi everyone,I have a function f=f(eta, bx, bt), in which diff(eta,x)=k(bx,bt) 
 and diff(eta,t)=-omega(bx,bt) withbx=delta*x and bt=delta^2*t. I want to 
 calculate the second order derivative diff(diff(f,x)). Theresult should be 
 k^2*D[0,0](f)+2*delta*k*D[0,1](f)+delta*D[0](k)*D[0](f)+delta^2*D[1,1](f).b­ut
  when I did as 
 follows:var('x,t,bx,bt,delta')bx=function('bx',x)bx=delta*xbt=function('bt'­,t)bt=delta^2*tk=function('k',bx,bt)omega=function('omega',bx,bt)eta=functi­on('eta',x,t)f=function('f',eta,bx,bt)it
  does not work. could anyone help me with that?Tanks in advanced!regards,YC

That can be done as

var('x t delta')
map(function,('eta','f','k','omega'))
bx,bt = delta*x,delta^2*t
eq=diff(eta(x,t),x)==k(bx,bt)
f(eta(x,t),bx,bt).diff(x,2).expand().subs(eq).subs(diff(eq,x))

delta^2*D[1, 1](f)(eta(x, t), delta*x, delta^2*t) + 2*delta*k(delta*x,
delta^2*t)*D[0, 1](f)(eta(x, t), delta*x, delta^2*t) +
delta*D[0](f)(eta(x, t), delta*x, delta^2*t)*D[0](k)(delta*x,
delta^2*t)
+ k(delta*x, delta^2*t)^2*D[0, 0](f)(eta(x, t), delta*x, delta^2*t)

Alec Mihailovs

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

To unsubscribe from this group, send email to 
sage-support+unsubscribegooglegroups.com or reply to this email with the words 
REMOVE ME as the subject.


[sage-support] Re: Syntax highlight in SAGE Calculator?

2010-03-17 Thread Alec Mihailovs
On Mar 16, 5:05 pm, dmitrey dmitrey.kros...@scipy.org wrote:
 hi all,
 is it possible somehow to perform syntax highlight in SAGE Calculator,
 at least for viewing published worksheets?

 Regards, D.

In the documentation (in the notebook) the syntax is highlighted (I
mean colored). See, for example,

vector?

vector??

Alec Mihailovs

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Re: Entering matrices whose elements are functions of row/column indices?

2010-03-17 Thread Alec Mihailovs
On Mar 16, 10:47 pm, Alec Mihailovs alec.mihail...@gmail.com wrote:
 By the way, vector doesn't work with integer numpy arrays,

 from numpy import array
 vector(array([1,2]))

 Traceback (most recent call last):

That shouldn't be too hard to implement - in particular, the following
works,

sage: from numpy import array
sage: vector(list(array([1,2])))

(1, 2)

sage: vector(list(array([1,2],dtype=object)))

(1, 2)

sage: _.parent()

Ambient free module of rank 2 over the principal ideal domain Integer
Ring

sage: vector(list(array([1,2],dtype=float)))

(1.0, 2.0)

sage: vector(list(array([1,2],dtype=complex)))

(1.0, 2.0)

sage: _.parent()

Vector space of dimension 2 over Complex Double Field

So it looks as if the conversion from one-dimensional numpy arrays to
vectors could be done like that, independently of their dtype.

Alec Mihailovs

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Re: Entering matrices whose elements are functions of row/column indices?

2010-03-16 Thread Alec Mihailovs
On Mar 16, 2:32 am, Mike Hansen mhan...@gmail.com wrote:
 On Mon, Mar 15, 2010 at 10:16 PM, Jason Grout

 jason-s...@creativetrax.com wrote:
  Whoever takes care of this original issue gets to claim a 3-digit ticket!

 http://trac.sagemath.org/sage_trac/ticket/261

 Patch up for review.

 --Mike

Will it work as matrix(5,f) as well, or only as matrix(5,5,f) ?

Alec Mihailovs

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Re: Entering matrices whose elements are functions of row/column indices?

2010-03-16 Thread Alec Mihailovs
On Mar 16, 3:57 pm, Mike Hansen mhan...@gmail.com wrote:
 On Tue, Mar 16, 2010 at 12:38 PM, Alec Mihailovs

 alec.mihail...@gmail.com wrote:
  Will it work as matrix(5,f) as well, or only as matrix(5,5,f) ?

 It now works with both.

 --Mike

That's great!

What about vector(3,f), f.vector(3), and f.matrix(3,4) or
f.matrix(5) ?

Alec

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Re: Entering matrices whose elements are functions of row/column indices?

2010-03-16 Thread Alec Mihailovs
By the way, vector doesn't work with integer numpy arrays,

from numpy import array
vector(array([1,2]))

Traceback (most recent call last):
  File stdin, line 1, in module
  File _sage_input_60.py, line 5, in module
vector(array([_sage_const_1 ,_sage_const_2 ]))
  File , line 1, in module

  File free_module_element.pyx, line 309, in
sage.modules.free_module_element.vector (sage/modules/
free_module_element.c:3172)
TypeError: unsupported operand type(s) for ** or pow(): 'NoneType' and
'int'

Alec Mihailovs

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Re: Entering matrices whose elements are functions of row/column indices?

2010-03-15 Thread Alec Mihailovs
On Mar 15, 3:39 am, Alec Mihailovs alec.mihail...@gmail.com wrote:
 The second problem is that something strange happens for 1x1 matrices,
 with any dtype,

 matrix(fromfunction(lambda i,j:i-j,(1,1),dtype=int))

 []

 matrix(fromfunction(lambda i,j:i-j+3,(1,1),dtype=int))

 [0 0 0]
 [0 0 0]
 [0 0 0]

That seems to be a bug introduced in Sage, not in numpy,

sage: fromfunction(lambda i,j:i-j+3,(1,1),dtype=int)

array([[3]])

sage: matrix(_)

[0 0 0]
[0 0 0]
[0 0 0]

Alec Mihailovs

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Re: Could someone help me.....

2010-03-15 Thread Alec Mihailovs
On Mar 15, 4:41 pm, Kevin kevinloran...@gmail.com wrote:
 ...me make a graph for this code.
 The code makes a distribution of 2 dice.

 It would be nice to have a graph to go with it.

 from random import random
 maximum = 1
 counts = [0,0,0,0,0,0,0,0,0,0,0,0,0,0]
 n = 0
 while n  maximum:
     dieOne = int(random()*6)+1
     dieTwo = int(random()*6)+1
     dieSum = dieOne + dieTwo
     counts [dieSum] = counts [dieSum] + 1
     n = n + 1
 counts [1:]

Another way of doing that is
(see 
http://docs.scipy.org/doc/numpy/reference/generated/numpy.random.random_integers.html
)

from numpy.random import random_integers
dsums = random_integers(1, 6, 1) + random_integers(1, 6, 1)
from matplotlib import pyplot
counts = pyplot.hist(dsums, 11)[0]; counts

array([ 279,  569,  845, 1072, 1398, 1683, 1355, 1106,  842,  576,
275])

pyplot.savefig(sage1.png)

Alec Mihailovs

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Re: BoxPlot in Sage: how do we plot?

2010-03-15 Thread Alec Mihailovs

On Mar 14, 5:32 pm, jpc pedrocruzave...@gmail.com wrote:
 There is matplotlib

 http://matplotlib.sourceforge.net/examples/pylab_examples/boxplot_dem...

 http://matplotlib.sourceforge.net/plot_directive/mpl_examples/pylab_e...

 I also didn't get it with R in sage (or python).

Yes, R seems to be built without the png support in Sage.

Here is a simple working example of a boxplot using matplotlib:

from pylab import boxplot,savefig
b=boxplot(range(10))
savefig(sage1.png)

The original data list can be substituted in place of range(10) above.

Alec Mihailovs

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Re: Entering matrices whose elements are functions of row/column indices?

2010-03-14 Thread Alec Mihailovs
That could be also done as

from numpy import fromfunction

matrix(fromfunction(lambda i,j:i-j, (6,6), dtype=int))

[ 0 -1 -2 -3 -4 -5]
[ 1  0 -1 -2 -3 -4]
[ 2  1  0 -1 -2 -3]
[ 3  2  1  0 -1 -2]
[ 4  3  2  1  0 -1]
[ 5  4  3  2  1  0]

_.parent()

Full MatrixSpace of 6 by 6 dense matrices over Integer Ring

Alec Mihailovs


-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Re: shift-return, shift-enter, click-mouse-on-evaluate. on evaluating a cell in a notebook

2009-04-21 Thread Alec Mihailovs

In Windows, such things, as well as any other key (and mouse) remapping can 
be done using an autohotkey script, http://www.autohotkey.com/

Alec Mihailovs 


--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] NVIDIA Tesla

2008-11-23 Thread Alec Mihailovs

Is it possible to run SAGE on NVIDIA Tesla (with 4 teraflops)? 

http://www.nvidia.com/object/personal_supercomputing.html
http://tech.slashdot.org/article.pl?sid=08/11/23/068234from=rss

Alec

--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: NVIDIA Tesla

2008-11-23 Thread Alec Mihailovs

Thank you!

 http://groups.google.com/group/mpir-devel/t/df88735e6d4e678c

I should search the group before posting.

Alec


--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: square of an inequality

2008-08-25 Thread Alec Mihailovs

From: Stan Schymanski [EMAIL PROTECTED]

 I think it would be very nice to include a solve algorithm for
 inequalities. To my knowledge, Mathematica does not do this, either.
 Or at least, I did not find out how to do it in Mathematica after 4
 years of use.

For example, 

In[1]:= Reduce[x + y = 3  x = 0  y = 0, {x, y}, Integers]

Out[1]= (x == 0  y == 0) || (x == 0  y == 1) || (x == 0  
   y == 2) || (x == 0  y == 3) || (x == 1  y == 0) || (x == 1  
   y == 1) || (x == 1  y == 2) || (x == 2  y == 0) || (x == 2  
   y == 1) || (x == 3  y == 0)

Alec


--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: square of an inequality

2008-08-23 Thread Alec Mihailovs

 By the way, I just looked at Wester's article (briefly), and it seems as 
 if
 he missed inequalities. Such things, as, say, x+y=3, x=0, y=0 for 
 integer
 x and y, should be a part of the standard test, I think. [...]
 Can SAGE do that?

I meant to solve. The answer should be either a list of points, {x=0,y=0}, 
{x=0,y=1} etc. - or their convex hull. That gives feasible points for 
integer (linear or convex) programming problems.

I posted about that on Mapleprimes (Kindergarten). Maple can't do that using 
isolve.

Alec 


--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: Hypergeometric sum

2008-08-23 Thread Alec Mihailovs

 I came across this example in a recent thread in Maple newsgroup.

 Here is the link,

 http://groups.google.com/group/comp.soft-sys.math.maple/browse_thread/thread/65248f258f5522ad?hl=en#

 Another link, to Mathematica newsgroup,

 http://groups.google.com/group/comp.soft-sys.math.mathematica/browse_thread/thread/b84ac9c2a48f1bc1?hl=en#

Now, compare 3 different approaches to customer support - in Maplesoft 
(none), here (some discussion, but without Maxima or SAGE code, or a 
workaround), and in Wolfram Research (Devendra Kapadia responded very 
nicely, the problem was addressed, and a workaround was suggested).

And the winner is - Wolfram Research.

Alec 


--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: Hypergeometric sum

2008-08-23 Thread Alec Mihailovs

 What is your point?

Actually, I meant that more about Maplesoft. Sage support is usually good in 
this group, just wasn't very good in this thread.

Alec 


--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: Hypergeometric sum

2008-08-23 Thread Alec Mihailovs

Ondrej and William, 

Thank you, it's nice to know about that.

Alec

--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Hypergeometric sum

2008-08-21 Thread Alec Mihailovs

Both Maple and Mathematica give wrong answers to the following sum,

Sum[Binomial[n, k]/Binomial[2 n, k]/k! (2 x)^k, {k, 0, n}]

I tried to find a way to calculate it in SAGE, but couldn't find symbolic 
sums in the documentation. Is Maxima supposed to be used directly?

Alec 


--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: Hypergeometric sum

2008-08-21 Thread Alec Mihailovs

 I came across this example in a recent thread in Maple newsgroup.

Here is the link,

http://groups.google.com/group/comp.soft-sys.math.maple/browse_thread/thread/65248f258f5522ad?hl=en#

Another link, to Mathematica newsgroup,

http://groups.google.com/group/comp.soft-sys.math.mathematica/browse_thread/thread/b84ac9c2a48f1bc1?hl=en#

Alec 


--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: square of an inequality

2008-08-20 Thread Alec Mihailovs

 sage: eqn.lhs()^2eqn.rhs()^2
 bv^2  (bv^2*rwat + av*lwat)/rwat


 Perhaps, there is no need to implement it after all.

There is a definite need, and it shouldn't be too complicated. The thing 
that should be implemented is :

if ab and cd and a,b,c,d0, then a*cb*d.

It is similar to equations (which seems to be implemented - just because of 
Wester benchmarks).

By the way, I just looked at Wester's article (briefly), and it seems as if 
he missed inequalities. Such things, as, say, x+y=3, x=0, y=0 for integer 
x and y, should be a part of the standard test, I think. Maple can't do 
that. I didn't try Mathematica, but I believe that it is capable of that. 
Can SAGE do that?

Alec





--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] polymake

2008-08-18 Thread Alec Mihailovs

I just tried to install polymake (an optional package) in Sage 3.1.1 and it 
failed because it tried to find cddlib-094b.p1 while the next patch, 
cddlib-094b.p2 is included in standard packages.

Alec 


--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: polymake

2008-08-18 Thread Alec Mihailovs

Michael, 

 I have an updates spkg that fixes those issues once and for all. I
 need to polish it and have it reviewed so that I can push it into the
 repo.

Thank you, 
Alec

--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Spam bots

2008-07-15 Thread Alec Mihailovs

Sage seems to be used for creating spam bots. In particular, the FrontPage 
in Maple Wiki was corrupted yesterday from 193.53.87.109 with spam ending 
with CategorySage, see

http://mapleadvisor.com/cgi-bin/moin.cgi/FrontPage?action=diffrev1=3rev2=4

Alec Mihailovs 


--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: Spam bots

2008-07-15 Thread Alec Mihailovs

 http://mapleadvisor.com/cgi-bin/moin.cgi/FrontPage?action=diffrev1=3rev2=4

 I'm not sure what you mean by Sage is being used to create spam bots.
 Since you already had a CategorySage on your wiki, I don't see any
 evidence that this is related to Sage in any way.

First, I didn't have CategorySage there.

Second, look at the added text - CategorySage was added as a part of the 
spam.

Alec 


--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: Spam bots

2008-07-15 Thread Alec Mihailovs

 My guess is that the spam bot wanted to assign its page to a category,
 and it can easily find the already existing categories on your wiki
 from http://mapleadvisor.com/cgi-bin/moin.cgi/CategoryCategory

That could happen, with probability 20%. 

Alec

--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: Spam bots

2008-07-15 Thread Alec Mihailovs

 I guess in the end I'm not sure what you wanted to accomplish with
 this thread.  Are you saying that there is an individual associated to
 the Sage project that is spamming your wiki?  Or that there is code in
 Sage designed to spam your wiki? Or ...?

First, I wanted to know if there were other similar cases known.

Second, what would you do in a similar case, if say, your wiki got spammed 
with some text ending CathegoryMathematica?

Alec 


--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: Spam bots

2008-07-15 Thread Alec Mihailovs

 Disabled automated account creation and turn on the text captcha. Just
 because a spam bot uses a category X it has nothing to do with X. It
 seems kind of counter productive to be associated with the culprit in
 the first place. If *I* were to write a Sage spambot I would have it
 claim to be MMA as a diversion tactic ;)

That's a good advise, thank you. I'll turn on the captcha.

Alec

PS Frankly, knowing some of (young) Sage contributors (from their other 
Usenet and wiki activities), I suspected that they might have to do 
something with that spam bot - but you were very convincing, and now I am 
not that sure about that -Alec



--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: Accessing terms in an expression

2008-07-03 Thread Alec Mihailovs

From: David Joyner [EMAIL PROTECTED]

 I was wondering about this myself. Maple has a command that does
 exactly this (I think it is the ops command).

It's op. Maple represents objects using DAGs (directed acyclic graphs 
literally, but it also includes enumeration of child vertices), and op lists 
all vertices below the given vertex. For different representation of objects 
it may be not that easy to do.

Alec 


--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Maple wiki

2008-07-03 Thread Alec Mihailovs

I started a wiki 2 weeks ago at
http://mapleadvisor.com/cgi-bin/moin.cgi/StartingPage

Originally it was planned to be a Maple wiki (even if I am not especially
interested in Maple myself and my main advise for Mape users is to switch 
from Maple to SAGE), but it could be much wider than that - including 
Mathematica wiki (with a similar advice), and SAGE wiki, for example. 
Everybody can edit everything.

I added jsMath ( http://mapleadvisor.com/cgi-bin/moin.cgi/JsMath ) there, so
LaTeX formulas are displayed and printed normally (without using pictures).
Also, maple input can be displayed nicely (red and bold) through mi(some
maple input), etc.

Many posts on this list would look great there.

Generally speaking, wiki seem to have a potential of creating a nice
interactive community. Thus far, not that many people seem to get interested
though.

Alec Mihailovs


--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: Maple wiki

2008-07-03 Thread Alec Mihailovs

 I'd like to copy a few pages (and from cython wiki, too). The one that I
 originally meant, was 
 http://wiki.sagemath.org/A_short_introduction_to_SAGE

Just did it, 
http://mapleadvisor.com/cgi-bin/moin.cgi/A_short_introduction_to_SAGE

It took more time and effort than I expected though, because it has appeared 
that sagemath is running a quite old MoinMoin version, 1.5.7, with different 
link format than I have in version 1.7.

Alec 


--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: Performance problem in sage-3.0.2 and sage-3.0.3

2008-07-02 Thread Alec Mihailovs

From: Daryl Hammond [EMAIL PROTECTED]
 SAGE Version 3.0, Release Date: 2008-04-23
 array size:   1000
 number of primes: 664580
 Elapsed seconds:  70.93

That seems to be quite slow anyway. For example, for my Maple program ES2, 
see http://www.mapleprimes.com/blog/alec/the-eratosthenes-sieve ,

time(ES2(10^7));
0.702

Also, the number of primes given by your program is 1 more than it should 
be,

ArrayNumElems(ES2(10^7));
664579
Alec Mihailovs



--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: Fwd: GUI for SAGE

2007-08-10 Thread Alec Mihailovs

From: William Stein
Begin forwarded message:
From: [EMAIL PROTECTED] (Erik D. Jacobson 04)

 Can you recommend an IDE that supports SAGE?  I like DrPython...but I 
 haven't been able to get it to run my SAGE programs (I'm running SAGE from 
 a virtual machine on my PC).  The Notebook interface lacks colored text 
 and auto-indent--features that can really smooth out the learning curve 
 for a beginner.

Personally, I prefer IDLE, but I'm not sure whether Sage can run in it. I am 
not ready to pay $200 for developing that feature though.

Alec



--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://sage.math.washington.edu/sage/ and http://sage.scipy.org/sage/
-~--~~~~--~~--~--~---



[sage-support] Re: Cayley graphs in SAGE

2007-08-06 Thread Alec Mihailovs

From: David Joyner [EMAIL PROTECTED]

 Here is an example of constructing a Cayley graph in SAGE (this uses 
 grape):
 ...
 Question: Can anyone this of a simpler way to do this?

Group Explorer displays nice Cayley graphs,

http://groupexplorer.sourceforge.net/

I used it teaching algebra.

I'm not sure whether it could be added as a package to SAGE. The source is 
available though.

Alec 


--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://sage.math.washington.edu/sage/ and http://sage.scipy.org/sage/
-~--~~~~--~~--~--~---



[sage-support] Re:

2007-07-17 Thread Alec Mihailovs

Struggling with various choices of using SAGE from Windows, I finally 
decided to stop doing that - I bought a new computer (from HP) with 500 GB 
hard drive, installed Ubuntu on it and get SAGE installed into Ubuntu. That 
seems to be working much better than any of my previous attempts with 
virtualization (colinux, Virtual PC, VMware, or Parallels.)

Alec

- Original Message - 
From: William Stein [EMAIL PROTECTED]
To: David Stahl (PAVCO) [EMAIL PROTECTED]; 
sage-support@googlegroups.com
Sent: Tuesday, July 17, 2007 7:23 PM
Subject: [sage-support] Re: Re:



 On 7/17/07, David Stahl (PAVCO) [EMAIL PROTECTED] wrote:
 Windows 2000 with coLinux

 I'm no longer supporting SAGE running via colinux.  The recommended way
 to run SAGE under Windows is via VMware.  There's a premade machine here:

 http://www.sagemath.org/SAGEbin/vmware/

 That said, your problem is likely that SAGe doesn't have access to your
 gp scripts.  You'll have to get them into colinux somehow (or use vmware,
 and again you have to get them into vmware).   One somewhat silly
 way is to put the file somewhere online and use the get_remote_file
 command (available in recent versions of SAGE) to download the file
 into SAGE.

 William

 
 


--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://sage.math.washington.edu/sage/ and http://sage.scipy.org/sage/
-~--~~~~--~~--~--~---



[sage-support] Re: [sage-devel] Re: Kudos on a fabulous system!

2007-05-17 Thread Alec Mihailovs

William,

Thank you!

 Fortunately this problem is very very easy to solve.  Go to

   http://groups.google.com/group/sage-support/subscribe

 where you see that one option is to receive all messages as one
 batch per day

That is what I should have been done from the very beginning.

Alec

PS Just read your reply to Richard Fateman - a very good reading (a great 
compensation for series of other not such interesting mailing list 
posts) -Alec 


--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://sage.math.washington.edu/sage/ and http://sage.scipy.org/sage/
-~--~~~~--~~--~--~---



[sage-support] Re: nth root

2007-02-12 Thread Alec Mihailovs

- Original Message - 
From: Dirk Laurie [EMAIL PROTECTED]
 {{{
 sage: exp(log(64)/3)
 4.0
 }}}
 Well, that works for the cube root of 64.  But note it's 4.0, not 4.
 This exposes one to roundoff errors, which the other two methods
 avoid.

Well, that can be avoided by increasing the number of digits. Anyway, the 
winner is 64.nth_root(3) suggested by Didier Deshommes in another thread.

I'd like to make a suggestion to add th_root method to all domains where 
nth_root is implemented, working as 3.th_root(64) in this example, with 
aliases st_root, nd_root and rd_root, so that it could be executed as 
3.rd_root(64) that looks more natural to me than 64.nth_root(3).

Alec 



--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://sage.math.washington.edu/sage/ and http://sage.scipy.org/sage/
-~--~~~~--~~--~--~---



[sage-support] Re: nth root

2007-02-09 Thread Alec Mihailovs

- Original Message - 
From: Dirk Laurie [EMAIL PROTECTED]
 
 David Joyner skryf:
 
 Timothy Clemans wrote:
  Does SAGE support finding the nth root of something?
  The cube root of 27 is 3, 8 is 2, 64 is 4

 
 One way is
 ZZ(gap.eval(RootInt( 64, 3 )))
 
 Or:
  (x^n-a).roots()[0][0]

Or 
{{{
sage: exp(log(64)/3)
4.0
}}}

Alec


--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://sage.math.washington.edu/sage/ and http://sage.scipy.org/sage/
-~--~~~~--~~--~--~---



[sage-support] Re: [sage-devel] Re: [sage-support] Re: sage and sudoku

2007-02-04 Thread Alec Mihailovs

 Oh ok then in the code you should write n = 2*n-1 which means if n is
 2 then 3 will be used.

That's not the right way - the argument of the function should be the size 
of the square. If you want to avoid the case of even sizes, that could be 
done by testing the parity - something like

if n%2==0: print The argument should be odd; return

Alec



--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://sage.math.washington.edu/sage/ and http://sage.scipy.org/sage/
-~--~~~~--~~--~--~---



[sage-support] Re: [sage-devel] Re: [sage-support] Re: sage and sudoku

2007-02-04 Thread Alec Mihailovs

From: Timothy Clemans [EMAIL PROTECTED]

 My function clearly stated magicsquare_normal_odd by being called that
 so its fine and I would just call yours that too. In the docstring I
 would say computes nth odd normal magic square. This function is for
 a special case of normal magic squares.

AFAICT, there is no such thing as a normal magic square. What do you mean by 
normal?

I used 'Siamese' to specify the particular well-known case. If other 
algorithms are planned for including, a better name may be 
magic_square.Siamese , I think. The docstring may be For an odd n, returns 
$n\times n$ Siamese magic square.

Alec 



--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://sage.math.washington.edu/sage/ and http://sage.scipy.org/sage/
-~--~~~~--~~--~--~---



[sage-support] Re: [sage-devel] Re: [sage-support] Re: sage and sudoku

2007-02-03 Thread Alec Mihailovs

- Original Message - 
From: Timothy Clemans [EMAIL PROTECTED]

 def magicsquare_normal_odd(n):
r
Generates nth odd normal magic square for n greater than 1 using
 de la Loubere's method.

EXAMPLES:
sage: magicsquare_normal_odd(1)
[8 1 6]
[3 5 7]
[4 9 2]
sage: magicsquare_normal_odd(2)
[17 24  1  8 15]
[23  5  7 14 16]
[ 4  6 13 20 22]
[10 12 19 21  3]
[11 18 25  2  9]

--skip--

That can be done in Python in one line,

def Siamese_magic_square(n):
return [[(i+j+(n+1)/2)%n*n+(i+2*j+1)%n+1 for j in range(n)]
   for i in range(n)]

For example,

Siamese_magic_square(3)
[[8, 1, 6], [3, 5, 7], [4, 9, 2]]

Siamese_magic_square(5)
[[17, 24, 1, 8, 15], [23, 5, 7, 14, 16], [4, 6, 13, 20, 22], [10, 12, 19, 
21, 3], [11, 18, 25, 2, 9]]

Alec Mihailovs
http://mihailovs.com/Alec/





--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://sage.math.washington.edu/sage/ and http://sage.scipy.org/sage/
-~--~~~~--~~--~--~---



[sage-support] Re: [sage-devel] Re: [sage-support] Re: sage and sudoku

2007-02-03 Thread Alec Mihailovs

From: Timothy Clemans [EMAIL PROTECTED]

 Wow! Now thats cool. I'm going to time test them. Thanks

I had some trouble with copying and pasting your procedure in SAGE (because 
I use it in Windows through cygwin and rxvt with Unix line endings and my 
email has Windows line endings and convert it to Unix by creating a text 
file and then using dos2unix on it seemed to be too much trouble). So I 
modified your procedure to plain Python by changing ^ to ** in 2 places and 
changing the end line in it to return square.

After that I did timing in IDLE using the print_timing decorator from 
http://www.daniweb.com/code/snippet368.html .

It appears that Siamese_magic_square is about 4-5 times faster than 
magicsquare_normal_odd.

Actually, if the time is important, it can be made even faster by changing 
the j range (that reduces the number of operations). In SAGE form that looks 
like

def Siamese_magic_square(n):
return matrix([[j%n*n+(j+j-i)%n+1
for j in range(i+(1-n)/2,i+(n+1)/2)] for i in range(n)])

That makes it about 6-7 times faster than magicsquare_normal_odd (in IDLE, 
without matrix - I didn't test that in SAGE and I don't know how the matrix 
construction works there - in particular, whether adding the size of the 
matrix would make it faster.)

Alec Mihailovs
http://mihailovs.com/Alec/ 



--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://sage.math.washington.edu/sage/ and http://sage.scipy.org/sage/
-~--~~~~--~~--~--~---



  1   2   >