Simplify Your Workflow: Search MiniWebtool.
Add Extension
See also
Venn Diagram Generator (3 Sets)Set Theory CalculatorDerangement (Subfactorial) CalculatorSystem of Inequalities GrapherRugby Points CalculatorJWT Generator
Home Page > Math > Advanced Math Operations > Inclusion-Exclusion Calculator

Inclusion-Exclusion Calculator

Compute the size of a union of up to 5 sets using the inclusion–exclusion principle. Enter raw elements or cardinalities of every intersection — get the signed expansion, a live Venn-diagram visualization, and the size of every disjoint region.

Inclusion-Exclusion Calculator
Elements mode: one line per set, e.g. A: 1, 2, 3. The calculator detects every intersection automatically.
Cardinalities mode: one size per line, e.g. |A| = 50 and |A∩B| = 15. Any intersection you omit is treated as zero. Accepts A&B, AB, or |A∩B|.

Embed Inclusion-Exclusion Calculator Widget

About Inclusion-Exclusion Calculator

The Inclusion-Exclusion Calculator computes the size of a union of finite sets, |A1 ∪ A2 ∪ … ∪ An|, using the inclusion-exclusion principle — one of the most widely used identities in combinatorics and discrete probability. Enter raw set elements, or just the known cardinalities of each intersection, and the calculator returns the union size, the full signed expansion, the sizes of every disjoint Venn region, and a live diagram — for 2 to 5 sets at a time.

The Inclusion-Exclusion Principle

For two finite sets A and B, adding their sizes double-counts elements in both. Subtracting the intersection fixes the overcount:

|A ∪ B| = |A| + |B| − |A ∩ B|

For three sets, subtracting every pairwise intersection removes the triple-count twice, so we add the triple intersection back:

|A ∪ B ∪ C| = |A| + |B| + |C| − |A ∩ B| − |A ∩ C| − |B ∩ C| + |A ∩ B ∩ C|

In general, for n sets the signs alternate with the size of the intersection being counted:

|A1 ∪ … ∪ An| = ΣS ≠ ∅ (−1)|S|+1 · |⋂i ∈ S Ai|

There are 2n − 1 non-empty subsets of {1, …, n}, so the formula has 3 terms for 2 sets, 7 for 3 sets, 15 for 4 sets, and 31 for 5 sets. The calculator evaluates each term individually and shows its sign so you can follow the derivation.

Two Input Modes

Pick the mode that matches the data you have. Most textbook problems give you cardinalities directly; programming tasks usually give you the sets themselves.

ModeWhen to useExample input
Elements You have the actual items of each set and want every intersection derived automatically. A: 1, 2, 3, 4
B: 3, 4, 5, 6
C: 4, 6, 7, 8
Cardinalities You know how many elements are in each set and each intersection but not the elements themselves. |A| = 50
|B| = 40
|A∩B| = 15

In Cardinalities mode any intersection you omit is assumed to be zero. Accepted separators for the intersection label include A∩B, A&B, and AB, with optional pipes around the expression (|A∩B|).

Disjoint Region Sizes — Möbius Inversion

Beyond the union size the calculator returns the size of every disjoint region of the Venn diagram. The region labelled "in A and B but not C" counts elements that belong to exactly those sets. The sizes of all disjoint regions sum to the union, giving an instant sanity check.

|region T| = ΣS ⊇ T (−1)|S|−|T| · |⋂i ∈ S Ai|

This is the Möbius-inversion dual of inclusion-exclusion. For example, with three sets:

|A only| = |A| − |A∩B| − |A∩C| + |A∩B∩C| |A ∩ B only| = |A∩B| − |A∩B∩C|

If you enter inconsistent cardinalities — for instance |A∩B| > |A| — the calculator rejects the input. If the individual sizes pass but the combined values still can't come from real sets, one or more regions will be negative, which is flagged as a warning.

Worked Example — 3-Set Classroom Survey

A class of 100 students is asked which sports they play. 50 play football (A), 40 basketball (B), 30 tennis (C). 15 play both A and B, 10 both A and C, 8 both B and C, and 3 play all three. How many play at least one sport?

|A ∪ B ∪ C| = 50 + 40 + 30 − 15 − 10 − 8 + 3 = 120 − 33 + 3 = 90

So 90 of 100 students play at least one of these sports; 10 play none. The region breakdown reveals more: 28 play only football, 20 only basketball, 15 only tennis, 12 play football and basketball but not tennis, and so on.

How to Use This Calculator

  1. Pick an input mode — Elements if you have the items, Cardinalities if you only have sizes.
  2. Enter your data in the text area, one line per set or one line per known cardinality.
  3. Choose the number of sets (2 to 5) in Cardinalities mode. In Elements mode the count is detected automatically.
  4. Click Calculate Union & Regions. The result shows |⋃ Aᵢ| in a hero card, the full inclusion-exclusion expansion with each signed term, a Venn-diagram SVG (for 2, 3, or 4 sets), and a table with every disjoint region and its size.
  5. Hover a Venn region or a table row to cross-highlight the matching entry — a quick visual proof that the table and the diagram represent the same decomposition.

Common Applications

Tips & Common Pitfalls

Frequently Asked Questions

What is the inclusion-exclusion principle?

The inclusion-exclusion principle is a counting identity that gives the size of a union of sets in terms of the sizes of the sets themselves and their intersections. For two sets it says |A ∪ B| = |A| + |B| − |A ∩ B|. For three sets a correction for the triple intersection is added back, and for n sets the signs alternate, adding single sets, subtracting pairs, adding triples, and so on.

What is the difference between Elements mode and Cardinalities mode?

Elements mode expects the actual elements of each set, one line per set, and the calculator finds every intersection automatically. Cardinalities mode expects only the sizes of the sets and their intersections and is ideal when solving word problems where you know how many people like tea, coffee, or both, without being given the actual names.

Why does my calculator show negative region sizes?

Negative region sizes in Cardinalities mode mean your inputs are inconsistent — no collection of real sets can have those intersection sizes. Usually this happens when the pairwise or triple intersection is larger than the individual sets can support. Recheck the numbers; every intersection must be smaller than or equal to each of the sets that contain it.

How many sets can this calculator handle?

The calculator supports 2 to 5 sets. The Venn diagram is rendered for 2, 3, and 4 sets; the region-breakdown table is shown for any number of sets including 5. For larger problems the inclusion-exclusion expansion becomes unwieldy, so most textbook problems top out at 4 or 5 sets.

What is a disjoint region?

A disjoint region is a piece of the Venn diagram that belongs to exactly one combination of sets and to no others. For three sets A, B, C there are seven non-empty regions: A-only, B-only, C-only, A∩B-only, A∩C-only, B∩C-only, and A∩B∩C. Their sizes sum to |A ∪ B ∪ C|, which is a fast way to double-check an inclusion-exclusion calculation.

Can I use the calculator with infinite or continuous sets?

The calculator is designed for finite sets whose sizes are non-negative integers. For probability or measure-theory problems with continuous sets you can still apply the inclusion-exclusion identity conceptually, but the numeric tool expects cardinalities you can type as whole numbers.

Further Reading

Reference this content, page, or tool as:

"Inclusion-Exclusion Calculator" at https://MiniWebtool.com/inclusion-exclusion-calculator/ from MiniWebtool, https://MiniWebtool.com/

by miniwebtool team. Updated: Apr 21, 2026

You can also try our AI Math Solver GPT to solve your math problems through natural language question and answer.

Advanced Math Operations:

Top & Updated:

Instagram User ID LookupRandom Name Picker WheelRandom PickerImage ResizerFacebook User ID LookupLine CounterSort NumbersRSD Calculator - Relative Standard DeviationFPS ConverterMAC Address GeneratorRemove SpacesWord to Phone Number Converter⬛ Aspect Ratio Calculator📷 OCR / Image to TextSun Position CalculatorSun, Moon & Rising Sign Calculator 🌞🌙✨ERA CalculatorRandom Quote GeneratorMAC Address Lookup🖱️ Click CounterMerge VideosSlope and Grade CalculatorJob FinderPercent Off CalculatorSquare Root (√) CalculatorWeight Loss CalculatorRandom Truth or Dare GeneratorCm to Feet and Inches ConverterSHA256 Hash GeneratorSum CalculatorBatting Average CalculatorVertical Jump CalculatorMP3 LooperAdd Text to ImageRandom Credit Card GeneratorRandom Poker Hand GeneratorRandom Superpower GeneratorFeet and Inches to Cm ConverterNumber of Digits CalculatorRandom Fake Address GeneratorBitwise CalculatorRoman Numerals ConverterInvisible Text GeneratorRandom IMEI GeneratorSalary Conversion CalculatorPhone Number ExtractorAudio SplitterNumber to Word ConverterRandom Writing Prompt GeneratorImage SplitterRandom Birthday GeneratorText FormatterLog Base 10 CalculatorIP Subnet CalculatorBinary to Gray Code ConverterJulian Date ConverterCaffeine Overdose CalculatorBolt Torque CalculatorLunar Calendar ConverterName RandomizerOctal CalculatorCompound Growth CalculatorRandom Activity GeneratorHalfway Date CalculatorRandom Movie PickerFile Size ConvertereBay Fee CalculatorEmail ExtractorSHA512 Hash GeneratorYouTube Channel StatisticsQuotient and Remainder CalculatorImage CompressorDecimal to BCD ConverterStair CalculatorLeap Years ListLong Division CalculatorFirst n Digits of PiRandom Meal GeneratorWAR CalculatorVideo CompressorOutlier CalculatorHebrew Calendar ConverterBCD to Decimal ConverterWord Ladder GeneratorRandom Loadout GeneratorFlip Video📅 Date CalculatorMaster Number CalculatorOPS CalculatorBcrypt Hash Generator / CheckerCompare Two StringsMD5 Hash GeneratorMultiple Fraction CalculatorSlugging Percentage CalculatorAPI TesterPercent Growth Rate CalculatorAI Language DetectorRandom Number PickerList of Prime NumbersBreak Line by Characters🔍 Plagiarism CheckerSocial Media Username CheckerDMS to Decimal Degrees ConverterAdd Prefix and Suffix to TextRandomize NumbersIP Address to Hex ConverterArc Length CalculatorDay of the Year Calculator - What Day of the Year Is It Today?Bingo Card GeneratorBroken Link Checker🎰 Gacha Pity CalculatorMultiplication Calculator🔊 Tone GeneratorAstrological Element Balance CalculatorIs it a Prime Number?What is my Zodiac Sign?Percent to PPM ConverterOn Base Percentage CalculatorVideo to Image ExtractorYouTube Tag ExtractorModulo CalculatorGray Code to Binary ConverterAcreage CalculatorVideo SplitterTime Duration CalculatorURL ExtractorSmall Text Generator ⁽ᶜᵒᵖʸ ⁿ ᵖᵃˢᵗᵉ⁾Cone Flat Pattern (Template) GeneratorMercury Retrograde CalendarNumber ExtractorRemove AccentRandom Chord GeneratorDecibel (dB) CalculatorRandom Tournament Bracket GeneratorSocial Media Post Time OptimizerGreat Circle Distance CalculatorLED Resistor CalculatorName Number CalculatorList RandomizerRandom Emoji GeneratorRandom Object GeneratorWord Scramble GeneratorDay of Year CalendarEstimation CalculatorBattery Life CalculatorRatio CalculatorConnect the Dots GeneratorWHIP CalculatorRandom Math Problem GeneratorSaturn Return CalculatorHeight Percentile CalculatorProportion CalculatorChinese Gender PredictorIP Address to Binary ConverterSquare Numbers ListBinary to BCD ConverterLove Compatibility CalculatorMAC Address AnalyzerGolden Ratio CalculatorRandom Line PickerLottery Number GeneratorText Case ConverterRemove Line BreaksPercentage Increase CalculatorRandom User-Agent GeneratorImage EnhancerFraction CalculatorImage CropperMagic 8-BallRatio to Percentage CalculatorAmortization CalculatorTaco Bar CalculatorBackronym Generator📊 Bar Graph MakerAngel Number CalculatorPipe Flow CalculatorAdjust Video SpeedScientific Notation to Decimal ConverterWhitespace VisualizerAm I Overweight?HTML CompressorNumber Pattern FinderRandom Video Thumbnail GeneratorFirst n Digits of eLbs to Kg ConverterStandard Error CalculatorWhat is my Lucky Number?Color InverterInvisible Character RemoverReverse VideoRandom Excuse GeneratorPER Calculator💧 Dew Point CalculatorSigma Notation Calculator (Summation)Effect Size CalculatorMcg to Mg ConverterNumber RandomizerRandom Chess Opening GeneratorAI ParaphraserAI Punctuation AdderSort Lines AlphabeticallyHex to BCD ConverterBCD to Binary ConverterBCD to Hex ConverterMedian CalculatorAverage CalculatorPVIFA CalculatorHypotenuse CalculatorRemove Audio from VideoActual Cash Value CalculatorLog Base 2 CalculatorRoot Mean Square CalculatorSum of Positive Integers CalculatorSHA3-256 Hash GeneratorAI Sentence ExpanderHex to Decimal ConverterRandom Group GeneratorConvolution CalculatorRandom String GeneratorRemove Leading Trailing SpacesMarkup CalculatorPVIF CalculatorDecimal to Hex ConverterInstagram Font GeneratorSocial Media Image Size GuideTikTok Money CalculatorTwitter/X Character CounterTwitter/X Timestamp ConverterYouTube Watch Time CalculatorTwitch Earnings CalculatorYouTube Shorts Monetization CalculatorFacebook Ad Cost CalculatorSocial Media ROI CalculatorCTR CalculatorROAS CalculatorInfluencer ROI CalculatorForce CalculatorAcceleration CalculatorVelocity CalculatorMomentum CalculatorProjectile Motion CalculatorKinetic Energy CalculatorPotential Energy CalculatorWork and Power CalculatorDensity CalculatorPressure CalculatorIdeal Gas Law CalculatorFree Fall CalculatorTorque CalculatorHorsepower CalculatorDilution CalculatorChemical Equation BalancerStoichiometry CalculatorPercent Yield CalculatorEmpirical Formula CalculatorBoiling Point CalculatorTitration CalculatorMole/Gram/Particle ConverterIrregular Polygon Area CalculatorFrustum CalculatorTorus Calculator3D Distance CalculatorCircumscribed Circle (Circumcircle) CalculatorInscribed Circle (Incircle) CalculatorAngle Bisector CalculatorTangent Line to Circle CalculatorHeron's Formula CalculatorCoordinate Geometry Distance CalculatorVolume of Revolution CalculatorSurface of Revolution CalculatorParametric Curve GrapherRiemann Sum CalculatorTrapezoidal Rule CalculatorSimpson's Rule CalculatorImproper Integral CalculatorL'Hôpital's Rule CalculatorMaclaurin Series CalculatorPower Series CalculatorSeries Convergence Test CalculatorInfinite Series Sum CalculatorAverage Rate of Change CalculatorInstantaneous Rate of Change CalculatorRelated Rates SolverOptimization Calculator (Calculus)Gradient Calculator (Multivariable)Divergence CalculatorCurl CalculatorLine Integral CalculatorSurface Integral CalculatorJacobian Matrix CalculatorNewton's Method CalculatorRREF Calculator (Row Echelon Form)Matrix Inverse CalculatorMatrix Multiplication CalculatorDot Product CalculatorCross Product CalculatorVector Magnitude CalculatorUnit Vector CalculatorAngle Between Vectors CalculatorNull Space CalculatorColumn Space CalculatorCramer's Rule CalculatorMatrix Diagonalization CalculatorQR Decomposition CalculatorCholesky Decomposition CalculatorMatrix Power CalculatorCharacteristic Polynomial CalculatorBayes' Theorem CalculatorF-Test / F-Distribution CalculatorHypergeometric Distribution CalculatorNegative Binomial Distribution CalculatorGeometric Distribution CalculatorExponential Distribution CalculatorWeibull Distribution CalculatorBeta Distribution CalculatorSpearman Rank Correlation CalculatorFisher's Exact Test CalculatorContingency Table CalculatorOdds Ratio CalculatorBernoulli Equation CalculatorSurfboard Volume CalculatorTennis Grip Size CalculatorBackpack Size CalculatorCelsius to Fahrenheit ConverterFahrenheit to Celsius ConverterKm to Miles ConverterMiles to Km ConverterMM to Inches ConverterInches to MM ConverterStone to Kg ConverterKg to Stone ConverterLiters to Gallons ConverterGallons to Liters ConverterML to Oz ConverterOz to ML ConverterSquare Meters to Square Feet ConverterSquare Feet to Square Meters ConverterCubic Feet to Cubic Yards ConverterCubic Meters to Cubic FeetKnots to MPH ConverterMPH to KMH / KMH to MPHMg to Ml ConverterAI Text SummarizerAI TranslatorAI Story GeneratorAI Poem GeneratorAI Song Lyrics GeneratorIndian Land Unit ConverterTola to Gram ConverterPX to REM ConverterPT to PX ConverterMerge PDFSplit PDFCompress PDFPDF to JPGJPG to PDFRotate PDFDelete PDF PagesAdd Page Numbers to PDFProtect PDFReorder PDF PagesPDF Word CounterPDF Page ExtractorPDF to Text ExtractorUnlock PDF (Owner-Password Removal)PDF Flatten ToolAI Rap Lyrics GeneratorAI Cover Letter GeneratorAI Resume Bullet GeneratorAI LinkedIn Headline & Bio GeneratorAI Instagram Caption GeneratorAI YouTube Title & Description GeneratorAI Video Script GeneratorAI Product Description GeneratorAI Press Release GeneratorAI Wedding Speech GeneratorAI Thank-You Note GeneratorAI Dream InterpreterRandom Question GeneratorWould You Rather GeneratorNever Have I Ever GeneratorIcebreaker Question GeneratorCharades GeneratorPictionary Word GeneratorHangman Word GeneratorTrivia Question GeneratorRandom Fact GeneratorRandom Joke GeneratorDad Joke GeneratorPickup Line GeneratorCompliment GeneratorDaily Affirmation GeneratorJournal Prompt GeneratorDrawing Idea GeneratorFortune Cookie GeneratorFantasy Name Generator