Products
  • Wolfram|One

    The definitive Wolfram Language and notebook experience

  • Mathematica

    The original technical computing environment

  • Notebook Assistant + LLM Kit

    All-in-one AI assistance for your Wolfram experience

  • Compute Services
  • System Modeler
  • Finance Platform
  • Wolfram|Alpha Notebook Edition
  • Application Server
  • Enterprise Private Cloud
  • Wolfram Engine
  • Wolfram Player
  • Wolfram Cloud App
  • Wolfram Player App

More mobile apps

Core Technologies of Wolfram Products

  • Wolfram Language
  • Computable Data
  • Wolfram Notebooks
  • AI & Linguistic Understanding

Deployment Options

  • Wolfram Cloud
  • wolframscript
  • Wolfram Engine Community Edition
  • Wolfram LLM API
  • WSTPServer
  • Wolfram|Alpha APIs

From the Community

  • Function Repository
  • Community Paclet Repository
  • Example Repository
  • Neural Net Repository
  • Prompt Repository
  • Wolfram Demonstrations
  • Data Repository
  • Group & Organizational Licensing
  • All Products
Consulting & Solutions

We deliver solutions for the AI era—combining symbolic computation, data-driven insights and deep technical expertise

  • Data & Computational Intelligence
  • Model-Based Design
  • Algorithm Development
  • Wolfram|Alpha for Business
  • Blockchain Technology
  • Education Technology
  • Quantum Computation

Wolfram Consulting

Wolfram Solutions

  • Data Science
  • Artificial Intelligence
  • Biosciences
  • Healthcare Intelligence
  • Sustainable Energy
  • Control Systems
  • Enterprise Wolfram|Alpha
  • Blockchain Labs

More Wolfram Solutions

Wolfram Solutions For Education

  • Research Universities
  • Colleges & Teaching Universities
  • Junior & Community Colleges
  • High Schools
  • Educational Technology
  • Computer-Based Math

More Solutions for Education

  • Contact Us
Learning & Support

Get Started

  • Wolfram Language Introduction
  • Fast Intro for Programmers
  • Fast Intro for Math Students
  • Wolfram Language Documentation

More Learning

  • Highlighted Core Areas
  • Demonstrations
  • YouTube
  • Daily Study Groups
  • Wolfram Schools and Programs
  • Books

Grow Your Skills

  • Wolfram U

    Courses in computing, science, life and more

  • Community

    Learn, solve problems and share ideas.

  • Blog

    News, views and insights from Wolfram

  • Resources for

    Software Developers

Tech Support

  • Contact Us
  • Support FAQs
  • Support FAQs
  • Contact Us
Company
  • About Wolfram
  • Career Center
  • All Sites & Resources
  • Connect & Follow
  • Contact Us

Work with Us

  • Student Ambassador Initiative
  • Wolfram for Startups
  • Student Opportunities
  • Jobs Using Wolfram Language

Educational Programs for Adults

  • Summer School
  • Winter School

Educational Programs for Youth

  • Middle School Camp
  • High School Research Program
  • Computational Adventures

Read

  • Stephen Wolfram's Writings
  • Wolfram Blog
  • Wolfram Tech | Books
  • Wolfram Media
  • Complex Systems

Educational Resources

  • Wolfram MathWorld
  • Wolfram in STEM/STEAM
  • Wolfram Challenges
  • Wolfram Problem Generator

Wolfram Initiatives

  • Wolfram Science
  • Wolfram Foundation
  • History of Mathematics Project

Events

  • Stephen Wolfram Livestreams
  • Online & In-Person Events
  • Contact Us
  • Connect & Follow
Wolfram|Alpha
  • Your Account
  • User Portal
  • Wolfram Cloud
  • Products
    • Wolfram|One
    • Mathematica
    • Notebook Assistant + LLM Kit
    • Compute Services
    • System Modeler
    • Finance Platform
    • Wolfram|Alpha Notebook Edition
    • Application Server
    • Enterprise Private Cloud
    • Wolfram Engine
    • Wolfram Player
    • Wolfram Cloud App
    • Wolfram Player App

    More mobile apps

    • Core Technologies
      • Wolfram Language
      • Computable Data
      • Wolfram Notebooks
      • AI & Linguistic Understanding
    • Deployment Options
      • Wolfram Cloud
      • wolframscript
      • Wolfram Engine Community Edition
      • Wolfram LLM API
      • WSTPServer
      • Wolfram|Alpha APIs
    • From the Community
      • Function Repository
      • Community Paclet Repository
      • Example Repository
      • Neural Net Repository
      • Prompt Repository
      • Wolfram Demonstrations
      • Data Repository
    • Group & Organizational Licensing
    • All Products
  • Consulting & Solutions

    We deliver solutions for the AI era—combining symbolic computation, data-driven insights and deep technical expertise

    WolframConsulting.com

    Wolfram Solutions

    • Data Science
    • Artificial Intelligence
    • Biosciences
    • Healthcare Intelligence
    • Sustainable Energy
    • Control Systems
    • Enterprise Wolfram|Alpha
    • Blockchain Labs

    More Wolfram Solutions

    Wolfram Solutions For Education

    • Research Universities
    • Colleges & Teaching Universities
    • Junior & Community Colleges
    • High Schools
    • Educational Technology
    • Computer-Based Math

    More Solutions for Education

    • Contact Us
  • Learning & Support

    Get Started

    • Wolfram Language Introduction
    • Fast Intro for Programmers
    • Fast Intro for Math Students
    • Wolfram Language Documentation

    Grow Your Skills

    • Wolfram U

      Courses in computing, science, life and more

    • Community

      Learn, solve problems and share ideas.

    • Blog

      News, views and insights from Wolfram

    • Resources for

      Software Developers
    • Tech Support
      • Contact Us
      • Support FAQs
    • More Learning
      • Highlighted Core Areas
      • Demonstrations
      • YouTube
      • Daily Study Groups
      • Wolfram Schools and Programs
      • Books
    • Support FAQs
    • Contact Us
  • Company
    • About Wolfram
    • Career Center
    • All Sites & Resources
    • Connect & Follow
    • Contact Us

    Work with Us

    • Student Ambassador Initiative
    • Wolfram for Startups
    • Student Opportunities
    • Jobs Using Wolfram Language

    Educational Programs for Adults

    • Summer School
    • Winter School

    Educational Programs for Youth

    • Middle School Camp
    • High School Research Program
    • Computational Adventures

    Read

    • Stephen Wolfram's Writings
    • Wolfram Blog
    • Wolfram Tech | Books
    • Wolfram Media
    • Complex Systems
    • Educational Resources
      • Wolfram MathWorld
      • Wolfram in STEM/STEAM
      • Wolfram Challenges
      • Wolfram Problem Generator
    • Wolfram Initiatives
      • Wolfram Science
      • Wolfram Foundation
      • History of Mathematics Project
    • Events
      • Stephen Wolfram Livestreams
      • Online & In-Person Events
    • Contact Us
    • Connect & Follow
  • Wolfram|Alpha
  • Wolfram Cloud
  • Your Account
  • User Portal
Wolfram Language & System Documentation Center
Permutations
TECH NOTE

Permutations

Representation of a PermutationProduct of Permutations
Permutation Action and SupportEquality and Sorting of Permutations
Permute Parts of an ExpressionSpecial Types of Permutations
Permutations are basic elements in algebra. They have a natural non-commutative product (as matrices do as well), and hence can encode highly nontrivial structures in a compact way. Permutations provide a way of representing any finite group, which makes them key tools in many applications in mathematics, science, engineering, or even art. In particular, permutations play a central role in the description of discrete symmetries.
Permutations are, roughly speaking, reorderings of a set of elements, or more precisely, bijections from the set onto itself. Only sets with a finite number of elements will be considered. The number of possible permutations of a set of elements is , and therefore for a moderate number there are already permutations, which is almost .
This tutorial discusses how to manipulate permutations in cyclic notation in the Wolfram Language, and "Permutation Lists" describes the relation to permutation list notation. Other tutorials, "Permutation Groups" and "Named Groups", describe how to work with groups of permutations, and "Group Theory Algorithms" shows how to extract information from them without listing all elements of the group.
Representation of a Permutation
Cycles
head denoting a permutation in disjoint cyclic form
PermutationCyclesQ
validate a permutation
Representation of a permutation.
The disjoint cyclic representation of a permutation has the form Cycles[{cyc1,cyc2,…}] in the Wolfram Language, where the cycles cyci are disjoint lists of positive integers. Integers are mapped under the permutation to their right neighbors, and the last integer of a cycle is mapped to the first member of that cycle. Integers not present in the cycles are mapped onto themselves, though they could also appear in cycles of length 1, which are called singletons or fixed points. The ordering of cycles is immaterial, and individual cycles can be rotated without changing the permutation. Permutations are automatically canonicalized so that the smallest integer of each cycle comes first, and then cycles are sorted by their first integer.
This is a permutation with two cycles and :
This represents the same permutation. Singletons and empty cycles are removed:
Any permutation with only singletons represents the identity:
With permutations containing explicit lists of numbers, there is automatic syntax checking. In other cases, you can use the function PermutationCyclesQ to check the syntax.
The cycles must be disjoint:
Integers must be positive:
Numbers other than integers are not accepted:
This is a valid permutation in cyclic form:
These are invalid permutations, for obvious reasons:
Permutation Action and Support
If a permutation perm maps the integer to the integer , then is called the image of under the permutation perm. Images are computed with the function PermutationReplace.
PermutationReplace
image of an integer under a permutation
Standard action of permutations on other expressions.
This is the image of 3:
These are the images of the first 6 integers:
The standard action of permutations can be extended to other objects, like other permutations or arrays of integers or permutations.
Map integers of the first permutation under the second permutation (conjugation):
Permutations are not assumed to belong to any particular finite group, not even a particular symmetric group of some degree. However, there is the concept of support, defined as the set of integers moved by the permutation, which better describes where a permutation acts naturally.
PermutationSupport
set of integers moved by a permutation
PermutationLength
number of integers moved by a permutation
PermutationMax
largest integer moved by a permutation
PermutationMin
smallest integer moved by a permutation
Permutation support functions.
The following permutation moves only five points:
The largest moved point is 55:
The smallest moved point is 4:
RandomPermutation
generate pseudorandom permutations
Random generation of permutations.
Generate a random permutation moving (perhaps not all) integers {1,…,15}:
Generate several random permutations in a given group:
Permute Parts of an Expression
Permutations can be used to permute the parts of other expressions with the function Permute. Integer being mapped to integer is interpreted as part being moved to part . Permute never changes the number of elements of an expression, it simply reorders them.
Permute
permute parts of an expression
FindPermutation
return permutation linking two expressions with the same elements
Reordering under a permutation.
Swap the first and last letters of the alphabet:
Permute three parts of an expression, leaving the rest invariant:
The same result can be obtained using a permutation list representation and the function Part:
However, the length of the permutation list must match that of the expression:
Permutation lists can also be used with the function Permute:
Vice versa, given two expressions with the same elements, a permutation linking them can be computed:
Reversing the two arguments gives the inverse permutation:
With a single argument, FindPermutation returns the permutation that generates an expression from its canonical order:
Product of Permutations
PermutationProduct
product of permutations (non-commutative)
InversePermutation
inverse of a permutation
PermutationPower
integer power (product with itself or inverse) of a permutation
PermutationOrder
lowest positive power of a permutation yielding the identity
Product of permutations.
There are two possible conventions for the product of two permutations perm1 and perm2, depending on whether PermutationProduct[perm1,perm2] means that you first use perm1 and then perm2 (this is called a left-to-right product) or you first use perm2 and then perm1 (right-to-left product). With the convention of writing images as right neighbors in cycles, the Wolfram Language's PermutationProduct effectively is a left-to-right product.
The product of permutations is not commutative:
PermutationReplace acts from the right, consistent with the left-to-right character of the product:
Permute also acts from the right:
After the permutation product law has been given, the associated concepts of inversion, power, and order can be immediately defined. For permutations of finite support, the order is always finite.
You can compute inverses of permutations:
And you can compute powers of them. Negative powers are powers of the inverse:
The order of a permutation is the lowest positive power such that the identity permutation is obtained:
Another example:
This means that (for permutations of finite support) the inverse is always a positive power of the permutation:
Equality and Sorting of Permutations
As is standard in the Wolfram Language, there are two types of equality tests: structural equality (SameQ) and mathematical equality (Equal). The former can compare any two expressions, but the latter will only return True or False when comparing mathematical expressions with the same type of value. The same happens when ordering expressions: there is structural (canonical) order, implemented through Order and OrderedQ, and there is mathematical order, given by Less and related functions.
Any two permutations of any degree can always be tested for equality and ordering. This is done by comparing sequentially the images of the integers 1, 2, 3, … . The smaller permutation corresponds to smaller images, such that the identity permutation always comes first. This defines mathematical order. Canonical order follows standard rules, and may differ from mathematical order.
Take two permutations:
These are the images of the first 7 integers under them:
Permutation perm2 must be sorted before perm1 because its second image is smaller:
The standard canonical order will sort smaller expressions first:
You can sort permutations using mathematical order by using an "ordering function":
You can check whether a list of permutations is sorted:
Special Types of Permutations
There are special types of permutations. In many cases the cyclic notation allows simple constructions to detect them.
Involutions contain only cycles of maximal length 2:
A permutation is a derangement of degree if all integers are moved:
A permutation is said to be circular of degree if it consists of a single cycle of length :
From the cyclic notation of a permutation it is also simple to construct a decomposition into transpositions, that is, permutations with a single cycle of length 2.
These functions construct a list of transpositions whose product is the original permutation:
Such decomposition into transpositions is not unique, but the parity (even or odd) of the number of transpositions is invariant. This is called the signature of the permutation:
The previous example permutation perm was decomposed into five transpositions, an odd number. Hence it has signature -1:

Related Tech Notes

    ▪
  • Permutation Lists
  • ▪
  • Permutation Groups
Top
Introduction for Programmers
Introductory Book
Wolfram Function Repository | Wolfram Data Repository | Wolfram Data Drop | Wolfram Language Products
Top
  • Products
  • Wolfram|One
  • Mathematica
  • Notebook Assistant + LLM Kit
  • Compute Services
  • System Modeler

  • Wolfram|Alpha Notebook Edition
  • Wolfram|Alpha Pro
  • Mobile Apps

  • Wolfram Engine
  • Wolfram Player

  • Volume & Site Licensing
  • Server Deployment Options
  • Consulting
  • Wolfram Consulting
  • Repositories
  • Data Repository
  • Function Repository
  • Community Paclet Repository
  • Neural Net Repository
  • Prompt Repository

  • Wolfram Language Example Repository
  • Notebook Archive
  • Wolfram GitHub
  • Learning
  • Wolfram U
  • Wolfram Language Documentation
  • Webinars & Training
  • Educational Programs

  • Wolfram Language Introduction
  • Fast Introduction for Programmers
  • Fast Introduction for Math Students
  • Books

  • Wolfram Community
  • Wolfram Blog
  • Public Resources
  • Wolfram|Alpha
  • Wolfram Problem Generator
  • Wolfram Challenges

  • Computer-Based Math
  • Computational Thinking
  • Computational Adventures

  • Demonstrations Project
  • Wolfram Data Drop
  • MathWorld
  • Wolfram Science
  • Wolfram Media Publishing
  • Customer Resources
  • Store
  • Product Downloads
  • User Portal
  • Your Account
  • Organization Access

  • Support FAQ
  • Contact Support
  • Company
  • About Wolfram
  • Careers
  • Contact
  • Events
Wolfram Community Wolfram Blog
Legal & Privacy Policy
WolframAlpha.com | WolframCloud.com
© 2026 Wolfram
© 2026 Wolfram | Legal & Privacy Policy |
English