Main content

## Statistics and probability

### Course: Statistics and probability > Unit 7

Lesson 3: Basic set operations# Relative complement or difference between sets

Sal shows an example finding the relative complement or difference of two sets A and B. Created by Sal Khan.

## Want to join the conversation?

- Could you add, divide and/or multiply sets?(96 votes)
- Great question! Actually, there
*are*operations you can do with**sets**that are similar to the operations of multiplication, division, etc. that you do with numbers. However, that is all pretty advanced stuff--you probably won't learn about them until at least high school (if not college). Nevertheless, these operations*do*exist (and they have fancy names like**Minkowski Addition**,**Product Sets**, &**Quotient Sets**, to name a few).

If you're still interested, here's an example of an operation on two sets to get you thinking about the concept:

Let's say you have two sets, A & B

A = {a, b, c}

B = {2, 7}

Then the**Cartesian Product**of A and B (written as "A x B") is the set:

A x B = { (a,2), (a,7), (b,2), (b,7), (c,2), (c,7)},

where each element of the set is an**ordered pair**of elements. Thus, while "7" is a single element of the set B, the letter/number pair "(c,2)" is a single element of the set "A x B". Also, note that while "(c,2)" is an element of "A x B", "(2,c)" is*NOT*an element of "A x B" because*order matters*.

Anyway, there's a lot more to be said about these set operations but I don't want to bore you. I hope you found this interesting! (And not too confusing!!)(184 votes)

- EDIT: Can we even have the same object more than once in a set?

At0:55Sal says "take out the 17, 19, and 6s". So does that mean that if there were two 17s in set A, but only one in set B, would you take out both or only one 17? Do you remove all of what is in set A from set B, or only how many items are in set A from set B? (I can clarify my question if needed)

Example:

Set C={1,**2**,**2**,5,12,**33**,chicken,**33**}

Set D={**2**,pizza,**33**}

When you take C-D, is it (paying attention to the**2**s and**33**s)

C-D={1,**2**,5,12,chicken,**33**} (we subtracted one**2**&**33**from set C because there was only one**2**&**33**in set D)

OR

C-D={1,5,12,chicken} (we subtracted all**2**s &**33**s from set C because there is at least one**2**&**33**in set D)

Which way is correct?

Thanks!(23 votes)- Very good question! Set's can't have duplicate elements, so even though set C is listed as C={1, 2 , 2 ,5,12, 33 ,chicken, 33 }, it would be simplified to C={1, 2, 5,12, 33, chicken }(32 votes)

- As per the video, is there any difference between A-B and A-A∩B ?(11 votes)
- Nope, they both would be [5,3,12].(1 vote)

- Does it matter in what order species appear in sets?

For example is A = {5, 24, 6, 7}

the same as set B = {24, 7, 6, 5} or would you treat them as different sets?

Thanks in advance!(3 votes)- Yes, you must treat them as different sets. In this case, each set is given a different name. The first is A, the second is B. Even though the ORDER of the items in a set does not matter, the NAME does. So, by giving these sets two different names, you have created two different, distinct sets. You must treat them as such. Hope this helps!(1 vote)

- Since A\B = {5, 3, 12}, can I use a notation like this?

A'

Would the notation above do the same thing? Or do I need a universal set in order to use that notation? I've learned that notation from my teacher.(2 votes)- The first notation means everything in A but not in B.

The second notation means everything not in A.

Regardless of a universal set, these are not the same thing.

And you really can't not have a universal set. Even if it's not stated explicitly, a universal set is probably implied.(5 votes)

- At1:42/ before, does the 6 float off to space?(2 votes)
- That's not a mistake. If we subtract set B from set A, (A-B) all we have to do is remove all elements which are in both sets from set A. 6 is only in set B and not in set A. That's why 6 isn't in the set A-B. Does that answer your question?(4 votes)

- Null is different than zerro right?(0 votes)
- The symbol for a null set does look like a zero doesn't it? But I think that's where the similarities end as it would have been entirely possible for set A to contain a zero in the same way that it could have contained a badger.

In this instance Null means that the set has no member items in it.(8 votes)

- What is a relative complement when you have set C = (39,16 0,10,5,2) and set D = (10,49,7,16,4,12)?(1 vote)
- if C\D , then ( 39, 0, 5, 2)

if D\C , then (49, 7, 4, 12)(4 votes)

- If A-B = ø then A=B is this true or false(2 votes)
- Counterexample:

Let A = ø and B = {x}.

"A - B = ø" = True

"A = B" = False

"If A - B = ø, then A = B"

= "If True, then False"

= False

Therefore, the statement is false.(2 votes)

- PLEASE dont laugh at my ignorance............as far as i know SET IS A COLLECTION OF WELL DEFINED OBJECTS.... What is the well defined object in the null/empty set? How can we call a set an "EMPTY SET"?(1 vote)
- It is well defined as containing nothing.

Sure that idea is abstract, but not any more than understanding the value of 0 (something mathematicians did not for many generations).(4 votes)

## Video transcript

What we're now
going to think about is finding the
differences between sets. And the first way
that we will denote this is we'll start with
set A. I've already defined set A. Let me do it in
that same shade of green. I've already defined set A here. And in both cases, I've defined
these sets with numbers. Instead of having numbers as
being the objects in the set, I could have had farm animals
there or famous presidents, but numbers hopefully
keep things fairly simple. So I'm going to start with
set A. And from set A, I'm going to subtract set B.
So this is one way of thinking about the difference
between set A and set B. And when I've
written it this way, this essentially says give me
the set of all of the objects that are in A with
the things that are in B taken out of that set. So let's think about
what that means. So what's in set A with the
things that are in B taken out? Well, that means-- let's take
set A and take out a 17, a 19-- or take out the 17s,
the 19s, and the 6s. So we're going to be left with--
we're going to have the 5. We're going to have the 3. We're not going to have the
17 because we subtracted out set B. 17 is in set B, so take
out anything that is in set B. So you get the 5, the 3. See, the 12 is not in set B,
so we can keep that in there. And then the 19 is
in set B, so we're going to take out
the 19 as well. And so that is this
right over here is-- you could view it as
set B subtracted from set A. So one way of thinking
about it, like we just said, these are all of
the elements that are in set A that
are not in set B. Another way you
could think about it is, these are all of the
elements that are not in set B, but also in set A. So
let me make it clear. You could view this as
B subtracted from A. Or you could view this as
the relative complement-- I always have trouble
spelling things-- relative complement
of set B in A. And we're going to talk a
lot more about complements in the future. But the complement is the
things that are not in B. And so this is
saying, look, what are all of the things that are
not in B-- so you could say what are all of the things
not in B but are in A? So once again, if you said all
of the things that aren't in B, then you're thinking
about all of the numbers in the whole universe
that aren't 17, 19, or 6. And actually, you could
even think broader. You're not even just
thinking about numbers. It could even be the color
orange is not in set B, so that would be in the
absolute complement of B. I don't see a zebra
here in set B, so that would be its complement. But we're saying, what are
the things that are not in B but are in A? And that would be the
numbers 5, 3, and 12. Now, when we visualized
this as B subtracted from A, you might be saying,
hey, wait, look, look. OK. I could imagine you
took the 17 out. You took the 19 out. But what about taking the 6 out? Shouldn't you have
taken a 6 out? Or in traditional
subtraction, maybe we would end up with a negative
number or something. And when you subtract a set, if
the set you're subtracting from does not have that element, then
taking that element out of it doesn't change it. If I start with set A, and if
I take all the 6s out of set A, it doesn't change it. There was no 6 to begin with. I could take all the
zebras out of set A; it will not change it. Now, another way to denote
the relative complement of set B in A or B
subtracted from A, is the notation that
I'm about to write. We could have
written it this way. A and then we would have had
this little figure like this. That looks eerily
like a division sign, but this also means the
difference between set A and B where we're
talking about-- when we write it this
way, we're talking about all the things in
set A that are not in set B. Or the things in
set B taken out of set A. Or the relative
complement of B in A. Now, with that out of
the way, let's think about things the
other way around. What would B slash--
I'll just call it a slash right over here. What would B minus A be? So what would be B minus A? Which we could also
write it as B minus A. What would this be equal to? Well, just going
back, we could view this as all of the
things in B with all of the things in
A taken out of it. Or all of the things--
the complement of A that happens to
be in B. So let's think of it as
the set B with all of the things in
A taken out of it. So if we start with
set B, we have a 17. But a 17 is in set A, so
we have to take the 17 out. Then we have a 19. But there's a 19 in set A, so
we have to take the 19 out. Then we have a 6. Oh, well, we don't have
to take a 6 out of B because the 6 is not in set A.
So we're left with just the 6. So this would be just the set
with a single element in it, set 6. Now let me ask another question. What would the relative
complement of A in A be? Well, this is the same
thing as A minus A. And this is literally
saying, let's take set A and then take all of the things
that are in set A out of it. Well, I start with the 5. Oh, but there's already a 5. There's a 5 in set A. So
I have to take the 5 out. Well, there's a 3, but
there's a 3 in set A, so I have to take a 3 out. So I'm going to take
all of these things out. And so I'm just going to
be left with the empty set, often called the null set. And sometimes the
notation for that will look like this, the
null set, the empty set. There's a set that has
absolutely no objects in it.