WOLFRAM

Transpose[list]

transposes the first two levels in list.

Transpose[list,{n1,n2,}]

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

Transpose[list,mn]

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

Transpose[list,k]

cycles the levels in list k positions to the right.

Details and Options

Examples

open allclose all

Basic Examples  (3)Summary of the most common use cases

Transpose a 3×3 numerical matrix:

Out[8]=8

Visualize the transposition operation:

Out[11]=11

Transpose a 2×3 symbolic matrix:

Use followed by tr to enter the transposition operator:

Out[1]=1

Scope  (13)Survey of the scope of standard use cases

Matrices  (6)

Enter a matrix as a grid:

Out[1]=1

Transpose the matrix and format the result:

Transpose a row matrix into a column matrix:

Out[1]=1

Format the input and output:

Out[2]=2

Transpose the column matrix back into a row matrix:

Out[3]=3

Transposition of a vector leaves it unchanged:

Out[4]=4

Transpose leaves the identity matrix unchanged:

s is a sparse matrix:

Out[1]=1

Transpose[s] is also sparse:

Out[2]=2

The indices have, in effect, just been reversed:

Out[3]=3

Transpose a SymmetrizedArray object:

Out[1]=1
Out[2]=2

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

Out[3]=3

Format a symbolic transpose in TraditionalForm:

Arrays  (7)

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:

Out[1]=1
Out[2]=2
Out[3]=3
Out[4]=4

Cycle levels of a depth-5 array two positions to the right:

Out[2]=2
Out[3]=3

Perform transpositions using TwoWayRule notation:

Out[2]=2
Out[3]=3

Perform transpositions using Cycles notation:

Out[2]=2
Out[3]=3

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

Out[1]=1
Out[2]=2

The second and third dimensions have been exchanged:

Out[3]=3

Get the leading diagonal by transposing two identical levels:

Out[1]=1

Applications  (13)Sample problems that can be solved with this function

Matrix Decompositions  (4)

is a random real matrix:

Find the QRDecomposition of :

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

Out[3]=3

Reconstruct from the decomposition:

Out[4]=4

Compute the SchurDecomposition of a matrix :

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

Out[3]=3

Reconstruct from the decomposition:

Out[4]=4

Compute the SingularValueDecomposition of a matrix :

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

Out[3]=3

Reconstruct from the decomposition:

Out[4]=4

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:

Out[3]=3

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:

Out[7]=7
Out[8]=8

Verify the decomposition:

Out[9]=9

Special Matrices  (6)

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

Out[2]=2

Confirm with SymmetricMatrixQ:

Out[3]=3

This matrix is antisymmetric:

Out[5]=5

Confirm with AntisymmetricMatrixQ:

Out[6]=6

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

Out[2]=2

Confirm that it is orthogonal using OrthogonalMatrixQ:

Out[3]=3

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:

Out[2]=2

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

Out[3]=3

Next, compute the unit eigenvectors:

Out[4]=4

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

Out[5]=5

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

Out[2]=2

Confirm with UnitaryMatrixQ:

Out[3]=3

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 :

Out[1]=1

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

Out[3]=3

Confirm using NormalMatrixQ:

Out[4]=4

A normal matrix like can be unitarily diagonalized using Eigensystem:

Out[5]=5

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:

Out[7]=7

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

Out[8]=8

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:

Out[1]=1

For an antisymmetric matrix, both sides are simply :

Out[2]=2

Orthogonal matrices have eigenvalues that lie on the unit circle:

Out[3]=3
Out[4]=4

Antisymmetric matrices have pure imaginary eigenvalues:

Out[5]=5
Out[6]=6

Visualization  (3)

Use Transpose to change data grouping in BarChart:

Out[2]=2
Out[3]=3

Use Transpose to swap the and axes in ListPlot3D:

Out[2]=2
Out[3]=3

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

Out[4]=4

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

For example, accumulate at all levels of an array:

Out[2]=2

Reverse at all levels of an array:

Out[3]=3

Import an RGB image:

Out[4]=4

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

Out[5]=5

Properties & Relations  (18)Properties of the function, and connections to other functions

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

Out[2]=2

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

Out[1]=1

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

Out[2]=2

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

Out[2]=2
Out[3]=3

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

Out[1]=1

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

Out[2]=2

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

Out[3]=3

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:

Out[3]=3

The difference is antisymmetric:

Out[4]=4

Transposition of {{}} returns {}:

Out[1]=1

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

Out[2]=2

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

Out[2]=2

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

Out[2]=2
Out[3]=3
Out[4]=4

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

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

Out[2]=2
Out[3]=3
Out[4]=4

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

Out[2]=2

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

Out[3]=3
Out[4]=4

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

Out[4]=4

Transpositions do not commute, in general:

Out[5]=5

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

Out[2]=2
Out[3]=3

Transpose and TensorTranspose coincide on explicit arrays:

Out[2]=2

TensorTranspose further supports symbolic operations that Transpose does not:

Out[3]=3
Out[4]=4

Transposition of a matrix can also be performed with Thread:

Out[1]=1
Out[2]=2

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

Out[2]=2
Out[3]=3

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

Out[2]=2

Possible Issues  (1)Common pitfalls and unexpected behavior

Transpose only works for rectangular arrays:

Out[1]=1

Generalize transposition by padding:

Out[2]=2

Eliminate the padding:

Out[3]=3

Neat Examples  (1)Surprising or curious use cases

Out[1]=1
Wolfram Research (1988), Transpose, Wolfram Language function, https://reference.wolfram.com/language/ref/Transpose.html (updated 2024).
Wolfram Research (1988), Transpose, Wolfram Language function, https://reference.wolfram.com/language/ref/Transpose.html (updated 2024).

Text

Wolfram Research (1988), Transpose, Wolfram Language function, https://reference.wolfram.com/language/ref/Transpose.html (updated 2024).

Wolfram Research (1988), Transpose, Wolfram Language function, https://reference.wolfram.com/language/ref/Transpose.html (updated 2024).

CMS

Wolfram Language. 1988. "Transpose." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2024. https://reference.wolfram.com/language/ref/Transpose.html.

Wolfram Language. 1988. "Transpose." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2024. https://reference.wolfram.com/language/ref/Transpose.html.

APA

Wolfram Language. (1988). Transpose. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Transpose.html

Wolfram Language. (1988). Transpose. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Transpose.html

BibTeX

@misc{reference.wolfram_2025_transpose, author="Wolfram Research", title="{Transpose}", year="2024", howpublished="\url{https://reference.wolfram.com/language/ref/Transpose.html}", note=[Accessed: 31-March-2025 ]}

@misc{reference.wolfram_2025_transpose, author="Wolfram Research", title="{Transpose}", year="2024", howpublished="\url{https://reference.wolfram.com/language/ref/Transpose.html}", note=[Accessed: 31-March-2025 ]}

BibLaTeX

@online{reference.wolfram_2025_transpose, organization={Wolfram Research}, title={Transpose}, year={2024}, url={https://reference.wolfram.com/language/ref/Transpose.html}, note=[Accessed: 31-March-2025 ]}

@online{reference.wolfram_2025_transpose, organization={Wolfram Research}, title={Transpose}, year={2024}, url={https://reference.wolfram.com/language/ref/Transpose.html}, note=[Accessed: 31-March-2025 ]}