-
See Also
- If
- Piecewise
- DiscreteDelta
- UnitStep
- Unitize
- Ramp
- DiscreteIndicator
- Pick
- RegionPlot
- True
-
- Net Encoders
- Boolean
-
- Compiled Types
- Boolean
- Related Guides
- Tech Notes
Boole
Details
- Boole is also known as Iverson bracket, indicator function and characteristic function.
- Boole is typically used to express integrals and sums over regions given by logical combinations of predicates. It is also used as a dummy variable encoding for categorical variables in statistics.
- Boole[expr] remains unchanged if expr is neither True nor False.
- Boole[expr] is effectively equivalent to If[expr,1,0].
- Boole is Listable.
- Integrate[f Boole[pred],…] can be used to integrate f over the region in which pred is True.
Examples
open all close allBasic Examples (3)
Convert truth values to integers:
{Boole[False], Boole[True]}Convert a list of truth values to integers:
Boole[{True, False, True, True, False}]Find the area of the disc defined by the inequality
:
Integrate[Boole[x ^ 2 + y ^ 2 ≤ 1], {x, -1, 1}, {y, -1, 1}]Applications (4)
Find the area of a region defined by an inequality:
ineq = y ^ 2 - 4x ^ 2 + 4x ^ 4 ≤ 0;Integrate[Boole[ineq], {x, -Infinity, Infinity}, {y, -Infinity, Infinity}]NIntegrate[Boole[ineq], {x, -Infinity, Infinity}, {y, -Infinity, Infinity}]RegionPlot[ineq, {x, -1, 1}, {y, -1, 1}]Find the volume of a solid defined by an inequality:
ineq = y ^ 2 - 4x ^ 2 + 4x ^ 4 ≤ -z ^ 2;Integrate[Boole[ineq], {x, -Infinity, Infinity}, {y, -Infinity, Infinity}, {z, -Infinity, Infinity}]NIntegrate[Boole[ineq], {x, -Infinity, Infinity}, {y, -Infinity, Infinity}, {z, -Infinity, Infinity}]RegionPlot3D[ineq, {x, -1, 1}, {y, -1, 1}, {z, -1, 1}]Find the area of the intersection of a circle with a parametric radius and a square:
Integrate[Boole[x ^ 2 + y ^ 2 < a], {x, -1, 1}, {y, -1, 1}]Table[RegionPlot[x ^ 2 + y ^ 2 < a, {x, -1, 1}, {y, -1, 1}], {a, {1 / 2, 3 / 2, 5 / 2}}]Convert a table of True,False values to 1,0 for plotting:
ArrayPlot[Boole[Table[PrimeQ[a ^ b + 3], {a, 50}, {b, 50}]]]Properties & Relations (7)
The inverse of Boole:
(# != 0)& /@ {1, 0, 1, 1, 1}Boole[%]Use PiecewiseExpand to convert Boole to Piecewise:
PiecewiseExpand[Boole[a]]Correspondence between logic operations on conditions and arithmetic operations on Boole:
Simplify[Boole[a && b] - Min[Boole[a], Boole[b]]]Simplify[Boole[a || b] - Max[Boole[a], Boole[b]]]Simplify[Boole[a && b] - Boole[a]Boole[b]]Simplify[Boole[a || b] - (Boole[a] + Boole[b] - Boole[a]Boole[b])]Simplify[Boole[!a] - (1 - Boole[a])]Use Refine, Simplify, and FullSimplify to transform expressions involving Boole:
Refine[Boole[x ^ 2 + y ^ 2 < 10 && x > y], (x - 2) ^ 2 + y ^ 2 < 1]Simplify[Boole[x > y], x == y + 2]Reduce equations and optimize functions involving Boole:
Reduce[Exp[Sin[x]Boole[x ^ 2 + y ^ 2 < 1]] < 1, {x, y}]Minimize[Exp[Sin[x]Boole[x ^ 2 + y ^ 2 <= 1]], {x, y}]Use Boole as a characteristic function for integration problems:
Integrate[(x ^ 2 + x y + 3y ^ 4)Boole[x ^ 2 + y ^ 2 < 1 && y > x], {x, -Infinity, Infinity}, {y, -Infinity, Infinity}]NIntegrate[Exp[x ^ 2 + x y + 3y ^ 4]Boole[x ^ 2 + y ^ 2 < 1 && y > x], {x, -Infinity, Infinity}, {y, -Infinity, Infinity}]Boole can be represented as a DifferenceRoot in certain cases:
DifferenceRootReduce[Boole[Mod[k, 5] == 1], k]See Also
If Piecewise DiscreteDelta UnitStep Unitize Ramp DiscreteIndicator Pick RegionPlot True
Net Encoders: Boolean
Compiled Types: Boolean
Function Repository: InverseBoole
Tech Notes
Related Guides
History
Introduced in 2004 (5.1) | Updated in 2007 (6.0)
Text
Wolfram Research (2004), Boole, Wolfram Language function, https://reference.wolfram.com/language/ref/Boole.html (updated 2007).
CMS
Wolfram Language. 2004. "Boole." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2007. https://reference.wolfram.com/language/ref/Boole.html.
APA
Wolfram Language. (2004). Boole. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Boole.html
BibTeX
@misc{reference.wolfram_2026_boole, author="Wolfram Research", title="{Boole}", year="2007", howpublished="\url{https://reference.wolfram.com/language/ref/Boole.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_boole, organization={Wolfram Research}, title={Boole}, year={2007}, url={https://reference.wolfram.com/language/ref/Boole.html}, note=[Accessed: 13-June-2026]}