transposes the first two levels in list.


transposes list so that the k^(th) level in list is the nk^(th) level in the result.


transposes levels m and n in list, leaving all other levels unchanged.

Details and Options

  • Transpose[m] gives the usual transpose of a matrix m.
  • Transpose[m] can be input as m.
  • can be entered as tr or \[Transpose].
  • For a matrix m, Transpose[m] is equivalent to Transpose[m,{2,1}].
  • For an array a of depth r3, Transpose[a] is equivalent to Transpose[a,{2,1,3,,r}], only transposing the first two levels. »
  • The ni in Transpose[a,{n1,n2,}] or Transpose[a,n1n2] must be positive integers no larger than ArrayDepth[a].
  • If {n1,n2,} is a permutation list, then the element at position {i1,i2,} of Transpose[a,{n1,n2,}] is the element at position {in1,in2,} of the array a.
  • For a permutation perm, the dimensions of Transpose[a,perm] are Permute[Dimensions[a],perm].
  • A permutation list perm in Transpose[a,perm] can also be given in Cycles form, as returned by PermutationCycles[perm]. »
  • Transpose[a,mn] or Transpose[a,TwoWayRule[m,n]] is equivalent to Transpose[a,Cycles[{{m,n}}]]. »
  • Transpose allows the ni to be repeated, computing diagonals of the subarrays determined by the repeated levels. The result is therefore an array of smaller depth.
  • For a square matrix m, Transpose[m,{1,1}] returns the main diagonal of m, as given by Diagonal[m]. »
  • In general, if np=nq then the operation Transpose[a,{n1,n2,}] is possible for an array a of dimensions {d1,d2,} if dp=dq.
  • Transpose works on SparseArray and structured array objects.


open allclose all

Basic Examples  (3)

Transpose a 3×3 numerical matrix:

Visualize the transposition operation:

Transpose a 2×3 symbolic matrix:

Use followed by tr to enter the transposition operator:

Scope  (12)

Matrices  (6)

Enter a matrix as a grid:

Transpose the matrix and format the result:

Transpose a row matrix into a column matrix:

Format the input and output:

Transpose the column matrix back into a row matrix:

Transposition of a vector leaves it unchanged:

Transpose leaves the identity matrix unchanged:

s is a sparse matrix:

Transpose[s] is also sparse:

The indices have, in effect, just been reversed:

Transpose a SymmetrizedArray object:

The result equals the negative of the original array, due to its antisymmetry:

Format a symbolic transpose in TraditionalForm:

Arrays  (6)

Transpose the first two levels of a rank-3 array, effectively transposing it as a matrix of vectors:

Transpose an array of depth 3 using different permutations:

Perform transpositions using TwoWayRule notation:

Perform transpositions using Cycles notation:

Transpose levels 2 and 3 of a depth-4 array:

The second and third dimensions have been exchanged:

Get the leading diagonal by transposing two identical levels:

Applications  (13)

Matrix Decompositions  (4)

is a random real matrix:

Find the QRDecomposition of :

is orthogonal, so its inverse is TemplateBox[{q}, Transpose]:

Reconstruct from the decomposition:

Compute the SchurDecomposition of a matrix :

The matrix is orthogonal, so its inverse is TemplateBox[{q}, Transpose]:

Reconstruct from the decomposition:

Compute the SingularValueDecomposition of a matrix :

The matrices and are orthogonal, so their inverses are their transposes:

Reconstruct from the decomposition:

Construct the singular value decomposition of , a random matrix:

First compute the eigensystem of TemplateBox[{a}, Transpose].a:

The singular values are the square roots of the nonzero eigenvalues:

The matrix is a diagonal matrix of singular values with the same shape as :

The matrix has the eigenvectors as its columns:

The matrix has columns of the form for each of the nonzero eigenvalues:

Verify that and are orthogonal:

Verify the decomposition:

Special Matrices  (6)

A symmetric matrix obeys s=TemplateBox[{s}, Transpose], an antisymmetric matrix a=-TemplateBox[{a}, Transpose]. This matrix is symmetric:

Confirm with SymmetricMatrixQ:

This matrix is antisymmetric:

Confirm with AntisymmetricMatrixQ:

A matrix is orthogonal if TemplateBox[{o}, Inverse]=TemplateBox[{o}, Transpose]. Check if the matrix is orthogonal:

Confirm that it is orthogonal using OrthogonalMatrixQ:

A real-valued symmetric matrix is orthogonally diagonalizable as s=o.d.TemplateBox[{o}, Transpose], with diagonal and real valued and orthogonal. Verify that the following matrix is symmetric and then diagonalize it:

To diagonalize, first compute 's eigenvalues and place them in a diagonal matrix:

Next, compute the unit eigenvectors:

Then can be diagonalized with as previously, and o=TemplateBox[{v}, Transpose]:

A matrix is unitary if TemplateBox[{u}, Inverse]=TemplateBox[{{(, TemplateBox[{u}, Transpose, SyntaxForm -> SuperscriptBox], )}}, Conjugate]. Show that the matrix is unitary:

Confirm with UnitaryMatrixQ:

A real-valued matrix is called normal if n.TemplateBox[{n}, Transpose]=TemplateBox[{n}, Transpose].n. Normal matrices are the most general kind of matrix that can be unitarily diagonalized as n=u.d.TemplateBox[{{(, TemplateBox[{u}, Transpose, SyntaxForm -> SuperscriptBox], )}}, Conjugate] with diagonal and unitary. All real symmetric matrices are normal because both sides of the equality are simply :

Show that the following matrix is normal and then diagonalize it:

Confirm using NormalMatrixQ:

A normal matrix like can be unitarily diagonalized using Eigensystem:

Unlike the case of a symmetric matrix, the diagonal matrix here is complex valued:

Normalizing the eigenvectors and putting them in columns gives a unitary matrix:

Confirm the diagonalization n=u.d.TemplateBox[{{(, TemplateBox[{u}, Transpose, SyntaxForm -> SuperscriptBox], )}}, Conjugate]:

Show that real antisymmetric matrices and orthogonal matrices are normal and thus can be unitarily diagonalized. For orthogonal matrices, simply substitute in the definition TemplateBox[{o}, Transpose]=TemplateBox[{o}, Inverse] to get the identity matrix on both sides:

For an antisymmetric matrix, both sides are simply :

Orthogonal matrices have eigenvalues that lie on the unit circle:

Antisymmetric matrices have pure imaginary eigenvalues:

Visualization  (3)

Use Transpose to change data grouping in BarChart:

Use Transpose to swap the and axes in ListPlot3D:

This has the effect of reflecting the data across the line :

Multidimensionalize (in the tensor product sense) a one-dimensional list command:

For example, accumulate at all levels of an array:

Reverse at all levels of an array:

Import an RGB image:

Reverse the data at all levels, reflecting across the line and swapping red and blue channels:

Properties & Relations  (18)

Transpose obeys TemplateBox[{{(, TemplateBox[{A}, Transpose, SyntaxForm -> SuperscriptBox], )}}, Transpose]=A:

For compatible matrices and , Transpose obeys TemplateBox[{{(, {a, ., b}, )}}, Transpose]=TemplateBox[{b}, Transpose].TemplateBox[{a}, Transpose]:

Matrix inversion commutes with Transpose, i.e. TemplateBox[{{(, TemplateBox[{a}, Transpose], )}}, Inverse]=TemplateBox[{{(, TemplateBox[{a}, Inverse], )}}, Transpose]:

Conjugate[Transpose[m]] can be done in a single step with ConjugateTranspose:

Many special matrices are defined by their properties under Transpose. A symmetric matrix has TemplateBox[{s}, Transpose]=s:

An orthogonal matrix satisfies TemplateBox[{o}, Transpose]=TemplateBox[{o}, Inverse]:

The product of a matrix and its transpose is symmetric:

is the matrix product of and :

TemplateBox[{s}, Transpose]=TemplateBox[{{(, {TemplateBox[{m}, Transpose], ., m}, )}}, Transpose]=TemplateBox[{m}, Transpose].TemplateBox[{{(, TemplateBox[{m}, Transpose, SyntaxForm -> SuperscriptBox], )}}, Transpose]=TemplateBox[{m}, Transpose]m=s, so is symmetric

The sum of a square matrix and its transpose is symmetric:

is the matrix sum of and TemplateBox[{m}, Transpose]:

TemplateBox[{s}, Transpose]=TemplateBox[{{(, {TemplateBox[{m}, Transpose, SyntaxForm -> SuperscriptBox], +, m}, )}}, Transpose]=TemplateBox[{m}, Transpose]+TemplateBox[{{(, TemplateBox[{m}, Transpose, SyntaxForm -> SuperscriptBox], )}}, Transpose]=TemplateBox[{m}, Transpose]+m=s, so is symmetric:

The difference is antisymmetric:

Transposition of {{}} returns {}:

The result cannot be {{}} again because the permutation of the dimensions {1,0} is {0,1} and no expression can have dimensions {0,1}:

Transpose[a] transposes the first two levels of an array:

Transpose[a,perm] returns an array of dimensions Permute[Dimensions[a],perm]:

Take an array with dimensions {2,3,4}:

Transposing by a permutation σ transposes the element positions by σ-1:

Transpose[a,Cycles[{{m,n}}]] and Transpose[a,mn] are equivalent:

Both forms are equivalent to using PermutationList[Cycles[{{m,n}}]:

Composition of transpositions is equivalent to a product of their permutations, in the same order:

Transpositions do not commute, in general:

Transpose[a,σ] is equivalent to Flatten[a,List/@InversePermutation[σ]]:

Transpose and TensorTranspose coincide on explicit arrays:

TensorTranspose further supports symbolic operations that Transpose does not:

Transposition of a matrix can also be performed with Thread:

Transpose[m,{1,1}] is equivalent to Diagonal[m]:

Transpose[a,{1,,1,2,3,}] is equivalent to tracing the levels being transposed to level 1:

Possible Issues  (1)

Transpose only works for rectangular arrays:

Generalize transposition by padding:

Eliminate the padding:

Neat Examples  (1)

Wolfram Research (1988), Transpose, Wolfram Language function, (updated 2017).


Wolfram Research (1988), Transpose, Wolfram Language function, (updated 2017).


Wolfram Language. 1988. "Transpose." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2017.


Wolfram Language. (1988). Transpose. Wolfram Language & System Documentation Center. Retrieved from


@misc{reference.wolfram_2024_transpose, author="Wolfram Research", title="{Transpose}", year="2017", howpublished="\url{}", note=[Accessed: 17-July-2024 ]}


@online{reference.wolfram_2024_transpose, organization={Wolfram Research}, title={Transpose}, year={2017}, url={}, note=[Accessed: 17-July-2024 ]}