# Variable matrices

If I type M = matrix(SR, 2, var('a,b,c,d')); show(~M), it gives me the inverse of the matrix M with entries in terms of a,b,c,d. Now what I want is to set four variable matrices A,B,C,D each of size 2x2 and then I want to create the block matrix N=block_matrix([[A, B], [C, D]]). Finally I want some functions of N in terms of A,B,C,D (say det(N)).

And your question is ?

I want the determinant of N in terms of A,B,C,D as variables.

You want $\det N$ in terms of $\det A$, ..., $\det D$? SageMath is unable to give you this to the best of my knowledge. Note that it is not suprising: There is no such expression in a very general case. Only if some matrix is known to be invertible, or some matrices commute, etc. See on Wikipedia.

Now in your case of $2\times 2$ blocks, you may of course define $16$ variables $a_{11}$, ..., $a_{22}$, ..., $d_{22}$ and ask for this $16\times 16$ determinant. Then, you can try to reconstruct some expression based on the four $2\times 2$ determinants. But you'll need to have some assumptions at some point I guess.