Venn Diagram

Author

Eric W. Weisstein
March 7, 2012

This notebook downloaded from http://mathworld.wolfram.com/notebooks/Logic/VennDiagram.nb.

For more information, see Eric's MathWorld entry http://mathworld.wolfram.com/VennDiagram.html.

©2012 Wolfram Research, Inc. except for portions noted otherwise

Initialization

<<Graphics`InequalityGraphics`
<<DiscreteMath`Combinatorica`

Code

VennDiagram[n_,ineqs_:{}]:=Module[{i,r=.6,R=1,v},
v=Table[Circle[r{Cos[#],Sin[#]}&[2Pi(i-1)/n],R],{i,n}];
{
If[ineqs=={},{},
InequalityPlot[(v/.Circle[{xx_,yy_},rr_]:>(x-xx)^2+(y-yy)^2<rr^2)[[ineqs]],
{x},{y},Axes->False,
Curves->None,
DisplayFunction->Identity][[1]]
],
v
}
]

Diagram

GraphicsRow[{
Graphics[{Circle[{-.6,0},1],Circle[{.6,0},1],
Text[Style["A",Italic,18],{-.85,0}],Text[Style["B",Italic,18],{.85,0}],Text[Style[Row[{Style["A",Italic]," ⋂ ",Style["B",Italic]}],14],{0,0}]
}],
Graphics[{Circle[{-.6,0},1],Circle[{.6,0},1],Circle[{0,-.8},1],
Text[Style["A",Italic],{-.85,.25}],Text[Style["B",Italic],{.85,.25}],Text[Style["C",Italic],{0,-1.25}],
Text[Style[Row[{Style["A",Italic]," ⋂ ",Style["B",Italic]}],10],{0,.4}],Text[Style[Row[{Style["A",Italic]," ⋂ ",Style["C",Italic]}],10],{-.57,-.6}],Text[Style[Row[{Style["B",Italic]," ⋂ ",Style["C",Italic]}],10],{.57,-.6}],
Text[Style[Row[{Style["A",Italic]," ⋂ ",Style["B",Italic]," ⋂ ",Style["C",Italic]}],7],{0,-.1}]
},BaseStyle->18]
}]//Quiet

Diagrams

n = 2

Sort@Subsets[2]

Show[GraphicsArray[Partition[Graphics[VennDiagram[2,#],AspectRatio->Automatic,PlotLabel->TraditionalForm[And@@(Subscript[A,#]&/@#)]/.True->∅]&/@Sort@Subsets[2],2]
]]

n = 3

Sort@Subsets[3]

Show[GraphicsArray[Partition[Graphics[VennDiagram[3,#],AspectRatio->Automatic,PlotLabel->TraditionalForm[And@@(Subscript[A,#]&/@#)]/.True->∅]&/@Sort@Subsets[3],4]
]]

Doesn't work for n = 4

Show[Graphics[VennDiagram[4],AspectRatio->Automatic]]

Sums

(∑_(k=0)^n)(Binomial[n, k])==(2^n)

Sum[Binomial[n,k],{k,0,n}]