Search for all pages containing Transpose
Transpose
✖
Transpose

transposes list so that the k level in list is the nk
level in the result.
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 r≥3, 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,m↔n] or Transpose[a,TwoWayRule[m,n]] is equivalent to Transpose[a,Cycles[{{m,n}}]]. »
- Transpose[a,k] is equivalent to Transpose[a,RotateLeft[Range[n],k]], where n is the depth of a.
- 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.
Examples
open allclose allBasic Examples (3)Summary of the most common use cases
Transpose a 3×3 numerical matrix:

https://wolfram.com/xid/0y79sq-osbj2l

Visualize the transposition operation:

https://wolfram.com/xid/0y79sq-z37lk9

Transpose a 2×3 symbolic matrix:

https://wolfram.com/xid/0y79sq-cmu3xg

Use followed by
tr
to enter the transposition operator:

https://wolfram.com/xid/0y79sq-gsihc9

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

https://wolfram.com/xid/0y79sq-1r0nsm

Transpose the matrix and format the result:

https://wolfram.com/xid/0y79sq-cf9

Transpose a row matrix into a column matrix:

https://wolfram.com/xid/0y79sq-y9swck


https://wolfram.com/xid/0y79sq-4t8hxs

Transpose the column matrix back into a row matrix:

https://wolfram.com/xid/0y79sq-j4hiab

Transposition of a vector leaves it unchanged:

https://wolfram.com/xid/0y79sq-ueddlw

Transpose leaves the identity matrix unchanged:

https://wolfram.com/xid/0y79sq-m3qwhc


https://wolfram.com/xid/0y79sq-etj8hr

Transpose[s] is also sparse:

https://wolfram.com/xid/0y79sq-c5q1l0

The indices have, in effect, just been reversed:

https://wolfram.com/xid/0y79sq-we4i

Transpose a SymmetrizedArray object:

https://wolfram.com/xid/0y79sq-82qm3u


https://wolfram.com/xid/0y79sq-civx75

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

https://wolfram.com/xid/0y79sq-de2mnu

Format a symbolic transpose in TraditionalForm:

https://wolfram.com/xid/0y79sq-2n9c1h

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

https://wolfram.com/xid/0y79sq-7ufmlr


https://wolfram.com/xid/0y79sq-g6xbi9

Transpose an array of depth 3 using different permutations:

https://wolfram.com/xid/0y79sq-c0m95j


https://wolfram.com/xid/0y79sq-c1s5kt


https://wolfram.com/xid/0y79sq-b4b2ee


https://wolfram.com/xid/0y79sq-bsd5eg

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

https://wolfram.com/xid/0y79sq-bhq8zt

https://wolfram.com/xid/0y79sq-ozihc


https://wolfram.com/xid/0y79sq-b5uqki

Perform transpositions using TwoWayRule notation:

https://wolfram.com/xid/0y79sq-2qfhhd

https://wolfram.com/xid/0y79sq-cm8eb6


https://wolfram.com/xid/0y79sq-8abywv

Perform transpositions using Cycles notation:

https://wolfram.com/xid/0y79sq-ic0rgo

https://wolfram.com/xid/0y79sq-hj83dw


https://wolfram.com/xid/0y79sq-ucg10e

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

https://wolfram.com/xid/0y79sq-c5c0ih


https://wolfram.com/xid/0y79sq-jc5no1

The second and third dimensions have been exchanged:

https://wolfram.com/xid/0y79sq-mwakei

Get the leading diagonal by transposing two identical levels:

https://wolfram.com/xid/0y79sq-d5uow8

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

https://wolfram.com/xid/0y79sq-gvyftk
Find the QRDecomposition of :

https://wolfram.com/xid/0y79sq-duooxk
is orthogonal, so its inverse is
:

https://wolfram.com/xid/0y79sq-iai3qt

Reconstruct from the decomposition:

https://wolfram.com/xid/0y79sq-krsa32

Compute the SchurDecomposition of a matrix :

https://wolfram.com/xid/0y79sq-r0ajyn

https://wolfram.com/xid/0y79sq-1az2es
The matrix is orthogonal, so its inverse is
:

https://wolfram.com/xid/0y79sq-exoan3

Reconstruct from the decomposition:

https://wolfram.com/xid/0y79sq-fcownu

Compute the SingularValueDecomposition of a matrix :

https://wolfram.com/xid/0y79sq-djlrlp

https://wolfram.com/xid/0y79sq-haka0j
The matrices and
are orthogonal, so their inverses are their transposes:

https://wolfram.com/xid/0y79sq-zommsn

Reconstruct from the decomposition:

https://wolfram.com/xid/0y79sq-iq478f

Construct the singular value decomposition of , a random
matrix:

https://wolfram.com/xid/0y79sq-id0tma
First compute the eigensystem of :

https://wolfram.com/xid/0y79sq-x65cfp
The singular values are the square roots of the nonzero eigenvalues:

https://wolfram.com/xid/0y79sq-mshm4f

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

https://wolfram.com/xid/0y79sq-9jahvl

The matrix has the eigenvectors as its columns:

https://wolfram.com/xid/0y79sq-qp01lu
The matrix has columns of the form
for each of the nonzero eigenvalues:

https://wolfram.com/xid/0y79sq-qrh82h
Verify that and
are orthogonal:

https://wolfram.com/xid/0y79sq-eai6rd


https://wolfram.com/xid/0y79sq-q876ri


https://wolfram.com/xid/0y79sq-zdl8rk

Special Matrices (6)
A symmetric matrix obeys , an antisymmetric matrix
. This matrix is symmetric:

https://wolfram.com/xid/0y79sq-t2jxdg

https://wolfram.com/xid/0y79sq-zp2lyx

Confirm with SymmetricMatrixQ:

https://wolfram.com/xid/0y79sq-wcmgtr


https://wolfram.com/xid/0y79sq-2k6v81

https://wolfram.com/xid/0y79sq-ihaql5

Confirm with AntisymmetricMatrixQ:

https://wolfram.com/xid/0y79sq-nuu23a

A matrix is orthogonal if . Check if the matrix
is orthogonal:

https://wolfram.com/xid/0y79sq-9ntar2

https://wolfram.com/xid/0y79sq-5yg2s8

Confirm that it is orthogonal using OrthogonalMatrixQ:

https://wolfram.com/xid/0y79sq-23cqdz

A real-valued symmetric matrix is orthogonally diagonalizable as , with
diagonal and real valued and
orthogonal. Verify that the following matrix is symmetric and then diagonalize it:

https://wolfram.com/xid/0y79sq-f7taoa


https://wolfram.com/xid/0y79sq-tcctdb

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

https://wolfram.com/xid/0y79sq-dfmnfg

Next, compute the unit eigenvectors:

https://wolfram.com/xid/0y79sq-3qxvbq

Then can be diagonalized with
as previously, and
:

https://wolfram.com/xid/0y79sq-uh3v2b

A matrix is unitary if . Show that the matrix
is unitary:

https://wolfram.com/xid/0y79sq-x4lsbu

https://wolfram.com/xid/0y79sq-iy9g94

Confirm with UnitaryMatrixQ:

https://wolfram.com/xid/0y79sq-qvribd

A real-valued matrix is called normal if
. Normal matrices are the most general kind of matrix that can be unitarily diagonalized as
with
diagonal and
unitary. All real symmetric matrices
are normal because both sides of the equality are simply
:

https://wolfram.com/xid/0y79sq-308r90

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

https://wolfram.com/xid/0y79sq-1z1cmi


https://wolfram.com/xid/0y79sq-djw0no

Confirm using NormalMatrixQ:

https://wolfram.com/xid/0y79sq-bwszq4

A normal matrix like can be unitarily diagonalized using Eigensystem:

https://wolfram.com/xid/0y79sq-4dicrg

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

https://wolfram.com/xid/0y79sq-9o36nv

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

https://wolfram.com/xid/0y79sq-3e7oay


https://wolfram.com/xid/0y79sq-yo7dmh

Show that real antisymmetric matrices and orthogonal matrices are normal and thus can be unitarily diagonalized. For orthogonal matrices, simply substitute in the definition to get the identity matrix on both sides:

https://wolfram.com/xid/0y79sq-7uiuk4

For an antisymmetric matrix, both sides are simply :

https://wolfram.com/xid/0y79sq-59rysv

Orthogonal matrices have eigenvalues that lie on the unit circle:

https://wolfram.com/xid/0y79sq-gptb40


https://wolfram.com/xid/0y79sq-8vok8u

Antisymmetric matrices have pure imaginary eigenvalues:

https://wolfram.com/xid/0y79sq-81bsn9


https://wolfram.com/xid/0y79sq-go05yp

Visualization (3)
Use Transpose to change data grouping in BarChart:

https://wolfram.com/xid/0y79sq-g6afgt

https://wolfram.com/xid/0y79sq-ooiam9


https://wolfram.com/xid/0y79sq-szh5xl

Use Transpose to swap the and
axes in ListPlot3D:

https://wolfram.com/xid/0y79sq-76lcdb

https://wolfram.com/xid/0y79sq-eemn3q


https://wolfram.com/xid/0y79sq-zwrpyo

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

https://wolfram.com/xid/0y79sq-3t08fo

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

https://wolfram.com/xid/0y79sq-nir7xh
For example, accumulate at all levels of an array:

https://wolfram.com/xid/0y79sq-19fawm

Reverse at all levels of an array:

https://wolfram.com/xid/0y79sq-y5vtzs


https://wolfram.com/xid/0y79sq-syqpwb

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

https://wolfram.com/xid/0y79sq-xej8a1

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

https://wolfram.com/xid/0y79sq-ppx488

For compatible matrices and
, Transpose obeys
:

https://wolfram.com/xid/0y79sq-076psl

Matrix inversion commutes with Transpose, i.e. :

https://wolfram.com/xid/0y79sq-6xdruj

https://wolfram.com/xid/0y79sq-9mq3tz

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

https://wolfram.com/xid/0y79sq-6b42t5

https://wolfram.com/xid/0y79sq-6mvxiw


https://wolfram.com/xid/0y79sq-qvbgku

Many special matrices are defined by their properties under Transpose. A symmetric matrix has :

https://wolfram.com/xid/0y79sq-wt32yj

An orthogonal matrix satisfies :

https://wolfram.com/xid/0y79sq-ctyb19

The product of a matrix and its transpose is symmetric:

https://wolfram.com/xid/0y79sq-cfw1m2
is the matrix product of
and
:

https://wolfram.com/xid/0y79sq-cve5vk

https://wolfram.com/xid/0y79sq-bp3dws

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

https://wolfram.com/xid/0y79sq-mts4tu

https://wolfram.com/xid/0y79sq-6sdwey

https://wolfram.com/xid/0y79sq-posi16

The difference is antisymmetric:

https://wolfram.com/xid/0y79sq-uu85wz

Transposition of {{}} returns {}:

https://wolfram.com/xid/0y79sq-gub690

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

https://wolfram.com/xid/0y79sq-ba3x3q

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

https://wolfram.com/xid/0y79sq-1s0ige

https://wolfram.com/xid/0y79sq-wducpe

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

https://wolfram.com/xid/0y79sq-7ps8jr

https://wolfram.com/xid/0y79sq-s7odki


https://wolfram.com/xid/0y79sq-5rk4q8


https://wolfram.com/xid/0y79sq-k1xm97

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

https://wolfram.com/xid/0y79sq-gw4grb
Transposing by a permutation σ transposes the element positions by σ-1:

https://wolfram.com/xid/0y79sq-yn6yxw


https://wolfram.com/xid/0y79sq-yxbwon


https://wolfram.com/xid/0y79sq-jr73nv

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

https://wolfram.com/xid/0y79sq-dzu6br

https://wolfram.com/xid/0y79sq-nzg92j

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

https://wolfram.com/xid/0y79sq-snuf7j


https://wolfram.com/xid/0y79sq-7yz8yr

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

https://wolfram.com/xid/0y79sq-iav14f

https://wolfram.com/xid/0y79sq-h95rni

https://wolfram.com/xid/0y79sq-vnag6r

https://wolfram.com/xid/0y79sq-bw6our

Transpositions do not commute, in general:

https://wolfram.com/xid/0y79sq-igs834

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

https://wolfram.com/xid/0y79sq-pz5kvg

https://wolfram.com/xid/0y79sq-mpncfu


https://wolfram.com/xid/0y79sq-zuhyd6

Transpose and TensorTranspose coincide on explicit arrays:

https://wolfram.com/xid/0y79sq-i7svv0

https://wolfram.com/xid/0y79sq-eug4ak

TensorTranspose further supports symbolic operations that Transpose does not:

https://wolfram.com/xid/0y79sq-nk5cyt


https://wolfram.com/xid/0y79sq-0qvuum

Transposition of a matrix can also be performed with Thread:

https://wolfram.com/xid/0y79sq-k3zzck


https://wolfram.com/xid/0y79sq-l8i1lg

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

https://wolfram.com/xid/0y79sq-kyar1f

https://wolfram.com/xid/0y79sq-85it7


https://wolfram.com/xid/0y79sq-mxx54q

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

https://wolfram.com/xid/0y79sq-nn789

https://wolfram.com/xid/0y79sq-qznzbc

Possible Issues (1)Common pitfalls and unexpected behavior
Transpose only works for rectangular arrays:

https://wolfram.com/xid/0y79sq-dga05m


Generalize transposition by padding:

https://wolfram.com/xid/0y79sq-gt2ub0


https://wolfram.com/xid/0y79sq-bu5m7u

Neat Examples (1)Surprising or curious use cases

https://wolfram.com/xid/0y79sq-dk7tdt

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
]}
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
]}