I think the order of the i and j is transposed (assuming row i and
column j):
sage: M = matrix(5,5,[[1/(i+j%2) for j in range(1,6)] for i in range
(1,6)])
sage: M

[1/2   1 1/2   1 1/2]
[1/3 1/2 1/3 1/2 1/3]
[1/4 1/3 1/4 1/3 1/4]
[1/5 1/4 1/5 1/4 1/5]
[1/6 1/5 1/6 1/5 1/6]
s
M = matrix(5,5,[[1/(i+j%2) for j in range(1,6)] for i in range(1,6)])

On Dec 10, 4:24 pm, "David Joyner" <[EMAIL PROTECTED]> wrote:
> One way to do it (for a 10x10):
>
> sage: n = 10
> sage: M = Matrix(n,n,[[1/(i+j) for i in range(1,11)] for j in range(1,11)])
> sage: M
>
> [ 1/2  1/3  1/4  1/5  1/6  1/7  1/8  1/9 1/10 1/11]
> [ 1/3  1/4  1/5  1/6  1/7  1/8  1/9 1/10 1/11 1/12]
> [ 1/4  1/5  1/6  1/7  1/8  1/9 1/10 1/11 1/12 1/13]
> [ 1/5  1/6  1/7  1/8  1/9 1/10 1/11 1/12 1/13 1/14]
> [ 1/6  1/7  1/8  1/9 1/10 1/11 1/12 1/13 1/14 1/15]
> [ 1/7  1/8  1/9 1/10 1/11 1/12 1/13 1/14 1/15 1/16]
> [ 1/8  1/9 1/10 1/11 1/12 1/13 1/14 1/15 1/16 1/17]
> [ 1/9 1/10 1/11 1/12 1/13 1/14 1/15 1/16 1/17 1/18]
> [1/10 1/11 1/12 1/13 1/14 1/15 1/16 1/17 1/18 1/19]
> [1/11 1/12 1/13 1/14 1/15 1/16 1/17 1/18 1/19 1/20]
>
> On Wed, Dec 10, 2008 at 5:19 PM, Alasdair <[EMAIL PROTECTED]> wrote:
>
> > The title pretty much says it all - for example, how would I create a
> > 4x4 matrix whose (i,j)-th element is 1/(i+j)?
>
> > Thanks,
> > Alasdair
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to