9

I'm trying to show that matrix A (m rows, n columns) times matrix B(n rows, k columns), results as matrix C ( m rows, k columns).

enter image description here

I wonder what's the easier way to write it?

there are several posts here, I found Block matrix equation with dimensioning and Equation with Large Matrix Dimension a bit too complex, while Matrix decomposition dimensions diagram put the dimensions at the bottom of the matrix, while I hope this can be displayed on the left and top.

3
  • @Brian yes. I only know how to put subtext on top-right, top-bottom, top-left, bottom-left corner, but don't know how to put things on top, left, right or bottom.
    – athos
    Commented Aug 5, 2014 at 4:00
  • 1
    Why do you want create confusions when things can be simple and neat? Commented Aug 5, 2014 at 6:02
  • 1
    I have some experience with linear algebra teaching that, other than showing rectangles with rows and vectors inside them, nothing is illustrative/explanatory. They just create more confusion or state the obvious; People know how to multiply already know it, people who don't know it won't get it with notations.
    – percusse
    Commented Aug 5, 2014 at 10:42

5 Answers 5

15

I would suggest writing something more traditional and clear:

enter image description here

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\[
  \underset{(m \times n)}{A} \times \underset{(n \times k)}{B} =
    \underset{(m \times k)}{C}
\]
\end{document}
2
  • after comparison, I agree, this notation is much better. Thanks!
    – athos
    Commented Aug 5, 2014 at 6:27
  • 8
    I would suggest not using \times between A and B, as the symbol is never used in this context.
    – egreg
    Commented Aug 5, 2014 at 9:32
5

You could use the following code -- note the use of positive thinspace (\,) and negative thinspace (\!) to finetune the position of the side-set and supra-set items.

\documentclass{article}
\usepackage{amsmath}
\begin{document}
$ {}^m\!\overset{\,n}{A} \, {}^n\!\overset{\,k}{B} = {}^m  \overset{\,k}{C} $
\end{document}

enter image description here

4

A variation of Mico's solution, that's less obtrusive.

The height of the two small superscripts can be changed with an optional argument, in case of need:

\rowcol[<height>]{<matrix>}{<rows>}{<columns>}

\documentclass{article}

\newcommand{\rowcol}[4][2ex]{%
  \raisebox{#1}{\vtop{
    \tiny
    \ialign{%
      &##\cr
      &\rlap{$\,#4$}\cr
      \noalign{\nointerlineskip}
      $#3\!$\cr
    }
  }}
  #2
}

\begin{document}
\[
\rowcol{A}{m}{n}\cdot\rowcol{B}{n}{k}=\rowcol{C}{m}{k}
\]
\end{document}

enter image description here

1

For a subscript to be put on the top of a given symbol one uses \overset{}{}, where the first blank is to be replaced with the intended subscript and the second blank is to be replaced with the given symbol.

For subscripts to be put on the left or right of a given symbol you may refer to the question here: Left and right subscript / superscript

Hope these helpful.

2
  • Sorry the description is not clear. I just updated the question with a picture.
    – athos
    Commented Aug 5, 2014 at 3:51
  • Never mind. So do you mean you wish to know the codes for displaying what the picture shows? If so then the revised answer works.
    – Yes
    Commented Aug 5, 2014 at 4:00
1

Another suggestion:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\[
  A_{m \times n} B_{n \times k} = C_{m \times k}
\]
\end{document}

enter image description here

EDIT: Or you can simply declare the matrices

enter image description here

and then AB = C. This notation is used, for example, in Golub, Van Loan, "Matrix Computation", 3rd Ed. Johns Hopkins, 1996.

2
  • How is the suggestion in the edit a decleration of the matirces? You only declare the spaces they are elements in. Commented Jan 15, 2015 at 7:11
  • You are formally correct. My suggestion in the edit may be complemented by definition on page 3 of the cited reference. Thank you for your observation.
    – user13907
    Commented Jan 15, 2015 at 9:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .