My *nix world

When to use a Venn diagram

Venn diagram is not just that simple but ingenious tool that helps you to solve those complicated set problems. Venn diagram is a powerful tool.

A Venn diagram or set diagram is a diagram that shows all possible logical relations between a finite collection of sets. Venn diagrams were conceived around 1880 by John Venn. They are used to teach elementary set theory, as well as illustrate simple set relationships in probability, logic, statistics, linguistics and computer science.

A Venn diagram can represent something simple like the intersection between 2 sets:


or something complicated like the intersection and union of 16 different sets:


But how can they help us to solve problems? I will try to show you by examples when to use a Venn diagram.

Example 1:

One of the hardest problem that emergency units have in hospitals is how to prioritize the resources in the most effective way possible.

After an explosion in a chemical factory came 77 people to the emergency room (ER) to seek for help. 49 people had respiratory failure and 38 people complained of headaches. The ER stuff decided that:

  • those patients that have headaches they don't need special attention, they can take an aspirin and then go home
  • those patients that had respiratory failure should be treated with normal priority by the ER stuff
  • only those patients that had both headaches and respiratory failure should be treated with high priority (they need special assistance)

The question is: how many of all these patients need special assistance, i.e. must be treated with high priority by the ER stuff?

To solve this problem only with the algebraic means would be cumbersome. It's not always simple to model such a problem algebraically, i.e. we don't see immediately what are the variables and how to create some set of equations with them which later it's reduced to solve a trivial system of equations. Here comes in help Venn diagrams, these discrete tools of mathematics created specially when dealing with sets (like set of peoples, set of problems, etc).

Let's call the set of all these patients U. We note by \mid{U}\mid the number of elements within U. In our example \mid{U}\mid = 77.

Let's call the set of those patients with respiratory failure R, where \mid R\mid = 49.

Let's call the set of those patients with only headaches problems H, where \mid H\mid = 38.

Those patients that had both respiratory failure and headaches problems belongs to both sets, R and H. In fact they belongs to the R\cap{H} and this subset is what we are looking for, i.e. those that should be treated with high priority.


If we take a look at the Venn diagram above we can clearly see that if we add those elements of R with those elements of H we add in fact those elements that only appears in R with those elements that only appears in H and twice those elements that are shared between R and H. With other words:

\mid R\mid +\mid H\mid =\mid \text{only R}\mid +\mid \text{only H}\mid +2 \times\mid R\cap H\mid (R1)

Moreover, we can see that if we add only those elements in R with only those elements in H and with those elements shared in common by R and H we get the union between R and H:

\mid \text{only R}\mid +\mid \text{only H}\mid +1 \times\mid R\cap H\mid=\mid R\cup H\mid (R2)
From (R1) and (R2) above we can conclude that: \mid R \cup H\mid =\mid R\mid+\mid H\mid-\mid R\cap H\mid (R3)

These three relations are extremely important when working with sets. I know that the union between R and H have 77 elements in total. I know that only R has 49 elements while only H has 38 elements. I can use (R2) and extract \mid R\cap H\mid=\mid R\mid+\mid H\mid)-\mid R\cup H\mid=49+38-77=87-77=10

So the answer is: 10 patients needed special assistance (they had to be helped with high priority).

Example 2:

In a language institute do study 65 students the English language, 45 students the German language and 42 students the French language. They don't study any other language. Moreover we know that:

  • 20 students do study both the English and German languages
  • 25 students do study both the English and French languages
  • 15 students do study both the French and German languages
  • 8 students do study all three languages (i.e the English, the German and the French)

The question is : how many students do study in total at that language institute?

If the previous problem seemed a bit easier to be described in terms of some unknown variables such that we could create an algebraic system of equations and then solve the problem by algebraic means, this one seems just a bit difficult than that, isn't it?

Here I would only use set theory with its Venn diagram than Algebra because this way the problem is just a piece of cake. Let me show you!

Let's call G that set of students which do study German, F that set of students which do study French and E that set of students which do study English language.

We know that \mid E\mid=65, \mid G\mid=45\text{ and }\mid F\mid=42. We also know that:

\mid E\cap G\mid=20, \mid E\cap F\mid=25, \mid F\cap G\mid=15 and \mid E\cap G\cap F\mid=8.


We can see that the total number of elements (which is our dilemma)  is equal to the number of students that do study only English + number of student that do study only German + number of student that do study only French + number of students that study both English+German (but not French) + number of students that study both English+French (but not German) + number of students that study both French+German (but not English) - 2 times the number of students that study all three languages:

\mid E\cup F\cup G\mid=\mid\text{only E}\mid+\mid\text{only F}\mid+\mid\text{only G}\mid+\mid E\cap G\mid+\mid E\cap F\mid+\mid F\cap G\mid-2\times\mid E\cap F\cap G\mid (R4)
If you wonder why I have subtracted twice \mid E\cap F\cap G\mid the answer is quite simple. By adding \mid E\cap G\mid+\mid E\cap F\mid+\mid F\cap G\mid we have included three times that small intersection. Because we wanted to add only once that \mid E\cap F\cap G\mid we have to subtract twice those additional copies.

If we use the (R4) and also (R1) then we can understand that:

\mid E\cup F\cup G\mid=\mid A\mid+\mid B\mid+\mid C\mid+\mid E\cap G\mid+\mid E\cap F\mid+\mid F\cap G\mid+\mid E\cap F\cap G\mid such that we can solve our problem by just plugging those number in this equation but I just wanted to show you that by using the Venn diagram you can really visualize the problem and find the solution quite easily. So in the following we'll stick to our original solution and not choosing the shortcut mentioned above.

If we find out the value for \mid\text{only E}\mid\text{, }\mid\text{only F}\mid\text{ and }\mid\text{only G}\mid we have solved our problem.

So, what is \mid\text{only E}\mid for instance?

\mid\text{only E}\mid=\mid E\mid-\mid F\cap E\mid-\mid G\cap E\mid+\mid E\cap F\cap G\mid=65-25-20+8=28

Likewise \mid\text{only F}\mid=\mid F\mid-\mid F\cap G\mid-\mid F\cap E\mid+\mid E\cap F\cap G\mid=42-15-25+8=10

and \mid\text{only G}\mid=\mid G\mid-\mid F\cap G\mid-\mid E\cap G\mid+\mid E\cap F\cap G\mid=45-15-20+8=18

We plug all these data into (R4) and get \mid E\cup F\cup G\mid=28+10+18+20+25+15-2\times 8=100

There are 100 student that do study in that language institute.

Conclusion: by using Venn diagram we can easily solve problems involving sets, although they might seem tricky and complicated at first sight.

Now, if you think that this article was interesting don't forget to rate it. It shows me that you care and thus I will continue write about these things.

The following two tabs change content below.
When to use a Venn diagram

Eugen Mihailescu

Founder/programmer/one-man-show at Cubique Software
Always looking to learn more about *nix world, about the fundamental concepts of math, physics, electronics. I am also passionate about programming, database and systems administration. 16+ yrs experience in software development, designing enterprise systems, IT support and troubleshooting.
When to use a Venn diagram

Latest posts by Eugen Mihailescu (see all)

Tagged on: ,

Leave a Reply

Your email address will not be published. Required fields are marked *