1 | initial version |
The problem is that matrix rows and columns are numbered from 0.
So the top left element of that matrix would be 1 / (0 + 0).
If you are thinking of rows and columns as numbered from 1, do this instead:
sage: m = matrix(QQ, 3, 3, lambda i, j: 1 / (i + j + 2)); m
[1/2 1/3 1/4]
[1/3 1/4 1/5]
[1/4 1/5 1/6]
or you can use another base ring such as RR or R in your example, if you defined R as a ring beforehand (in Sage, by default, R stand for the interpreter for the R statistics language).