Discrete Mathematics: Wwlchen

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 13

DISCRETE MATHEMATICS

W W L CHEN


c W W L Chen, 1992, 2003.
This chapter is available free to all individuals, on the understanding that it is not to be used for financial gains,
and may be downloaded and/or photocopied, with or without permission from the author.
However, this document may not be kept on any information storage and retrieval system without permission
from the author, unless such system is not accessible to any individuals other than its owners.

Chapter 15
NUMBER OF SOLUTIONS
OF A LINEAR EQUATION

15.1. Introduction

Example 15.1.1. Suppose that 5 new academic positions are to be awarded to 4 departments in
the university, with the restriction that no department is to be awarded more than 3 such positions,
and that the Mathematics Department is to be awarded at least 1. We would like to find out in how
many ways this could be achieved. If we denote the departments by M, P, C, E, where M denotes
the Mathematics Department, and denote by uM , uP , uC , uE the number of positions awarded to these
departments respectively. Then clearly we must have

(1) uM + uP + uC + uE = 5.

Furthermore,

(2) uM ∈ {1, 2, 3} and uP , uC , uE ∈ {0, 1, 2, 3}.

We therefore need to find the number of solutions of the equation (1), subject to the restriction (2).

In general, we would like to find the number of solutions of an equation of the type

u1 + . . . + uk = n,

where n, k ∈ N are given, and where the variables u1 , . . . , uk are to assume integer values, subject to
certain given restrictions.
15–2 W W L Chen : Discrete Mathematics

15.2. Case A – The Simplest Case

Suppose that we are interested in finding the number of solutions of an equation of the type

(3) u1 + . . . + uk = n,

where n, k ∈ N are given, and where the variables

(4) u1 , . . . , uk ∈ {0, 1, 2, 3, . . .}.

PROPOSITION 15A. The number of solutions of the equation (3), subject to the restriction (4), is
given by the binomial coefficient
 
n+k−1
.
n

Proof. Consider a row of (n + k − 1) + signs as shown in the picture below:

+ + + + + + + + + + + + + + + + ... + + + + + + + + + + + + + + + +
  
n+k−1

Let us choose n of these + signs and change them to 1’s. Clearly there are exactly (k − 1) + signs
remaining, the same number of + signs as in the equation (3). The new situation is shown in the picture
below:

(5) 1 .
. . 1 + . . . + 1 .
. . 1
u1 uk
  
k

For example, the picture

+1111 + +1 + 111 + 11 + . . . + 1111111 + 1111 + 11

denotes the information

0 + 4 + 0 + 1 + 3 + 2 + ... + 7 + 4 + 2

(note that consecutive + signs indicate an empty block of 1’s in between, and the + sign at the left-hand
end indicates an empty block of 1’s at the left-hand end; similarly a + sign at the right-hand end would
indicate an empty block of 1’s at the right-hand end). It follows that our choice of the n 1’s corresponds
to a solution of the equation (3), subject to the restriction (4). Conversely, any solution of the equation
(3), subject to the restriction (4), can be illustrated by a picture of the type (5), and so corresponds to
a choice of the n 1’s. Hence the number of solutions of the equation (3), subject to the restriction (4),
is equal to the number of ways we can choose n objects out of (n + k − 1). Clearly this is given by the
binomial coefficient indicated. 

Example 15.2.1. The equation u1 + . . . + u4 = 11, where the variables u1 , . . . , u4 ∈ {0, 1, 2, 3, . . .}, has
   
11 + 4 − 1 14
= = 364
11 11

solutions.
Chapter 15 : Number of Solutions of a Linear Equation 15–3

15.3. Case B – Inclusion-Exclusion

We next consider the situation when the variables have upper restrictions. Suppose that we are interested
in finding the number of solutions of an equation of the type

(6) u1 + . . . + uk = n,

where n, k ∈ N are given, and where the variables

(7) u1 ∈ {0, 1, . . . , m1 }, ..., uk ∈ {0, 1, . . . , mk }.

Our approach is to first of all relax the upper restrictions in (7), and solve instead the Case A
problem of finding the number of solutions of the equation (6), where the variables

(8) u1 , . . . , uk ∈ {0, 1, 2, 3, . . .}.

By Proposition 15A, this relaxed system has


 
n+k−1
n

solutions. Among these solutions will be some which violate the upper restrictions on the variables
u1 , . . . , uk as given in (7).

For every i = 1, . . . , k, let Si denote the collection of those solutions of (6), subject to the relaxed
restriction (8) but which ui > mi . Then we need to calculate

|S1 ∪ . . . ∪ Sk |,

the number of solutions which violate the upper restrictions on the variables u1 , . . . , uk as given in (7).
This can be achieved by using the Inclusion-exclusion principle, but we need to calculate

|Si1 ∩ . . . ∩ Sij |

whenever 1 ≤ i1 < . . . < ij ≤ k. To do this, we need the following simple observation.

PROPOSITION 15B. Suppose that i = 1, . . . , k is chosen and fixed. Then the number of solutions
of the equation (6), subject to the restrictions

(9) ui ∈ {mi + 1, mi + 2, mi + 3, . . .}

and

(10) u1 ∈ B1 , ..., ui−1 ∈ Bi−1 , ui+1 ∈ Bi+1 , ..., uk ∈ Bk ,

where B1 , . . . , Bi−1 , Bi+1 , . . . , Bk are all subsets of N ∪ {0}, is equal to the number of solutions of the
equation

(11) u1 + . . . + ui−1 + vi + ui+1 + . . . + uk = n − (mi + 1),

subject to the restrictions

(12) vi ∈ {0, 1, 2, 3, . . .}

and (10).
15–4 W W L Chen : Discrete Mathematics

Proof. This is immediate on noting that if we write

ui = vi + (mi + 1),

then the restrictions (9) and (12) are the same. Furthermore, equation (6) becomes

u1 + . . . + ui−1 + (vi + (mi + 1)) + ui+1 + . . . + uk = n,

which is the same as equation (11). 

By applying Proposition 15B successively on the subscripts i1 , . . . , ij , we have the following result.

PROPOSITION 15C. Suppose that 1 ≤ i1 < . . . < ij ≤ k. Then


 
n − (mi1 + 1) − . . . − (mij + 1) + k − 1
|Si1 ∩ . . . ∩ Sij | = .
n − (mi1 + 1) − . . . − (mij + 1)

Proof. Note that |Si1 ∩ . . . ∩ Sij | is the number of solutions of the equation (6), subject to the
restrictions

(13) ui ∈ {mi + 1, mi + 2, mi + 3, . . .} whenever i ∈ {i1 , . . . , ij },

and

(14) ui ∈ {0, 1, 2, 3, . . .} whenever i ∈ {i1 , . . . , ij }.

Now write

vi + (mi + 1) if i ∈ {i1 , . . . , ij },
ui =
vi if i ∈
 {i1 , . . . , ij }.

Then by repeated application of Proposition 15B, we can show that the number of solutions of the
equation (6), subject to the restrictions (13) and (14), is equal to the number of solutions of the equation

(15) v1 + . . . + vk = n − (mi1 + 1) − . . . − (mij + 1),

subject to the restriction

(16) vi ∈ {0, 1, 2, 3, . . .}.

This is a Case A problem, and it follows from Proposition 15A that the number of solutions of the
equation (15), subject to the restriction (16), is given by
 
n − (mi1 + 1) − . . . − (mij + 1) + k − 1
.
n − (mi1 + 1) − . . . − (mij + 1)

This completes the proof. 

Example 15.3.1. Consider the equation

(17) u1 + . . . + u4 = 11,

where the variables

(18) u1 , . . . , u4 ∈ {0, 1, 2, 3}.


Chapter 15 : Number of Solutions of a Linear Equation 15–5

Recall that the equation (17), subject to the restriction

(19) u1 , . . . , u4 ∈ {0, 1, 2, 3, . . .},

has
   
11 + 4 − 1 14
=
11 11

solutions. For every i = 1, . . . , 4, let Si denote the collection of those solutions of (17), subject to the
relaxed restriction (19) but which ui > 3. Then we need to calculate

|S1 ∪ . . . ∪ S4 |.

Note that by Proposition 15C,


   
11 − 4 + 4 − 1 10
|S1 | = |S2 | = |S3 | = |S4 | = =
11 − 4 7

and
   
11 − 8 + 4 − 1 6
|S1 ∩ S2 | = |S1 ∩ S3 | = |S1 ∩ S4 | = |S2 ∩ S3 | = |S2 ∩ S4 | = |S3 ∩ S4 | = = .
11 − 8 3

Next, note that a similar argument gives


   
11 − 12 + 4 − 1 2
|S1 ∩ S2 ∩ S3 | = = .
11 − 12 −1

This is meaningless. However, note that |S1 ∩ S2 ∩ S3 | is the number of solutions of the equation

(v1 + 4) + (v2 + 4) + (v3 + 4) + v4 = 11,

subject to the restriction

v1 , v2 , v3 , v4 ∈ {0, 1, 2, 3, . . .}.

This clearly has no solution. Hence

|S1 ∩ S2 ∩ S3 | = |S1 ∩ S2 ∩ S4 | = |S1 ∩ S3 ∩ S4 | = |S2 ∩ S3 ∩ S4 | = 0.

Similarly

|S1 ∩ S2 ∩ S3 ∩ S4 | = 0.

It then follows from the Inclusion-exclusion principle that


4 
|S1 ∪ S2 ∪ S3 ∪ S4 | = (−1)j+1 |Si1 ∩ . . . ∩ Sij |
j=1 1≤i1 <...<ij ≤4

= (|S1 | + |S2 | + |S3 | + |S4 |)


− (|S1 ∩ S2 | + |S1 ∩ S3 | + |S1 ∩ S4 | + |S2 ∩ S3 | + |S2 ∩ S4 | + |S3 ∩ S4 |)
+ (|S1 ∩ S2 ∩ S3 | + |S1 ∩ S2 ∩ S4 | + |S1 ∩ S3 ∩ S4 | + |S2 ∩ S3 ∩ S4 |)
− (|S1 ∩ S2 ∩ S3 ∩ S4 |)
     
4 10 4 6
= − .
1 7 2 3
15–6 W W L Chen : Discrete Mathematics

It now follows that the number of solutions of the equation (17), subject to the restriction (18), is given
by
         
14 14 4 10 4 6
− |S1 ∪ S2 ∪ S3 ∪ S4 | = − + = 4.
11 11 1 7 2 3

15.4. Case C – A Minor Irritation

We next consider the situation when the variables have non-standard lower restrictions. Suppose that
we are interested in finding the number of solutions of an equation of the type

(20) u1 + . . . + uk = n,

where n, k ∈ N are given, and where for each i = 1, . . . , k, the variable

(21) ui ∈ Ii ,

where

(22) Ii = {pi , . . . , mi } or Ii = {pi , pi + 1, pi + 2, . . .}.

It turns out that we can apply the same idea as in Proposition 15B to reduce the problem to a Case
A problem or a Case B problem. For every i = 1, . . . , k, write ui = vi + pi , and let Ji = {x − pi : x ∈ Ii };
in other words, the set Ji is obtained from the set Ii by subtracting pi from every element of Ii . Clearly

(23) Ji = {0, . . . , mi − pi } or Ji = {0, 1, 2, . . .}.

Note also that the equation (20) becomes

(24) v1 + . . . + vk = n − p1 − . . . − pk .

It is easy to see that the number of solutions of the equation (20), subject to the restrictions (21) and
(22), is the same as the number of solutions of the equation (24), subject to the restrictions vi ∈ Ji and
(23).

Example 15.4.1. Consider the equation

(25) u1 + . . . + u4 = 11,

where the variables

(26) u1 ∈ {1, 2, 3} and u2 , u3 , u4 ∈ {0, 1, 2, 3}.

We can write u1 = v1 + 1, u2 = v2 , u3 = v3 and u4 = v4 . Then

(27) v1 ∈ {0, 1, 2} and v2 , v3 , v4 ∈ {0, 1, 2, 3}.

Furthermore, the equation (25) becomes

(28) v1 + . . . + v4 = 10.

The number of solutions of the equation (25), subject to the restriction (26), is equal to the number of
solutions of the equation (28), subject to the restriction (27). We therefore have a Case B problem.
Chapter 15 : Number of Solutions of a Linear Equation 15–7

Example 15.4.2. Consider the equation

(29) u1 + . . . + u6 = 23,

where the variables

(30) u1 , u2 , u3 ∈ {1, 2, 3, 4, 5, 6} and u4 , u5 ∈ {2, 3, 4, 5} and u6 ∈ {3, 4, 5}.

We can write u1 = v1 + 1, u2 = v2 + 1, u3 = v3 + 1, u4 = v4 + 2, u5 = v5 + 2 and u6 = v6 + 3. Then

(31) v1 , v2 , v3 ∈ {0, 1, 2, 3, 4, 5} and v4 , v5 ∈ {0, 1, 2, 3} and v6 ∈ {0, 1, 2}.

Furthermore, the equation (29) becomes

(32) v1 + . . . + v6 = 13.

The number of solutions of the equation (29), subject to the restriction (30), is equal to the number
of solutions of the equation (32), subject to the restriction (31). We therefore have a Case B problem.
Consider first of all the Case A problem, where the upper restrictions on the variables v1 , . . . , v6 are
relaxed. By Proposition 15A, the number of solutions of the equation (32), subject to the relaxed
restriction

(33) v1 , . . . , v6 ∈ {0, 1, 2, 3, . . .},

is given by the binomial coefficient


   
13 + 6 − 1 18
= .
13 13

Let

S1 = {(v1 , . . . , v6 ) : (32) and (33) hold and v1 > 5},


S2 = {(v1 , . . . , v6 ) : (32) and (33) hold and v2 > 5},
S3 = {(v1 , . . . , v6 ) : (32) and (33) hold and v3 > 5},
S4 = {(v1 , . . . , v6 ) : (32) and (33) hold and v4 > 3},
S5 = {(v1 , . . . , v6 ) : (32) and (33) hold and v5 > 3},
S6 = {(v1 , . . . , v6 ) : (32) and (33) hold and v6 > 2}.

Then we need to calculate

|S1 ∪ . . . ∪ S6 |.

Note that by Proposition 15C,


   
13 − 6 + 6 − 1 12
|S1 | = |S2 | = |S3 | = = ,
13 − 6 7
   
13 − 4 + 6 − 1 14
|S4 | = |S5 | = = ,
13 − 4 9
   
13 − 3 + 6 − 1 15
|S6 | = = .
13 − 3 10
15–8 W W L Chen : Discrete Mathematics

Also
   
13 − 12 + 6 − 1 6
|S1 ∩ S2 | = |S1 ∩ S3 | = |S2 ∩ S3 | = = ,
13 − 12 1
   
13 − 10 + 6 − 1 8
|S1 ∩ S4 | = |S1 ∩ S5 | = |S2 ∩ S4 | = |S2 ∩ S5 | = |S3 ∩ S4 | = |S3 ∩ S5 | = = ,
13 − 10 3
   
13 − 9 + 6 − 1 9
|S1 ∩ S6 | = |S2 ∩ S6 | = |S3 ∩ S6 | = = ,
13 − 9 4
   
13 − 8 + 6 − 1 10
|S4 ∩ S5 | = = ,
13 − 8 5
   
13 − 7 + 6 − 1 11
|S4 ∩ S6 | = |S5 ∩ S6 | = = ,
13 − 7 6

and

|S1 ∩ S2 ∩ S3 | = |S1 ∩ S2 ∩ S4 | = |S1 ∩ S2 ∩ S5 | = |S1 ∩ S2 ∩ S6 | = |S1 ∩ S3 ∩ S4 |


= |S1 ∩ S3 ∩ S5 | = |S1 ∩ S3 ∩ S6 | = |S1 ∩ S4 ∩ S5 | = |S2 ∩ S3 ∩ S4 |
= |S2 ∩ S3 ∩ S5 | = |S2 ∩ S3 ∩ S6 | = |S2 ∩ S4 ∩ S5 | = |S3 ∩ S4 ∩ S5 | = 0,
|S1 ∩ S4 ∩ S6 | = |S1 ∩ S5 ∩ S6 | = |S2 ∩ S4 ∩ S6 | = |S2 ∩ S5 ∩ S6 | = |S3 ∩ S4 ∩ S6 |
   
13 − 13 + 6 − 1 5
= |S3 ∩ S5 ∩ S6 | = = ,
13 − 13 0
   
13 − 11 + 6 − 1 7
|S4 ∩ S5 ∩ S6 | = = .
13 − 11 2

Finally, note that

|Si1 ∩ . . . ∩ Si4 | = 0 whenever 1 ≤ i1 < . . . < i4 ≤ 6,


|Si1 ∩ . . . ∩ Si5 | = 0 whenever 1 ≤ i1 < . . . < i5 ≤ 6,

and

|S1 ∩ . . . ∩ S6 | = 0.

It follows from the Inclusion-exclusion principle that


6 
|S1 ∪ . . . ∪ S6 | = (−1)j+1 |Si1 ∩ . . . ∩ Sij |
j=1 1≤i1 <...<ij ≤6
                      
12 14 15 6 8 9 10 11 5 7
= 3 +2 + − 3 +6 +3 + +2 + 6 + .
7 9 10 1 3 4 5 6 0 2

Hence the number of solutions of the equation (29), subject to the restriction (30), is equal to
 
18
− |S1 ∪ . . . ∪ S6 |
13
        
18 12 14 15
= − 3 +2 +
13 7 9 10
               
6 8 9 10 11 5 7
+ 3 +6 +3 + +2 − 6 + .
1 3 4 5 6 0 2
Chapter 15 : Number of Solutions of a Linear Equation 15–9

15.5. Case Z – A Major Irritation

Suppose that we are interested in finding the number of solutions of the equation

u1 + . . . + u4 = 23,

where the variables

u1 , u2 ∈ {1, 3, 5, 7, 9} and u3 , u4 ∈ {3, 6, 7, 8, 9, 10, 11, 12}.

Then it is very difficult and complicated, though possible, to make our methods discussed earlier work.
We therefore need a slightly better approach. We turn to generating functions which we first studied in
Chapter 14.

15.6. The Generating Function Method

Suppose that we are interested in finding the number of solutions of an equation of the type

(34) u1 + . . . + uk = n,

where n, k ∈ N are given, and where, for every i = 1, . . . , k, the variable

(35) ui ∈ Bi ,

where

(36) B1 , . . . , Bk ⊆ N ∪ {0}.

For every i = 1, . . . , k, consider the formal (possibly finite) power series



(37) fi (X) = X ui
ui ∈Bi

corresponding to the variable ui in the equation (34), and consider the product

   
f (X) = f1 (X) . . . fk (X) = X u1
... X uk
= ... X u1 +...+uk .
u1 ∈B1 uk ∈Bk u1 ∈B1 uk ∈Bk

We now rearrange the right-hand side and sum over all those terms for which u1 + . . . + uk = n. Then
we have
   

  ∞
      n
f (X) =  X u1 +...+uk  =  1
   X .
n=0 u1 ∈B1 ,...,uk ∈Bk n=0 u1 ∈B1 ,...,uk ∈Bk
u1 +...+uk =n u1 +...+uk =n

We have therefore proved the following important result.

PROPOSITION 15D. The number of solutions of the equation (34), subject to the restrictions (35)
and (36), is given by the coefficient of X n in the formal (possible finite) power series

f (X) = f1 (X) . . . fk (X),

where, for each i = 1, . . . , k, the formal (possibly finite) power series fi (X) is given by (37).
15–10 W W L Chen : Discrete Mathematics

The main difficulty in this method is to calculate this coefficient.

Example 15.6.1. The number of solutions of the equation (29), subject to the restriction (30), is given
by the coefficient of X 23 in the formal power series

f (X) = (X 1 + . . . + X 6 )3 (X 2 + . . . + X 5 )2 (X 3 + . . . + X 5 )
 3  2 2  3 
X − X7 X − X6 X − X6
=
1−X 1−X 1−X
= X 10 (1 − X 6 )3 (1 − X 4 )2 (1 − X 3 )(1 − X)−6 ;

or the coefficient of X 13 in the formal power series

g(X) = (1 − X 6 )3 (1 − X 4 )2 (1 − X 3 )(1 − X)−6 = h(X)(1 − X)−6 ,

where

h(X) = (1 − X 6 )3 (1 − X 4 )2 (1 − X 3 )
= (1 − 3X 6 + 3X 12 − X 18 )(1 − 2X 4 + X 8 )(1 − X 3 )
= 1 − X 3 − 2X 4 − 3X 6 + 2X 7 + X 8 + 3X 9 + 6X 10 − X 11 + 3X 12 − 6X 13
+ terms with higher powers in X.

It follows that the coefficient of X 13 in g(X) is given by

1 × coefficient of X 13 in (1 − X)−6 − 1 × coefficient of X 10 in (1 − X)−6


− 2 × coefficient of X 9 in (1 − X)−6 − 3 × coefficient of X 7 in (1 − X)−6
+ 2 × coefficient of X 6 in (1 − X)−6 + 1 × coefficient of X 5 in (1 − X)−6
+ 3 × coefficient of X 4 in (1 − X)−6 + 6 × coefficient of X 3 in (1 − X)−6
− 1 × coefficient of X 2 in (1 − X)−6 + 3 × coefficient of X 1 in (1 − X)−6
− 6 × coefficient of X 0 in (1 − X)−6 .

Using Example 14.3.1, we see that this is equal to


           
−6 −6 −6 −6 −6 −6
(−1)13 − (−1)10 − 2(−1)9 − 3(−1)7 + 2(−1)6 + (−1)5
13 10 9 7 6 5
         
−6 −6 −6 −6 −6
+ 3(−1)4 + 6(−1)3 − (−1)2 + 3(−1)1 − 6(−1)0
4 3 2 1 0
                     
18 15 14 12 11 10 9 8 7 6 5
= − −2 −3 +2 + +3 +6 − +3 −6
13 10 9 7 6 5 4 3 2 1 0

as in Example 15.4.2.

Example 15.6.2. The number of solutions of the equation

u1 + . . . + u10 = 37,

subject to the restriction

u1 , . . . , u5 ∈ {1, 2, 3, 4, 5, 6} and u6 , . . . , u9 ∈ {2, 3, 4, 5, 6, 7, 8} and u10 ∈ {5, 10, 15, . . .},

is given by the coefficient of X 37 in the formal power series

f (X) = (X 1 + . . . + X 6 )5 (X 2 + . . . + X 8 )4 (X 5 + X 10 + X 15 + . . .)
 5  2 4  
X − X7 X − X9 X5
= = X 18 (1 − X 6 )5 (1 − X 7 )4 (1 − X)−9 (1 − X 5 )−1 ;
1−X 1−X 1 − X5
Chapter 15 : Number of Solutions of a Linear Equation 15–11

or the coefficient of X 19 in the formal power series

g(X) = (1 − X 6 )5 (1 − X 7 )4 (1 − X)−9 (1 − X 5 )−1 = h(X)(1 − X)−9 (1 − X 5 )−1 ,

where

h(X) = (1 − X 6 )5 (1 − X 7 )4
= (1 − 5X 6 + 10X 12 − 10X 18 + 5X 24 − X 30 )(1 − 4X 7 + 6X 14 − 4X 21 + X 28 )
= 1 − 5X 6 − 4X 7 + 10X 12 + 20X 13 + 6X 14 − 10X 18 − 40X 19
+ terms with higher powers in X.

It follows that the coefficient of X 19 in g(X) is given by

1 × coefficient of X 19 in (1 − X)−9 (1 − X 5 )−1 − 5 × coefficient of X 13 in (1 − X)−9 (1 − X 5 )−1


− 4 × coefficient of X 12 in (1 − X)−9 (1 − X 5 )−1 + 10 × coefficient of X 7 in (1 − X)−9 (1 − X 5 )−1
+ 20 × coefficient of X 6 in (1 − X)−9 (1 − X 5 )−1 + 6 × coefficient of X 5 in (1 − X)−9 (1 − X 5 )−1
− 10 × coefficient of X 1 in (1 − X)−9 (1 − X 5 )−1 − 40 × coefficient of X 0 in (1 − X)−9 (1 − X 5 )−1 .

This is equal to
            
−9 −1 −9 −1 −9 −1
(−1)19 (−1)0 + (−1)14 (−1)1 + (−1)9 (−1)2
19 0 14 1 9 2
   
−9 −1
+ (−1)4 (−1)3
4 3
            
−9 −1 −9 −1 −9 −1
− 5 (−1)13 (−1)0 + (−1)8 (−1)1 + (−1)3 (−1)2
13 0 8 1 3 2
            
−9 −1 −9 −1 −9 −1
− 4 (−1)12 (−1)0 + (−1)7 (−1)1 + (−1)2 (−1)2
12 0 7 1 2 2
        
−9 −1 −9 −1
+ 10 (−1)7 (−1)0 + (−1)2 (−1)1
7 0 2 1
        
−9 −1 −9 −1
+ 20 (−1)6 (−1)0 + (−1)1 (−1)1
6 0 1 1
        
−9 −1 −9 −1
+ 6 (−1)5 (−1)0 + (−1)0 (−1)1
5 0 0 1
    
−9 −1
− 10 (−1)1 (−1)0
1 0
   
−9 −1
− 40(−1)0 (−1)0
0 0
                   
27 22 17 12 21 16 11 20 15 10
= + + + −5 + + −4 + +
19 14 9 4 13 8 3 12 7 2
               
15 10 14 9 13 8 9 8
+ 10 + + 20 + +6 + − 10 − 40 .
7 2 6 1 5 0 1 0
Let us reconsider this same question by using the Inclusion-exclusion principle. In view of Proposition
15B, the problem is similar to the problem of finding the number of solutions of the equation

v1 + . . . + v10 = 19,

subject to the restrictions v1 , . . . , v5 ∈ {0, 1, 2, 3, 4, 5}, v6 , . . . , v9 ∈ {0, 1, 2, 3, 4, 5, 6} and v10 ∈ {0, 5, 10,
15, . . .}. Clearly we must have four cases: (I) v10 = 0; (II) v10 = 5; (III) v10 = 10; and (IV) v10 = 15.
The number of case (I) solutions is equal to the number of solutions of the equation

v1 + . . . + v9 = 19,
15–12 W W L Chen : Discrete Mathematics

subject to the restriction

(38) v1 , . . . , v5 ∈ {0, 1, 2, 3, 4, 5} and v6 , . . . , v9 ∈ {0, 1, 2, 3, 4, 5, 6}.

Using the Inclusion-exclusion principle, we can show that the number of solutions is given by
               
27 21 20 15 14 13 9 8
−5 −4 + 10 + 20 +6 − 10 − 40 .
19 13 12 7 6 5 1 0

The number of case (II) solutions is equal to the number of solutions of the equation

v1 + . . . + v9 = 14,

subject to the restriction (38). This can be shown to be


           
22 16 15 10 9 8
−5 −4 + 10 + 20 +6 .
14 8 7 2 1 0

The number of case (III) solutions is equal to the number of solutions of the equation

v1 + . . . + v9 = 9,

subject to the restriction (38). This can be shown to be


     
17 11 10
−5 −4 .
9 3 2

Finally, the number of case (IV) solutions is equal to the number of solutions of the equation

v1 + . . . + v9 = 4,

subject to the restriction (38). This can be shown to be


 
12
.
4

Problems for Chapter 15

1. Consider the linear equation u1 + . . . + u6 = 29. Use the arguments in Sections 15.2–15.4 to solve
the following problems:
a) How many solutions satisfy u1 , . . . , u6 ∈ {0, 1, 2, 3, . . .}?
b) How many solutions satisfy u1 , . . . , u6 ∈ {0, 1, 2, 3, . . . , 7}?
c) How many solutions satisfy u1 , . . . , u6 ∈ {2, 3, . . . , 7}?
d) How many solutions satisfy u1 , u2 , u3 ∈ {1, 2, 3, . . . , 7} and u4 , u5 , u6 ∈ {2, 3, . . . , 6}?

2. Consider the linear equation u1 + . . . + u7 = 34. Use the arguments in Sections 15.2–15.4 to solve
the following problems:
a) How many solutions satisfy u1 , . . . , u7 ∈ {0, 1, 2, 3, . . .}?
b) How many solutions satisfy u1 , . . . , u7 ∈ {0, 1, 2, 3, . . . , 7}?
c) How many solutions satisfy u1 , . . . , u7 ∈ {2, 3, 4, . . . , 7}?
d) How many solutions satisfy u1 , . . . , u4 ∈ {1, 2, 3, . . . , 8} and u5 , . . . , u7 ∈ {3, 4, 5, . . . , 7}?

3. How many natural numbers x ≤ 99999999 are such that the sum of the digits in x is equal to 35?
How many of these numbers are 8-digit numbers?
Chapter 15 : Number of Solutions of a Linear Equation 15–13

4. Rework Questions 1 and 2 using generating functions.

5. Use generating functions to find the number of solutions of the linear equation u1 + . . . + u5 = 25
subject to the restrictions that u1 , . . . , u4 ∈ {1, 2, 3, . . . , 8} and u5 ∈ {2, 3, 13}.

6. Consider again the linear equation u1 + . . . + u7 = 34. How many solutions of this equation satisfy
u1 , . . . , u6 ∈ {1, 2, 3, . . . , 8} and u7 ∈ {2, 3, 5, 7}?

You might also like