### Related

? diag_matrix;

Calculate

##### diag_matrix-matrix

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

diag_matrix(m);

Calculate

##### diag_matrix-eigenvectors-matrix-transpose

A:matrix([-1,0,0,1],[...

eigenvectors(A);

diag_matrix(A);

Calculate

? diag_matrix;

Calculate

##### diag_matrix-matrix

A: matrix([3,-1,2],[3...

B: A-diag_matrix(x,x,x);

Calculate

##### diag_matrix-eigenvectors-matrix-transpose

A:matrix([5,0,-4],[0,...

eigenvectors(A);

diag_matrix(A);

Calculate

##### diag_matrix-genmatrix-invert-lambda-transpose

A: genmatrix(lambda([...

B: matrix([1,0], [2,7...

P: diag_matrix(1/2,1/2);

Calculate

##### diag_matrix-matrix

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

diag_matrix(m);

Calculate

(cframe_flag:false,gc...

lg:diag_matrix(-t,t^2...

Calculate

##### diag_matrix-matrix-transpose

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

a.transpose(a);

a.diag_matrix(2,4,2,1...

Calculate

### diag_matrix

Run Example
```(%i1)load(ctensor);
(%o1)          /usr/share/maxima/5.21.1/share/tensor/ctensor.mac
(%i2) (cframe_flag:false,gcd:spmod,ctrgsimp:true,ratfac:true);
(%o2)                                true
(%i3) lg:diag_matrix(-1,r*k^2,r^2,(sin(%theta)*r)^2);
[ - 1   0    0          0        ]
[                                ]
[       2                        ]
[  0   k  r  0          0        ]
(%o3)                 [                                ]
[             2                  ]
[  0    0    r          0        ]
[                                ]
[                   2          2 ]
[  0    0    0   sin (%theta) r  ]
(%i4) ct_coords:[t,r,%theta,%phi];
(%o4)                        [t, r, %theta, %phi]
(%i5) depends(%nu,[r,t],%lambda,[r,t]);
(%o5)                     [%nu(r, t), %lambda(r, t)]
(%i6) cmetric(false);
(%o6)                                done
(%i7) christof(mcs);
1
(%t7)                          mcs        = ---
2, 2, 2   2 r

1
(%t8)                           mcs        = -
2, 3, 3   r

1
(%t9)                           mcs        = -
2, 4, 4   r

1
(%t10)                         mcs        = - --
3, 3, 2      2
k

cos(%theta)
(%t11)                     mcs        = -----------
3, 4, 4   sin(%theta)

2
sin (%theta)
(%t12)                    mcs        = - ------------
4, 4, 2           2
k

(%t13)              mcs        = - cos(%theta) sin(%theta)
4, 4, 3

(%o13)                               done
(%i14)  riemann(true);
1
(%t14)                      riem           = - ----
2, 3, 2, 3        2
2 r

1
(%t15)                      riem           = - ----
2, 4, 2, 4        2
2 r

1
(%t16)                      riem           = ------
3, 3, 2, 2      2
2 k  r

1
(%t17)                     riem           = ---- - 1
3, 4, 3, 4    2
k  r

2
sin (%theta)
(%t18)                   riem           = ------------
4, 4, 2, 2         2
2 k  r

2           2
sin (%theta) (k  r - 1)
(%t19)             riem           = -----------------------
4, 4, 3, 3             2
k  r

(%o19)                               done
(%i20) ricci(true);
1
(%t20)                           ric     = --
2, 2    2
r

2
2 k  r - 1
(%t21)                       ric     = ----------
3, 3        2
2 k  r

2             2
sin (%theta) (2 k  r - 1)
(%t22)                ric     = -------------------------
4, 4               2
2 k  r

(%o22)                               done
(%i23) R:scurvature();
2
(%o23)                                --
2
r
(%i24) ```
Run Example
```A:matrix([0,1,1,1],[1,-2,-1,-2],[1,-1,0,-1],[1,-2,-1,-2]);
[ 0   1    1    1  ]
[                  ]
[ 1  - 2  - 1  - 2 ]
(%o1)                        [                  ]
[ 1  - 1   0   - 1 ]
[                  ]
[ 1  - 2  - 1  - 2 ]
(%i2) eigenvectors(A);
(%o2) [[[- 5, 1, 0], [1, 1, 2]], [[[1, - 2, - 1, - 2]], [[1, 0, 1, 0]],
[[1, 0, - 1, 1], [0, 1, 0, - 1]]]]
(%i3) diag_matrix(A);
[ [ 0   1    1    1  ] ]
[ [                  ] ]
[ [ 1  - 2  - 1  - 2 ] ]
(%o3)                      [ [                  ] ]
[ [ 1  - 1   0   - 1 ] ]
[ [                  ] ]
[ [ 1  - 2  - 1  - 2 ] ]
(%i4) transpose(A);
[ 0   1    1    1  ]
[                  ]
[ 1  - 2  - 1  - 2 ]
(%o4)                        [                  ]
[ 1  - 1   0   - 1 ]
[                  ]
[ 1  - 2  - 1  - 2 ]
(%i5) I:matrix([1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]);
[ 1  0  0  0 ]
[            ]
[ 0  1  0  0 ]
(%o5)                           [            ]
[ 0  0  1  0 ]
[            ]
[ 0  0  0  1 ]
(%i6) b=(-5*I-A);
[ - 5  - 1  - 1  - 1 ]
[                    ]
[ - 1  - 3   1    2  ]
(%o6)                     b = [                    ]
[ - 1   1   - 5   1  ]
[                    ]
[ - 1   2    1   - 3 ]
(%i7) ```
Run Example
```load(ctensor);
(%o1)          /usr/share/maxima/5.21.1/share/tensor/ctensor.mac
(%i2) (cframe_flag:false,gcd:spmod,ctrgsimp:true,ratfac:true);
(%o2)                                true
(%i3) lg:diag_matrix(-1,1,1,f(t,x));
[ - 1  0  0     0    ]
[                    ]
[  0   1  0     0    ]
(%o3)                       [                    ]
[  0   0  1     0    ]
[                    ]
[  0   0  0  f(t, x) ]
(%i4) ct_coords:[t,x,y,z];
(%o4)                            [t, x, y, z]
(%i5) cmetric(false);
(%o5)                                done
(%i6) christof(mcs);
d
-- (f(t, x))
dt
(%t6)                      mcs        = ------------
1, 4, 4    2 f(t, x)

d
-- (f(t, x))
dx
(%t7)                      mcs        = ------------
2, 4, 4    2 f(t, x)

d
-- (f(t, x))
dt
(%t8)                      mcs        = ------------
4, 4, 1        2

d
-- (f(t, x))
dx
(%t9)                     mcs        = - ------------
4, 4, 2          2

(%o9)                                done
(%i10)  riemann(true);
2
d
--- (f(t, x))    d            2
2             (-- (f(t, x)))
dt               dt
(%t10)         riem           = ------------- - ---------------
1, 4, 1, 4     2 f(t, x)          2
4 f (t, x)

2
d                 d              d
----- (f(t, x))   (-- (f(t, x))) (-- (f(t, x)))
dt dx              dt             dx
(%t11) riem           = --------------- - -----------------------------
1, 4, 2, 4      2 f(t, x)                  2
4 f (t, x)

2
d                 d              d
----- (f(t, x))   (-- (f(t, x))) (-- (f(t, x)))
dt dx              dt             dx
(%t12) riem           = --------------- - -----------------------------
2, 4, 1, 4      2 f(t, x)                  2
4 f (t, x)

2
d
--- (f(t, x))    d            2
2             (-- (f(t, x)))
dx               dx
(%t13)         riem           = ------------- - ---------------
2, 4, 2, 4     2 f(t, x)          2
4 f (t, x)

2
d                 d            2
2 f(t, x) (--- (f(t, x))) - (-- (f(t, x)))
2               dt
dt
(%t14)   riem           = -------------------------------------------
4, 4, 1, 1                    4 f(t, x)

(%t15) riem           =
4, 4, 1, 2
2
d              d                           d
(-- (f(t, x))) (-- (f(t, x))) - 2 f(t, x) (----- (f(t, x)))
dt             dx                         dt dx
-----------------------------------------------------------
4 f(t, x)

(%t16) riem           =
4, 4, 2, 1
2
d              d                           d
(-- (f(t, x))) (-- (f(t, x))) - 2 f(t, x) (----- (f(t, x)))
dt             dx                         dt dx
- -----------------------------------------------------------
4 f(t, x)

2
d                 d            2
2 f(t, x) (--- (f(t, x))) - (-- (f(t, x)))
2               dx
dx
(%t17)  riem           = - -------------------------------------------
4, 4, 2, 2                      4 f(t, x)

(%o17)                               done
(%i18) ricci(true);
2
d                 d            2
2 f(t, x) (--- (f(t, x))) - (-- (f(t, x)))
2               dt
dt
(%t18)      ric     = - -------------------------------------------
1, 1                        2
4 f (t, x)

2
d              d                           d
(-- (f(t, x))) (-- (f(t, x))) - 2 f(t, x) (----- (f(t, x)))
dt             dx                         dt dx
(%t19) ric     = -----------------------------------------------------------
1, 2                              2
4 f (t, x)

2
d                 d            2
2 f(t, x) (--- (f(t, x))) - (-- (f(t, x)))
2               dx
dx
(%t20)      ric     = - -------------------------------------------
2, 2                        2
4 f (t, x)

2
d                 d            2
(%t21) ric     = - (2 f(t, x) (--- (f(t, x))) - (-- (f(t, x)))
4, 4                   2               dx
dx
2
d                 d            2
- 2 f(t, x) (--- (f(t, x))) + (-- (f(t, x))) )/(4 f(t, x))
2               dt
dt

(%o21)                               done
(%i22) ```

### Related Help

Help for Diag_matrix