Docsity

Finite Calculus: Derivation and Use of Discrete Sums and Falling Powers, Study notes of Calculus

Toggle sidebar
bg1
Finite Calculus:
A Tutorial for Solving Nasty Sums
David Gleich
January 17, 2005
Abstract
In this tutorial, I will first explain the need for finite calculus using an example sum
I think is difficult to solve. Next, I will show where this sum actually occurs and why it
is important. Following that, I will present all the mathematics behind finite calculus
and a series of theorems to make it helpful before concluding with a set of examples to
show that it really is useful.
Contents
1 How to Evaluate Pn
x=1 x2? 2
2 The Computational Cost of Gaussian Elimination 3
3 The Finite Calculus 4
3.1 Discrete Derivative . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
3.2 The Indefinite Sum and the Discrete Anti-Derivative . . . . . . . . . . . 7
3.3 Helpful Finite Calculus Theorems . . . . . . . . . . . . . . . . . . . . . . 8
4 Making Finite Calculus Useful:
Stirling and His Numbers 10
4.1 Stirling Numbers (of the Second Kind) . . . . . . . . . . . . . . . . . . . 12
4.2 Proving the Theorem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
4.3 Computing Stirling Numbers . . . . . . . . . . . . . . . . . . . . . . . . 15
5 Examples Galore... 16
5.1 Pn
x=1 x2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
5.2 A Double Sum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
5.3 Average Codeword Length . . . . . . . . . . . . . . . . . . . . . . . . . . 17
6 Conclusion 18
1
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12

Partial preview of the text

Download Finite Calculus: Derivation and Use of Discrete Sums and Falling Powers and more Study notes Calculus in PDF only on Docsity!

Finite Calculus:

A Tutorial for Solving Nasty Sums

David Gleich

January 17, 2005

Abstract In this tutorial, I will first explain the need for finite calculus using an example sum I think is difficult to solve. Next, I will show where this sum actually occurs and why it is important. Following that, I will present all the mathematics behind finite calculus and a series of theorems to make it helpful before concluding with a set of examples to show that it really is useful.

Contents

1 How to Evaluate

∑n x=1 x

2 The Computational Cost of Gaussian Elimination 3

3 The Finite Calculus 4 3.1 Discrete Derivative.............................. 5 3.2 The Indefinite Sum and the Discrete Anti-Derivative........... 7 3.3 Helpful Finite Calculus Theorems...................... 8

4 Making Finite Calculus Useful: Stirling and His Numbers 10 4.1 Stirling Numbers (of the Second Kind)................... 12 4.2 Proving the Theorem............................. 14 4.3 Computing Stirling Numbers........................ 15

5 Examples Galore... 16

∑n x=1 x

5.2 A Double Sum................................ 16 5.3 Average Codeword Length.......................... 17

6 Conclusion 18

1 How to Evaluate

∑n

x=1 x

One of the problems we’ll^1 learn to address during this tutorial is how to mechanically (i.e. without much thinking) compute the closed form value of the sum

∑^ n

x=

x^2. (1)

While many students may already know the closed form answer to this particular question, our quest for the answer will lead us to techniques to easily evaluate nasty sums such as (^) n ∑

x=

∑^ m

y=

(x + y)^2 (2)

and (^) n ∑

x=

x 2 x. (3)

Since we’ll be using

∑n x=1 x (^2) as a motivating example, we’ll first familiarize our- selves with the first few values of this function.

∑^ n^1 2 3 4 5 n x=1 x

Now, we’ll try a few techniques to evaluate this sum before honing in on the correct answer. The astute student reading this tutorial may have surmised that we’ll make some connection with calculus at some point. Hence, let’s see what happens if we just “pretend” that this was an integral from calculus instead. Switching the

to a

sign gives ∑n

x=

x^2 =?

∫ (^) n

1

x^2 dx.

Using calculus, we can immediately solve the integral formulation.

∑^ n

x=

x^2 =? n^3 3

Sadly, trying n = 2 shows us that this is wrong.

∑^2

x=

x^2 =?

Graphically, we can see what went wrong in this derivation. (^1) Since I like to keep things informal, if I say we in the text, I really mean you and I. (^2) Interesting trivia: The integral symbol was actually a long letter S for “summa” [3]. So such a substi-

tution makes sense at least alphabetically.

Algorithm 1 Gaussian Elimination

Require: A ∈ Rm×m

U = A, L = I

for k = 1 to m − 1 do

for j = k + 1 to m do

ljk = ujk/ukk

uj,k ~:m = uj,k~:m − ljk uk,k~:m

end for

end for

In this tutorial, I won’t give a full derivation of Gaussian Elimination, but simply give the algorithm (from [4]) and analyze its computational cost. The computational cost of an algorithm is the number of addition, subtraction, multiplication, and division operations performed during the algorithm. To analyze this cost, we’ll look at how much work is done at each step of Gaussian Elimination, that is, each iteration of the outer loop. In the case when k = 1, then we let j go between 2 and m. In the inner loop, we perform 1 division (ljk = ujk/ukk), m multiplications (ljk uk,k~:m), and m subtractions. Since we run this inner loop m − 1 times, we have 2 m(m − 1) + (m − 1) = 2m^2 − 1 ≤ 2 m^2 work on the first step. On the second step, we let j go between 3 and m. In the inner loop, we now perform 1 division, m − 1 multiplications, and m − 1 subtractions, for a total of 2(m − 2)(m − 1) + (m − 2) ≤ 2(m − 1)^2. This pattern continues for each of the following outer steps. Thus, the total runtime of Gaussian Elimination is less than

2 m^2 + 2(m − 1)^2 + 2(m − 2)^2 +... + 1 =

∑^ m

x=

2 x^2 = 2

∑^ m

x=

x^2.

Since we looked up the answer to this sum in the previous section, we know that Gaussian Elimination takes less

2

∑^ m

x=

x^2 = 2 m(m + 1)(2m + 1) 6

m^3 + m^2 +

m

total additions, subtractions, multiplications, and divisions. Now, let’s start determin- ing how we can compute

∑n x=1 x (^2) ourselves.

3 The Finite Calculus

Before launching into the derivation of finite calculus, I should probably explain what it is. By analogy with infinite calculus, we seek a “closed form” expression for sums of the form ∑b

x=a

f (x).

By closed form, we mean involving some set of fundamental operations, such as addi- tion, multiplication, exponentiation, and even factorials. Whereas in infinite calculus, we needed to compute the area under a function exactly, in finite calculus we want to compute the area under a sequence exactly. We call this finite calculus because each sum is composed of a finite (rather than infinite) set of terms. One way to think of finite calculus is calculus on the integers rather than the real numbers. In calculus, we used the notion of derivative and anti-derivative along with the fundamental theorem of calculus to write the closed form solution of ∫ (^) b

a

f (x) dx = F (b) − F (a),

where d dx

F (x) = f (x).

Our immediate goal for finite calculus (and this section) is to develop a fundamental theorem of finite calculus of a similar form.

3.1 Discrete Derivative

Before we can hope to find the fundamental theorem of finite calculus, our first goal is to develop a notion of “derivative.” Recall from calculus that

d dx

f (x) = lim h→ 0

f (x + h) − f (x) h

Since we aren’t allowing real numbers, the closest we can get to 0 is 1 (that is, without actually getting to 0). Then, the discrete derivative is

∆f (x) = f (x + 1) − f (x).

(As an aid to those readers who are skimming this tutorial, we’ll repeat this and future definitions in a formal definition statement.)

Definition (Discrete Derivative). The discrete derivative of f (x) is defined as

∆f (x) = f (x + 1) − f (x).

What can we do with our new derivative? From calculus, we found that it was simple to take the derivative of powers f (x) = xm.

d dx xm^ = mxm−^1.

Hopefully, we’ll find such a simple derivative for finite powers as well.

∆xm^ = (x + 1)m^ − xm^ =? mxm−^1.

A quick check shows that ∆x = (x + 1) − x = 1,

Proof. The proof is straight from the definition.

∆ (f (x) + g(x)) = f (x + 1) + g(x + 1) − f (x) − g(x).

Rearranging terms, we get

∆ (f (x) + g(x)) = ∆f (x) + ∆g(x).

Theorem 3.3. The discrete derivative of a constant times a function is the constant times the discrete derivative of the function.

∆ (cf (x)) = c∆f (x).

Proof. Simply factor out the constant from the application of the definition of the discrete derivative.

3.2 The Indefinite Sum and the Discrete Anti-Derivative

With some handle on what our finite derivative does, let’s move on to discrete integra- tion. First, we’ll define some notation.

Definition (Discrete Anti-Derivative). A function f (x) with the property that ∆f (x) = g(x) is called the discrete anti-derivative of g. We denote the class of func- tions satisfying this property as the indefinite sum of g(x),

∑ g(x) δx = f (x) + C,

where C is an arbitrary constant.

g(x) δx is also called the indefinite sum of g(x).

The discrete anti-derivative corresponds to the anti-derivative or indefinite integral from calculus. ∫ g(x) dx = f (x) + c

g(x) δx = f (x) + C

So far, all we’ve done is establish some notation. We have not shown any anti- derivatives yet. However, we can easily do just that. Recall that

∆xm^ =^ mxm−^1.

Using this fact, along with Theorems 3.2, 3.3, allows us to state that

∑ xm^ δx = xm+ m + 1

+ C.

Now, let’s work toward a fundamental theorem of finite calculus. First, we need to define the notion of a discrete definite integral or definite sum.

Definition (Discrete Definite Integral). Let ∆f (x) = g(x). Then

∑^ b

a

g(x) δx = f (b) − f (a).

With the discrete definite integral, the theorem we’d like to show (by analogy with infinite calculus) is ∑b

a

g(x) δx ? =

∑^ b

x=a

g(x).

Unfortunately, this isn’t true as a quick check shows.

∑^5

1

x δx = x^2 2

5

1

But,

x=1 x^ = 15, so the theorem isn’t true. However, we were very close. Note that ∑^5

1

x δx = 10 =

∑^4

x=

x.

This revised form gives us the correct fundamental theorem of finite calculus.

Theorem 3.4. The fundamental theorem of finite calculus is

∑^ b

a

g(x) δx =

∑^ b−^1

x=a

g(x).

Proof. Here we have more algebra for the proof. Let ∆f (x) = f (x + 1) − f (x) = g(x).

∑^ b−^1

x=a

g(x) =

b∑− 1

x=a

f (x + 1) − f (x)

= f (a + 1) − f (a) + f (a + 2) − f (a + 1) +...

  • f (b) − f (b − 1) = f (b) − f (a),

after the telescoping sum collapses. Now f (b) − f (a) =

∑b a g(x)^ δx^ by definition.

3.3 Helpful Finite Calculus Theorems

Now that we have our fundamental theorem, this section is just a collection of theorems to make finite calculus useful. The uninterested reader can skip to Table 1 at the end. One of the more useful functions from calculus is f (x) = ex. This special function has the property that

D (ex) = ex^ and

ex^ dx = ex^ + C.

Our first theorem is that there is an analogous function in the finite calculus – a function whose derivative is itself. To find it, let’s “round” e. If we do this right, the analog of e should either be 2 or 3, right? Let’s see which one works.

∆ (2x) = 2x+1^ − 2 x^ = 2 · 2 x^ − 2 x^ = (2 − 1)2x^ = 2x. ∆ (3x) = 3x+1^ − 3 x^ = 3 · 3 x^ − 3 x^ = (3 − 1)3x^ = 2 · 3 x.

Thus, e corresponds to the integer 2.

To move from x^3 to x^2 we divide by (x − 2). Then we divide by (x − 1) to go from x^2 to x^1. When we continue this pattern, we get

x−^1 = x^0 /(x + 1) =

x + 1 x−^2 = x−^1 /(x + 2) =

(x + 1)(x + 2)

Definition (Negative Falling Power).

x−m^ =

(x + 1)(x + 2) · · · (x + m)

Let’s check our derivative rule for negative falling powers.

x−m

(x + 2)(x + 3) · · · (x + m + 1)

(x + 1)(x + 2) · · · (x + m)

= (x + 1) − (x + m + 1) (x + 1)(x + 2) · · · (x + m + 1) = mx−m−^1.

Amazingly, I haven’t led you astray here. It does! This fact implies that our formula for the discrete anti-derivative for falling powers holds for negative falling powers as well. Well, our theorem holds, unless m = −1. In that case, we’d get

x−^1 = x 0 0 ,^ which is a problem. Recall from infinite calculus, we had to appeal to the log(x) function to integrate (^) x^1. There is no easy way of getting the correct function intuitively.

Theorem 3.7. Let Hx =

︸ ︷︷ x︸ x

for integer x. The function Hx is the antiderivative of (^) x^1.

Proof.

∆(Hx) =

x + 1

x

x + 1

4 Making Finite Calculus Useful:

Stirling and His Numbers

If you’ve gotten this far, you’re probably thinking. “Great David, we’ve shown all these really neat facts about finite calculus. But, you still haven’t shown me how to solve

∑^ n

x=

x^2

as you promised way back in the introduction.” Well, let’s do that now!

f (x) ∆f (x)

f (x) δx

xm^ mxm−^1 x

m+ m+

x−^1 −x−^2 Hx

2 x^2 x^2 x

cx^ (c − 1)cx^ c

x

( x^ c−^1

m

) ( x

m− 1

) ( x

m+

u(x) + v(x) ∆u(x) + ∆v(x)

u(x) δx +

v(x) δx

u(x)v(x) u(x)∆v(x) + v(x + 1)∆u(x)

u(x)∆v(x) u(x)v(x) −

v(x + 1)∆u(x) δx

Table 1: Here we give a set a useful finite calculus theorems. These

should make solving even nasty sums easy (or at least tractable). All

of the discrete anti-derivatives have the constant omitted for brevity.

In order to solve regular powers, we need to find some way to convert between xm and xm^ so we can use our integration theorems. Let’s see all the conversions we can come up with ourselves.

x^0 = x^0 x^1 = x^1 x^2 = x^2 + x^1 x^3 =???

So we find that the first few powers were easy to convert, but then the higher powers are not so obvious. Let’s see if we can work with

x^3 = ax^3 + bx^2 + cx^1

to come up with a formula for a, b, and c.

ax^3 + bx^2 + cx^1 = [a(x)(x − 1)(x − 2)] + [b(x)(x − 1)] + [c(x)]

[

ax^3 − 3 ax^2 + 2ax

]

[

bx^2 − bx

]

  • [cx] = ax^3 + (b − 3 a)x^2 + (2a − b + c)x.

If we want ax^3 + bx^2 + cx^1 = x^3 ,

then we need the following coefficients

a = 1 (b − 3 a) = 0 (2a − b + c) = 0,

or a = 1, b = 3, and c = 1. Hence, we have

x^3 = x^3 + 3x^2 + x^1.

That was a lot of work just for x^3. I’m not going to attempt x^4 , but feel free if you are so inclined. Instead, I’ll devote the rest of the section to proving the following theorem.

we get the following sets. {♣, ♦}, {♥} {♣, ♥}, {♦} {♦, ♥}, {♣}

So

2

= 3, since there are three ways to put 3 items into 2 non-empty sets. We still don’t really know much about Stirling numbers though. Let’s prove a theorem to help us general new Stirling numbers from previous ones.

Theorem 4.2. (^) { n k

n − 1 k − 1

  • k

n − 1 k

Proof. We’ll give a combinatorial proof of this identity. In a combinatorial proof, we choose a particular quantity and give two ways of counting this quantity. Since these two different ways count the same thing, they must be equal. In this proof, we’ll count the number of ways to partition n distinct objects into k non-empty sets. The obvious way to count this quantity is by using our previous definition of Stirling numbers. By this definition,

{n k

counts the number of ways to partition n distinct objects into k non-empty sets. Now, let’s count this quantity using a different way. I like to call this the “weirdo” method. Let’s pick out one of our distinct objects and call it x, the “weirdo.” We can now count the number of ways to partition n distinct objects into k non-empty sets by keeping track of where the “weirdo” goes. The first possibility is that the “weirdo” is in a set all by itself. In this case, there are

{n− 1 k− 1

ways for the other n − 1 objects to be partitioned into k − 1 non-empy sets. If the “weirdo” is not in a set by itself, then it must be inside another non-empty set. So the others must have been divided into k non-empty sets. There are

{n− 1 k

ways of partitioning them. For each of these partitions, we can insert the “weirdo” into any of the k sets and get another partition. So there are k

{n− 1 k

total ways putting the “weirdo” into these existing sets. Since we have completely dealt with the “weirdo”, there are

{n− 1 k− 1

  • k

{n− 1 k

ways to partition n distinct objects into k non-empty sets. Thus, (^) { n k

n − 1 k − 1

  • k

n − 1 k

This proof is a little challenging. Let me just go through it with our 3 items from before. Let ♣ be the “weirdo.” (It does look a little strange, doesn’t it?). If ♣ is in a set by itself, then we need to partition ♦, ♥ between the 1 remaining set. There is no way to divide them between one set, so there is just one way of putting them in a set together. We get the following partition

{♦, ♥}, {♣}. The other case was that ♣ was not by itself. So we partition ♦, ♥ into 2 sets. There’s still just one way of doing this {♦}, {♥}. We can insert ♣ into either of the sets in this partition, so we get 2 more ways of partitioning the items into two sets.

{♣, ♦}, {♥} {♣, ♥}, {♦} Using this theorem, we can build the Stirling number triangle (like Pascal’s trian- gle). See Figure 1.

Figure 1: A table of Stirling Numbers of the second kind

{n

k

which

induces the Stirling triangle. The value of

{n

k

is the k + 1th number on

the n + 1th row, e.g.

2

= 7. To build the triangle, use Theorem 4.2.

This theorem says that the value in a particular position is k times the

number up and to the right, plus the number up and to the left, e.g.

4.2 Proving the Theorem

In order to prove Theorem 4.1, we’ll first prove a helpful lemma, then do a lot of algebra.

Lemma. A helpful lemma x · xk^ = xk+1^ + kxk.

Proof. x · xk^ = x · xk^ − k · xk^ + k · xk = (x − k) · xk^ + k · xk = xk+1^ + k · xk.

Now, recall Theorem 4.1. xm^ =

∑^ m

k=

m k

xk,

Proof. We’ll prove this by induction on n. The base case, n = 1 is trivial. x^1 =

0

x^0 +

1

x^1 = x. Our induction hypothesis is that xn^ =

∑n k=

{n k

xk^ holds for all n ≤ r.

If we apply an ordering to the sets comprising these partitions, i.e. π 1 , π 2 ,... , πk, then we can construct a surjective map from X to Y using the map

f (x) = yj | x ∈ πj ,

that is, the set πj is the inverse image of yj. Since there are k! orderings of the numbers between 1 and k, we get that there are k!

{n k

surjections. We can also count this using an inclusion-exclusion argument. If we take the total number of mappings from X to Y , we want to subtract all the mappings that do not map to at least one element in y. We can do this by look at all maps that exclude a particular element yi. To do this, we take the total number of maps between X and Y and subtract the number of maps that exclude an element yi. However, now we’ve subtracted some maps twice (maps that exclude yi and yj ), and we then need to add them back. So we then add the number of maps that exclude two elements, then subtract the maps that exclude at least three (for a similar reason), etc. This strange sum actually counts all of our elements. For more information about a powerful generalization of this proof technique, see [5]. There are

(k i

ways to pick the i elements from k to exclude and there are (k − i)n maps that exclude one set of i elements from Y. Thus, we get the number of surjective maps from X to Y is

( k 0

kn ︸ ︷︷ ︸ all maps

k 1

(k − 1)n ︸ ︷︷ ︸ exclude 1

k 2

(k − 2)n ︸ ︷︷ ︸ exclude 2

∑^ k

i=

(−1)i

k i

(k − i)n.

We divide both sides by k! to complete the proof.

5 Examples Galore...

In this section, we just provide a few in-depth examples to show the utility of finite calculus and how it really takes the thought out of complicated sums.

∑n x=1 x

2

Since I still haven’t gotten around to showing how to derive the closed form solution to this sum, let’s do that now. It’s a nice quick warm-up to the following examples.

∑^ n

x=

x^2 =

n∑+

1

x^2 δx =

n∑+

1

x^2 + x^1 δx = x^3 /3 + x^2 / 2

∣∣n+ 1 = (n^ + 1)

(^3) /3 + (n + 1) (^2) / 2.

5.2 A Double Sum

As promised in the introduction, let’s compute

∑n x=

∑n y=1(x+y) (^2) using finite calculus.

First, we’ll convert to falling powers and take the anti-derivative, then evaluate the inner sum and repeat the process.

∑n

x=

∑^ n

y=

(x + y)^2 =

n∑+

1

n∑+

1

(x + y)^2 δy δx =

n∑+

1

n∑+

1

(x + y)^2 + (x + y)^1 δy δx

n∑+

1

(x + n + 1)^3 /3 + (x + n + 1)^2 / 2 − (x + 1)^3 / 3 − (x + 1)^2 / 2 δx

= (2n + 2)^4 /12 + (2n + 2)^3 / 6 − (n + 2)^4 / 6 − (n + 2)^3 / 3

Oops. While that was correct, we skipped one step. What is the

(x + c)m^ δx? We assumed it was the same as

xm^ δx without proof. Looking at the proof of Theorem 3.1, it is true since we just add a constant to the falling power.

5.3 Average Codeword Length

(This example, without the story, comes courtesy of CS 141 at Harvey Mudd Col- lege [2]). Suppose you are the director of programming for one of the Mars rovers. These rovers accept command codewords of up to 10 bits. A brief summary of the commands are listed below.

0 stop 1 take photo 00 move forward 01 move backward 10 move left 11 move right .. . 001101 take picture of green alien .. . 1111111111 self-destruct There are a few interesting aspects to this table. First, 0 and 00 are different com- mands! Second, all possible commands are used and there is no redundancy between the command codes. After you have designed and implemented this codeword system, your boss calls you on the phone and wants to know the average codeword length. Since NASA pays interplanetary communications costs per bit, he really wants to know how much money your codeword system will cost. While still talking to your boss, you quickly jot down a few notes. First, for a codeword of exactly x bits, you note that there are 2x^ possible codes. Hence, the total number of codes is

∑^10

x=

2 x^ = 2^11 − 2.

Second, the total length of all codewords of exactly x bits is x 2 x. Aha! Now you can easily compute the average codeword length. ∑ 10 x=1 x^2 x ∑ 10 x=1 2 x^