Xor
Details
- Xor[e1,e2,…] can be input in StandardForm and InputForm as
. The character ⊻ can be entered as
xor
or \[Xor]. - Xor gives symbolic results when necessary, applying various simplification rules to them.
- Unlike And, Nand, Or, and Nor, Xor must always test all its arguments, and so is not a control structure, and does not have attribute HoldAll.
Examples
open all close allBasic Examples (2)
Scope (4)
Xor is associative and commutative:
Xor[Xor[x, y], z]Xor[y, x]Simplify[Xor[True, x]]Simplify[Xor[x, x, y]]Expand in terms of And, Or, and Not:
LogicalExpand[Xor[x, y]]TraditionalForm formatting:
Xor[x, y, z]//TraditionalFormApplications (3)
Find the Xor of two regions in 2D:
RegionPlot[Xor[x ^ 2 + y ^ 2 < 1, x + y > 0], {x, -2, 2}, {y, -2, 2}]Find the Xor of three regions in 3D:
RegionPlot3D[Xor[x > 0, y > 0, z > 0], {x, -1, 1}, {y, -1, 1}, {z, -1, 1}]A cellular automaton based on Xor:
ArrayPlot[Boole[CellularAutomaton[{Xor@@#&, {}}, {{True}, False}, 40]]]Find the area of the symmetric difference of sets given by algebraic conditions:
Integrate[Boole[Xor[x ^ 2 + y ^ 2 < 1, (x - 1) ^ 2 + y ^ 2 < 2]], {x, -Infinity, Infinity}, {y, -Infinity, Infinity}]//FullSimplifyRegionPlot[Xor[x ^ 2 + y ^ 2 < 1, (x - 1) ^ 2 + y ^ 2 < 2], {x, -1.5, 2.5}, {y, -2, 2}]Properties & Relations (3)
Truth table for binary Xor:
BooleanTable[{x, y, Xor[x, y]}, {x, y}]//GridTernary Xor:
BooleanTable[{x, y, z, Xor[x, y, z]}, {x, y, z}]//GridUse BooleanConvert to expand in terms of And, Or, and Not:
BooleanConvert[Xor[p, q, r]]Xor of conditions in Boole functions:
Boole[Xor[a, b, c]] - Mod[Boole[a] + Boole[b] + Boole[c], 2]Simplify[%]Neat Examples (2)
The Xor of disks on a circle:
disk[m_, n_] := Block[{x0 = 1 / 2Cos[m 2Pi / n], y0 = 1 / 2Sin[m 2Pi / n]}, (x - x0) ^ 2 + (y - y0) ^ 2 < 1]disk[n_] := Apply[Xor, Table[disk[m, n], {m, 0, n - 1}]]Generate three disks on a circle:
disk[3]Table[RegionPlot[disk[n], {x, -2, 2}, {y, -2, 2}, FrameTicks -> None], {n, 2, 5}]A truth table for a 12-variable Xor function:
ArrayPlot[BooleanTable[Xor@@Array[x, 12], Array[x, 6], Array[x, 6, 7]], ColorRules -> {False -> White, True -> Black}]See Also
LogicalExpand Mod BitXor Xnor Nor Or BooleanCountingFunction
Characters: \[Xor]
Function Repository: VennDiagram
Tech Notes
Related Guides
Related Links
History
Introduced in 1988 (1.0) | Updated in 2003 (5.0)
Text
Wolfram Research (1988), Xor, Wolfram Language function, https://reference.wolfram.com/language/ref/Xor.html (updated 2003).
CMS
Wolfram Language. 1988. "Xor." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2003. https://reference.wolfram.com/language/ref/Xor.html.
APA
Wolfram Language. (1988). Xor. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Xor.html
BibTeX
@misc{reference.wolfram_2026_xor, author="Wolfram Research", title="{Xor}", year="2003", howpublished="\url{https://reference.wolfram.com/language/ref/Xor.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_xor, organization={Wolfram Research}, title={Xor}, year={2003}, url={https://reference.wolfram.com/language/ref/Xor.html}, note=[Accessed: 12-June-2026]}