Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Example: I have a matrix $R = \left( \begin{array}{cc} A & \mathbf{t} \\ 0 & 1 \end{array} \right) $ where $A$ is 3-by-3 and $\mathbf{t}$ is 3 by 1. Or in Mathematica


I would like to be able to use a form of block matrix notation / entry and subsequently find the inverse of R.

Question: Is this possible?

share|improve this question
up vote 34 down vote accepted

You're looking for ArrayFlatten. For your example matrices,

 R = ArrayFlatten[ {{A, {t}\[Transpose]},{0, 1}} ]
 => {{1, 0, 0, 1}, {0, 0, 1, 1}, {0, -1, 0, 1}, {0, 0, 0, 1}}

The construct {t}\[Transpose] is necessary for ArrayFlatten to treat t as a column matrix.

Mathematica graphics

Then to find $\boldsymbol{R}^{-1}$, you run

=> {{1, 0, 0, -1}, {0, 0, -1, 1}, {0, 1, 0, -1}, {0, 0, 0, 1}}
share|improve this answer
beat me by 5s... – acl Jan 26 '12 at 16:25
He was also asking for the inverse - could add this for completeness. – Vitaliy Kaurov Jan 26 '12 at 16:31
@VitaliyKaurov, done! – rcollyer Jan 26 '12 at 16:36
@acl, it's a testament to how much we've been waiting for these types of questions when 3 of the top users jump on it within seconds of each other. – rcollyer Jan 26 '12 at 16:38
This point about {t}\[Transpose] being necessary is important and subtle: Mathematica (to its credit) does NOT finesse the fact that vectors must be either 1 x n or n x 1 matrices, that is, explicitly either row or column vectors. Pretty much everything else (including my beloved Golub & VanLoan) does (tho G&VL have the grace at least to say they do). I find the conceptual hygiene forced by Mathematica to be refreshing and helpful. – Reb.Cabin Jul 27 '14 at 17:32

The keyboard commands Ctrl+Enter, Ctrl+, and Tab can be used to enter this format.

You can also use the menu Insert > Table/Matrix to create a table of specified size with placeholders.

See Entering Tables and Matrices.

Depending on the meaning of the question, this may have some bearing:

Mathematica graphics

share|improve this answer
beat you to it. :P – rcollyer Jan 26 '12 at 16:23
LOL at the pity vote. – Mr.Wizard Jan 26 '12 at 16:27
I meant, I beat you to posting the "correct" answer. Although, I posted the result he wanted, and you posted the entry method. Win for both of us. – rcollyer Jan 26 '12 at 16:28
Not a pity vote. If you don't post this, I would have edited it into @rcollyer's answer. It's much more convenient to enter matrices like this (see my screenshot). – Szabolcs Jan 26 '12 at 16:29
@rcollyer Recently I saw someone give input to NDSolve that way, and I really liked it --> – Szabolcs Jan 26 '12 at 16:47

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.