How to calculate a matrix as a function of a matrix Say, we have a matrix
$$f=\begin{bmatrix}
x&  2x\\
3x& x+2
\end{bmatrix}.$$
Say we have a matrix another matrix represented by 
$$g=\begin{bmatrix}
5x&   6x \\
4x& x-1
\end{bmatrix}$$
Is there a way to calculate $$f(g(x))?$$
If so, how would it be performed in this example? I'm assuming it wouldn't be a strict multiplication, rather some use of a chain rule.  I am not exactly sure how to proceed.
 A: Supposing that $x\in \Bbb R$ then you have $f:\Bbb R\to \Bbb R^{2\times 2}$ and $g:\Bbb R\to \Bbb R^{2\times 2}$.
If you want $f(g(x))$ you should have the image of $g$ inside the domain of $f$, what is not possible because a subset of $\Bbb R^{2\times 2}$ is not inside of $\Bbb R$.
A: I would prefer to think of the inputs of matrices as objects, as if you were programming in an object oriented language like C++. In this way, the matrix entities could be anything, as long all of the necessary operations could be performed.
So instead of $f:\Bbb R\to\Bbb R^2$, the function would be defined $f:\Bbb S\to\Bbb S^2$ where $\Bbb S$ is the co-domain of $g$
What this means is that $f(g(x))$ would be a 2×2 matrix whose entities were 2×2 matrices. In this way, the determinant would be in the same form as the entries, a 2×2 matrix. And multiplication of $f(g(x))$ by any quantity $\alpha$ with would only be defined in a few cases:

*

*$\alpha$ is a scalar

*$\alpha$ is a 2×$n$ matrix whose entries are scalars

*$\alpha$ is a 2×$n$ matrix whose entries are 2×2 matrices

Likewise the resulting product would be, respectively,

*

*A 2×2 matrix of 2×2 matirces

*A 2×n matrix of 2×2 matrices

*A 2×n matrix of 2×2 matrices

Another interpretation would be to extend the resultant matrix to be a 4×4 matrix. Don't think of this as "correct" or "incorrect," think of it as a the premise of a postulate. One interesting fact is that the determinant of such a 4×4 matrix would be the determinant of the determinant of the 2×2 matrix of 2×2 matrices.
How the composition of $f$ and $g$ would work would be determined by the actual application
