### The Maxima on-line user's manual

Algebra Calculator

#### Diag_matrix

Function: diag_matrix (<d_1>, <d_2>,...,<d_n>) Return a diagonal matrix with diagonal entries <d_1>, <d_2>,...,<d_n>. When the diagonal entries are matrices, the zero entries of the returned matrix are zero matrices of the appropriate size; for example:

`          (%i1) diag_matrix(diag_matrix(1,2),diag_matrix(3,4));`

[ [ 1 0 ] [ 0 0 ] ] [ [ ] [ ] ] [ [ 0 2 ] [ 0 0 ] ]

`          (%o1)                       [                    ]`
`                                      [ [ 0  0 ]  [ 3  0 ] ]`
`                                      [ [      ]  [      ] ]`
`                                      [ [ 0  0 ]  [ 0  4 ] ]`
`          (%i2) diag_matrix(p,q);`

```                                             [ p  0 ]
(%o2)                              [      ]
[ 0  q ]```

```(%o1)                                true
(%i2) ```

### Related Examples

##### diag_matrix-matrix

m:matrix([1,2,3,4]);

diag_matrix(m);

Calculate

##### diag_matrix-matrix

m:columnvector([1,2,3...

diag_matrix(m);

Calculate

##### diag_matrix-matrix-transpose

a:matrix([-1,2,0,-1],...

a.transpose(a);

diag_matrix([2,4,2,1]);

Calculate

##### diag_matrix-matrix-transpose

a:matrix([-1,2,0,-1],...

a.transpose(a);

b.diag_matrix([2,4,2,...

Calculate

##### diag_matrix-matrix-transpose

a:matrix([-1,2,0,-1],...

a.transpose(a);

diag_matrix([2,4,2,1]);

Calculate

##### diag_matrix-matrix-sin

lg:diag_matrix(1,r^2,...

ct_coords:[r,%theta,%...

Calculate

##### diag_matrix-matrix-sin

diag_matrix(2*n,2*l,r...

Calculate

##### diag_matrix-matrix

diag([diag_matrix(1,2...

diag_matrix(p,q);

Calculate

##### diag_matrix-matrix

a: matrix([6, 1, 8], ...

diag([a,a]);

diag_matrix(p,q);

Calculate

##### diag_matrix-matrix

M: matrix ([6,2,-2], ...

diag_matrix (M);

Calculate