Dear friends! Hope you will be fine. I want to generate a general form of the matrix (of order 2M+1 by 2M+1) shown below in Maple

[[[0,0,⋯,0,-1/(M Pi),0,⋯,0,1/(M Pi)],[0,0,⋯,0,-1/((M-1) Pi),0,⋯,1/((M-1) Pi),0],[⋮,⋮,⋱,⋮,⋮,⋮, ⋰,⋮,⋮],[0,0,⋯,0,-1/(Pi),1/(Pi),⋯,0,0],[1/(Pi),1/(Pi),⋯,1/(Pi),1,1/(Pi),⋯,1/(Pi),1/(Pi)],[0,0,⋯,1/(Pi),1/(Pi),0,⋯,0,0],[⋮,⋮,⋰,⋮,⋮,⋮,⋱,⋮,⋮],[0,1/((M-1) Pi),⋯,0,1/((M-1) Pi),0,⋯,0,0],[1/(M Pi),0,⋯,0,1/(M Pi),0,⋯,0,0]]]

for M=4 we get

Matrix(9, 9, {(1, 1) = 0, (1, 2) = 0, (1, 3) = 0, (1, 4) = 0, (1, 5) = -(1/4)/Pi, (1, 6) = 0, (1, 7) = 0, (1, 8) = 0, (1, 9) = (1/4)/Pi, (2, 1) = 0, (2, 2) = 0, (2, 3) = 0, (2, 4) = 0, (2, 5) = -(1/3)/Pi, (2, 6) = 0, (2, 7) = 0, (2, 8) = (1/3)/Pi, (2, 9) = 0, (3, 1) = 0, (3, 2) = 0, (3, 3) = 0, (3, 4) = 0, (3, 5) = -(1/2)/Pi, (3, 6) = 0, (3, 7) = (1/2)/Pi, (3, 8) = 0, (3, 9) = 0, (4, 1) = 0, (4, 2) = 0, (4, 3) = 0, (4, 4) = 0, (4, 5) = -1/Pi, (4, 6) = 1/Pi, (4, 7) = 0, (4, 8) = 0, (4, 9) = 0, (5, 1) = 1/Pi, (5, 2) = 1/Pi, (5, 3) = 1/Pi, (5, 4) = 1/Pi, (5, 5) = 1, (5, 6) = 1/Pi, (5, 7) = 1/Pi, (5, 8) = 1/Pi, (5, 9) = 1/Pi, (6, 1) = 0, (6, 2) = 0, (6, 3) = 0, (6, 4) = 1/Pi, (6, 5) = 1/Pi, (6, 6) = 0, (6, 7) = 0, (6, 8) = 0, (6, 9) = 0, (7, 1) = 0, (7, 2) = 0, (7, 3) = (1/2)/Pi, (7, 4) = 0, (7, 5) = (1/2)/Pi, (7, 6) = 0, (7, 7) = 0, (7, 8) = 0, (7, 9) = 0, (8, 1) = 0, (8, 2) = (1/3)/Pi, (8, 3) = 0, (8, 4) = 0, (8, 5) = (1/3)/Pi, (8, 6) = 0, (8, 7) = 0, (8, 8) = 0, (8, 9) = 0, (9, 1) = (1/4)/Pi, (9, 2) = 0, (9, 3) = 0, (9, 4) = 0, (9, 5) = (1/4)/Pi, (9, 6) = 0, (9, 7) = 0, (9, 8) = 0, (9, 9) = 0})

I want the general for of this matrix for any value of M

9_by_9.mw