Efficient Computation of Binomial Coefficients and Applications

Abstract

Binomial coefficients can be computed very efficiently by
the construction of Pascal triangle. Analogous to this construction, we shall
derive efficient methods to compute bk=åi=0k Cki ai etc. Practical
applications of such methods include polynomial basis conversion,
reparametrisation, and subdivision.

1 Introduction

In interpolation and approximation, polynomials are employed for data fitting
[1]. In computational geometry, polynomial curves (e.g., Bézier and B-spline
polynomial curves) are used to describe the shape of geometric entities [2-3].
For the purpose of evaluating or manipulating a polynomial, it is often
required to convert a polynomial of one basis to another or subdivide an
interval over which a polynomial is defined. Accordingly, we shall need to
compute the following coefficients:

bk=

kåi=0

Cki ai, bk=

nåi=k

Cik ai, bk=

kåi=0

Cn-ik-iai, ¼ (k=0, 1, ¼, n)

where,

Cni=

æç
è

n

i

ö÷
ø

=

n!(n-i)! i!

are called the binomial coefficients. Assume a table of binomial
coefficients is given. Then, a straight forward method to compute, for example,
bk=åi=0k Cki pi (k=1,2,...,n) is to multiply pi by Cki
and then add them together. However, even with the supply of binomial
coefficients, this simple method requires n(n-1)/2 multiplications and the
same number of additions. In this paper, we shall derive an efficient
algorithm to compute bk. Using our method, only n(n-1)/2 additions are
needed to compute all bk=åi=0k Cki pi (k=0, 1, ..., n) in the
absence of a table of binomial coefficients.

Our methods are derived analogously to the construction of Pascal triangle, the
well-known algorithm to compute binomial coefficients. Some practical
applications of our methods are given in this paper.

2 Computing bk=åi=0k Cki ai and
bk=åi=0k Cki aibi

We start our discussion by considering computation of binomial coefficients.
It is taught in a high school that Cni=Cn-1i-1+Cn-1i. From this
property, we can derive an efficient algorithm to compute binomial
coefficients

This method is commonly known as the construction of Pascal triangle. It
is seen that only n(n-1)/2 additions are needed to obtain all Cki
(k=1,2,¼,n; i=1,2,¼,k). When n=3, the Pascal triangle is given
by

1

1

1

1

2

1

1

3

3

1

We now consider computation of bk=åi=0k Cki ai. For n=3, we have

æçç
ççè

b0

b1

b2

b3

ö÷÷
÷÷ø

=

æçç
ççè

1

0

0

0

1

1

0

0

1

2

1

0

1

3

3

1

ö÷÷
÷÷ø

æçç
ççè

a0

a1

a2

a3

ö÷÷
÷÷ø

=

æçç
ççè

a0

a0+a1

a0+2a1+a2

a0+3a1+3a2+a3

ö÷÷
÷÷ø

.

It is noted that the transformation matrix resembles the property of Pascal
triangle. Therefore, analogous to the construction of Pascal triangle, we may
derive the following method to compute bk

We now consider the application of the above method. In computational geometry,
a Bézier polynomial is commonly used to describe the shape of geometric
entity. A Bézier polynomial of degree n may be represented in terms of
Bernstein polynomials [2-3]:

P(t)=

nåi=0

Cni(1-t)n-iti pi.

For efficient evaluation of Bézier polynomial and its derivatives, we often
convert it into a canonical polynomial so that Horner method can be employed.
By the binomial expansion theorem, we have

nåi=0

Cni(1-t)n-itipi =

nåi=0

n-iåj=0

(-1)jCniCn-ijpiti+j.

Then, we want to find bk such that

nåk=0

bktk=

nåi=0

n-iåj=0

(-1)jCniCn-ijpiti+j.

Since the coefficients of the same degree terms at both sides should be equal,
we thus have

bk=

kåi=0

k-iåj=k-i

(-1)jCniCn-ijpiti+j =

kåi=0

(-1)k-iCniCn-ik-ipi.

From the relation CniCn-ik-i=CnkCki, we obtain

bk=

kåi=0

(-1)k-iCnkCkipi = (-1)kCnk

kåi=0

(-1)iCkipi.

To compute bk efficiently, we first evaluate åi=0k(-1)iCkipi
using the above method, then multiply the results by (-1)kCnk (noting that
Cnk=[(n-k+1)/k]Cnk-1). The pseudo code is given as
follows:

It should be noted that the third block may be replaced by directly
multiplying bk by (-1)kCnk if one's system has a table of binomial
coefficients.

3 Compute bk=åi=kn Cikai,
bk=åi=kn Cikaibi-k

In this section, we are concerned with efficient evaluation of
bk=åi=kn Cikai with k=0,1,¼,n. For n=3, we have

æçç
ççè

b0

b1

b2

b3

ö÷÷
÷÷ø

=

æçç
ççè

1

1

1

1

0

1

2

3

0

0

1

3

0

0

0

1

ö÷÷
÷÷ø

æçç
ççè

a0

a1

a2

a3

ö÷÷
÷÷ø

=

æçç
ççè

a0+a1+a2+a3

a1+2a2+3a3

a2+3a3

a3

ö÷÷
÷÷ø

.

From this special case, we can see that the transpose of a transformation
matrix resembles the property of Pascal triangle. Therefore, analogous to the
construction of Pascal triangle we can derive the following algorithm to
compute bk=åi=kn Cikai:

4 Compute bk=åi=0k Cn-ik-iai,
bk=åi=0k Cn-ik-iaibk-i

In this section, we are concerned with efficient evaluation of
bk=åi=0k Cn-ik-iai with k=0,1,¼,n. For n=3, we have

æçç
ççè

b0

b1

b2

b3

ö÷÷
÷÷ø

=

æçç
ççè

1

0

0

0

3

1

0

0

3

2

1

0

1

1

1

1

ö÷÷
÷÷ø

æçç
ççè

a0

a1

a2

a3

ö÷÷
÷÷ø

=

æçç
ççè

a0

3a0+a1

3a0+2a1+a2

a0+a1+a2+a3

ö÷÷
÷÷ø

.

From this special case, we can see that the transpose of a transformation
matrix resembles the property of Pascal triangle. Therefore, analogous to the
construction of Pascal triangle, we give the following method to compute bk:

To illustrate an application of the above method, we consider reparametrising a
vector-valued rational curve r(t)=(x(t),y(t),z(t)) by t=t(u) such that

r(u)=r(t), r¢(u)|u=0 = ar¢(t)|t=0.

Such reparametrisation is required whenever we want change the derivatives at
the end points without affecting the geometric shape of the curve. In addition
to the requirement of modifying the derivative at t=0, we also want to keep
the degree of curve and the parameter interval unchanged. To meet all these
requirements, the following bilinear transformation is a choice

t=

au(a-1)u+1

=

aubu+1

(u Î [0,1], t Î [0,1]).

By the chain rule of differentiation we have
r¢(u)=r¢(t)t¢(u). Then, it is readily checked that
r¢(u)|u=0=ar¢(t)|t=0.

We denote r(t)=(x(t),y(t),z(t)) in homogeneous coordinate system by
R(t)=(X(t),Y(t),Z(t),W(t)) and write R(t) in the canonical form
R(t)=åk=0nak tk, where ak=(xk,yk,zk,wk) are
vectors in homogeneous coordinates. Replacing t in R(t) by t=t(u),
we have

R(u)=

nåi=0

ai

æç
è

aubu+1

ö÷
ø

i

=

1(bu+1)n

nåi=0

ai(au)i(bu+1)n-i.

Since R(u) is represented in homogeneous coordinates, the common factor
1/(bu+1)n can be discarded. Therefore, we have

R(u) =

nåi=0

ai(au)i(bu+1)n-i.

By the binomial expansion theorem we obtain

R(u)=

nåi=0

n-iåj=0

aiaiCn-ijbj ui+j.

We now want to find bk such that

nåk=0

bkuk=

nåi=0

n-iåj=0

aiai Cn-ijbj ui+j.

Since the same degree terms at both side should be equal, we can then derive

bk=

kåi=0

k-iåj=k-i

aiaiCn-ijbj =

kåi=0

aiaiCn-ik-ibk-i.

Let [`(ai)]=aiai. Then,
bk=åi=0k Cn-ik-i[`(ai)]bk-i (k=0,1,¼,n), which can be computed very efficiently using the method we discussed
earlier.

5 Conclusions

Binomial coefficients can be computed very efficiently by the construction
of Pascal triangle. Based on an observation of this construction, we derived
efficient methods to compute bk=åi=0k Cki ai,
bk=åi=kn Cik ai, etc. Applications of these methods in
computational geometry and approximation were also discussed. Although not all
possible combinations of the binomial coefficients and ai were considered
in this paper, one can analogously derive a respective method to meet his own
requirement.