# What is an example of a linear function that maps a matrix to a scalar? What makes it a 'function'?

I suppose this is part terminology question and part math, but I am trying to untangle what we mean when we say "The linear function $f$ maps $R_{m\times n}$ space to $R_{m}$ space", and "The linear function $f$ maps $R_{m\times n}$ space to $R_{1}$ space".

To wit:

Let us say that there exists an $m\times n$ matrix $A$, and a function $f$ that maps $R_{m\times n}$ space to $R_{m}$ space. In this case, such a function $f$ can be an $n\times 1$ vector $v$. Thus, to apply the function, we have simply:

$$f(A_{m\times n}) = A_{m\times n}v_{n\times 1} =b_{m\times 1}$$

So here, the function $f$ is the vector $v$.

My question is when we read the statement "The linear function $f$ maps the $R_{m\times n}$ space to $R_{1}$ space", (scalar), then what is an example of this function? It cant be just a vector or just a matrix, so what does it look like? I realize we can do $v^{T}Av$ if $A$ is a square, and this will give a scalar, but what is the function here?

Thanks

A linear function from ${\mathbb R}^{m \times n}$ to $\mathbb R$ can be written in the form $f(A) = \text{Tr}(A B)$ where $B \in {\mathbb R}^{n \times m}$ and $\text{Tr}$ means trace.

• Ah! Thanks! Yes that makes sense... and as @MattPressland is saying, this transformation need not always be this 'neat'... I guess what was confusing me was that in mapping of spaces, I thought that they had to be 'neat', but they need not be it seems... May 7, 2012 at 16:33
• This answer contains the crucial word "linear", which puts more restrictions on what kinds of functions are allowed. This rules out the kinds of crazy things I was referring to (which is certainly a good thing), but also rules out the determinant as well. (It's also a very cool result that I didn't know, thanks Robert!)
– mdp
May 7, 2012 at 16:40
• @MattPressland Ah yes, shoot. I mistakenly omitted 'linear' although this is what I am after. >< . I have edited the question, but yes, I meant linear all along. May 7, 2012 at 16:49
• @Mohammad No problem - normally I would have assumed that, but I was a little uncomfortable about throwing the determinant away!
– mdp
May 7, 2012 at 16:51

A function is just a set of rules for generating a single output (injective), given a certain input. You don't have to be able to write in down in an explicit way.

A classic example for a function that takes a matrix and outputs a scalar is the determinant, which is a perfectly good (and very useful) function.

• I know what a function is. :-) What I mean is how would you write the function that maps $R_{mxn}$ space to $R_{1}$ space? May 7, 2012 at 16:21
• I don't think you meant to say injective there.
– mdp
May 7, 2012 at 16:21
• @Mohammad Which function? There are infinitely many.
– mdp
May 7, 2012 at 16:21
• Well, @nbubis did, the determinant. But not all functions are that nice. If you don't put any restrictions on the function, it could assign elements of $R_1$ to the matrices in $R_{m\times n}$ seemingly at random, and have no neat closed form at all (this could happen whenever the domain is infinite).
– mdp
May 7, 2012 at 16:27
• @Spacey "I know what a function is. :-)" Honestly, that's not clear from your comments. After reading the comments to the various excellent answers you got, I had to read the OP again to understand what you are looking for. It seems that you absolutely want to identify a function from $R_{m\times n}$ into $R_k$ to some other mathematical object (vector, matrix, etc), so it seems to me you are not comfortable with the general notion of functions (a relation with special properties). Feb 21 at 23:31

If you remove the specification "linear" (as in the original formulation of the question), then there are many functions you might consider. A function to $\mathbb R$ is just a way of assigning a member of $\mathbb R$ (i.e. a Real Number) to each matrix.

This could be done at random, for example, but the functions of interest tend to be more regular. You could send each matrix to the number in the top left-hand corner, for example (normally position 1,1) - actually that function, and the others which send the matrix to the numbers in other positions pretty much underlie all that we do with matrices: so much so that we forget the functions exist.

You can make other functions out of multiple elements - the sum of all the elements would be one, for example, or the sum or product of a particular row or column. Again there are functions which are more interesting because they encapsulate features of the matrix which allow analysis or classification. Particularly important are ones which are unchanged when the basis of the underlying space is changed. As well as the Determinant and Trace, there is the Rank, for example. (See comments below too)

• Thank you Mark. I have edited the question to be more specific, (I was talking about linear functions only but forgot to mention that). If you need to edit your answer please do, much appreciated. May 7, 2012 at 19:00
• Well, mine are not all linear (given the change), but things like individual elements or sums of elements are special cases of the Tr(AB) construction in Robert Israel's answer. His construction gives all linear combinations of all the $mn$ numbers in the original matrix. I'll leave the answer much as it is. May 7, 2012 at 19:58
• Ok, just making sure, thanks. May 7, 2012 at 20:20

Your statement "$$f$$ is the vector $$v$$" is incorrect. I understand you want to emphasize how $$f$$ completely depends on $$v$$ (and you can denote it as $$f_v$$ as such), but $$f$$ is still a function, not a vector.

Therefore, using your notation, $$f_v:R_{m\times n}\longrightarrow R_m$$ is a function such that $$f_v(A_{m\times n})=A_{m\times n}\cdot v_{n\times 1}\in R_{m\times 1}$$. This is an example of a linear mapping from $$R_{m\times n}$$ to $$R_{m\times 1}$$.

One common linear mapping from $$R_{n\times n}$$ to $$R_{1}$$ is the trace function $$Tr: R_{n\times n}\longrightarrow R_1$$ defined by $$Tr(A_{n\times n})=\sum_{i=1}^n a_{ii},$$ for any squared matrix $$A_{n\times n}$$, and for an arbitrary matrix $$A_{m\times n}$$ the dot product $$Tr(AA^T)=Tr(A^TA)$$ can be used, however, it is a non-linear mapping from $$R_{m\times n}$$ to $$R_1$$.

Lastly, for some matrix $$A_{m\times n}$$ and (column) vectors $$u_{m\times 1}$$, and $$v_{n\times 1}$$, a mapping $$f_{u,v}:R_{m\times n}\longrightarrow R_1$$ defined as $$f_{u,v}(A_{m\times n})= u_{m\times 1}^T\cdot A_{m\times n} \cdot v_{n\times 1}$$ is a classic example of linear mapping. It's often presented in a dot product form $$(A_{m\times n} \cdot v_{n\times 1}|u_{m\times 1})$$.

NOTE: You should be more precise in your statements. For instance, saying "The linear function $$f$$ maps the $$R_{m\times n}$$ space to $$R_1$$ space" implies that $$f$$ is at least surjective. I believe you mean either

• a mapping from $$R_{m\times n}$$ space to $$R_1$$ space, or
• $$f$$ maps elements of $$R_{m\times n}$$ space to elements in $$R_1$$ space (or something similar).