Understanding BlockDAGs and GHOSTDAG
My WebsiteSupport My Work
  • Welcome!
  • Preface
  • Introduction
  • Part 1: BlockChains and BlockDAGs
    • Introduction
    • Chapter 1: From BFT to PoW
      • Byzantine Fault Tolerance
      • Proof-of-Work (PoW)
      • How PoW Works*
      • PoS Vs. PoW
      • Exercises
    • Chapter 2: the Block Chain Paradigm
      • A Graph Theory Primer
      • The Paradigm
      • Honesty and Rationality
      • Three Chain Selection Rules
      • Security Notions
      • A Security Model for Blockchain Consensus
      • Selfish Mining in Bitcoin
      • Safety
      • Liveness
      • Confirmation Times
      • Proving Bitcoin's Security*
      • Exercises
  • Part 2: The GHOSTDAG Protocol
    • Page 2
  • Supplementary Material
    • Math
      • Stuff You Should Know
        • Asymptotics, Growth, and Decay
        • Binomial Coefficients
        • The Binomial Formula
        • Geometric Sums and Series
      • Probability Theory
        • Probability Spaces
        • Random Variables
        • The Math of Block Creation
    • Computer Science
      • Stuff you Should Know
        • Asymptotic Notation
        • Negligible Functions
      • Cryptography
        • Random Oracles
        • Merkle Trees
        • One Time Pads
Powered by GitBook
On this page
  1. Supplementary Material
  2. Math
  3. Stuff You Should Know

The Binomial Formula

PreviousBinomial CoefficientsNextGeometric Sums and Series

Last updated 3 months ago

The binomial formula is extremely useful for a variety of calculations. It follows a nice observation which follows closely from computing what results when we expend the expresssion (a+b)n(a+b)^n(a+b)n for various values of nnn.

We have that:

(a+b)0=1(a+b)1=a+b(a+b)2=a2+2ab+b2(a+b)3=a3+3a2b+3ab2+b3\begin{aligned}\left(a+b\right)^{0} & =1\\ \left(a+b\right)^{1} & =a+b\\ \left(a+b\right)^{2} & =a^{2}+2ab+b^{2}\\ \left(a+b\right)^{3} & =a^{3}+3a^{2}b+3ab^{2}+b^{3} \end{aligned} (a+b)0(a+b)1(a+b)2(a+b)3​=1=a+b=a2+2ab+b2=a3+3a2b+3ab2+b3​

We can rewrite this in a way that might seem a bit odd but will serve us well:

(a+b)0=1⋅a0b0(a+b)1=1⋅a1b0+1⋅a0b1(a+b)2=1⋅a2+2⋅a1b1+1⋅b2(a+b)3=1⋅a3+3⋅a2b1+3⋅a1b2+1⋅b3\begin{aligned}\left(a+b\right)^{0} & =1\cdot a^{0}b^{0}\\ \left(a+b\right)^{1} & =1\cdot a^{1}b^{0}+1\cdot a^{0}b^{1}\\ \left(a+b\right)^{2} & =1\cdot a^{2}+2\cdot a^{1}b^{1}+1\cdot b^{2}\\ \left(a+b\right)^{3} & =1\cdot a^{3}+3\cdot a^{2}b^{1}+3\cdot a^{1}b^{2}+1\cdot b^{3} \end{aligned} (a+b)0(a+b)1(a+b)2(a+b)3​=1⋅a0b0=1⋅a1b0+1⋅a0b1=1⋅a2+2⋅a1b1+1⋅b2=1⋅a3+3⋅a2b1+3⋅a1b2+1⋅b3​

Is this starting to look familiar? What about if we remove all the annoying aaa's and bbb's and plus signs?

11 11 2 11 3 3 1\begin{aligned} & 1\\ & 1\ 1\\ & 1\ 2\ 1\\ & 1\ 3\ 3\ 1 \end{aligned} ​11 11 2 11 3 3 1​

Of course! These are the first few lines of !

In other words, we can rewrite the last line of the expression above as:

(a+b)3=(30)⋅a3+(31)⋅a2b1+(32)⋅a1b2+(33)⋅b3\left(a+b\right)^{3}={3 \choose 0}\cdot a^{3}+{3 \choose 1}\cdot a^{2}b^{1}+{3 \choose 2}\cdot a^{1}b^{2}+{3 \choose 3}\cdot b^{3}(a+b)3=(03​)⋅a3+(13​)⋅a2b1+(23​)⋅a1b2+(33​)⋅b3

How does this happen? Well, remember that when we expend (a+b)3(a+b)^3(a+b)3 we actually go over each "copy" of (a+b)(a+b)(a+b) and choose either aaa or bbb. "Choose", here's that word again. Say we chose bbb exactly two out of the three times, then we got the monomial a⋅b2a\cdot b^2a⋅b2. How many ways are there to choose bbb two out of the three times? Obviously (32){3 \choose 2}(23​).

Similarly, if we ask ourselves what is the coefficient of an−k⋅bka^{n-k}\cdot b^kan−k⋅bk in (a+b)n(a+b)^n(a+b)n. That is, how many different ways are there to choose bbb in exactly kkk of the nnn copies of (a+b)(a+b)(a+b)? We know very well that the answer is (nk){n \choose k}(kn​).

Putting this all together, we get the remarkable formula known as Newton's binomial formula:

(a+b)n=(n0)an+(n1)an−1⋅b+…+(nk)an−kbk+…+(nn)bn=∑k=0n(nk)an−kbk\begin{aligned}\left(a+b\right)^{n} & ={n \choose 0}a^{n}+{n \choose 1}a^{n-1}\cdot b+\ldots+{n \choose k}a^{n-k}b^{k}+\ldots+{n \choose n}b^{n}\\ & =\sum_{k=0}^{n}{n \choose k}a^{n-k}b^{k} \end{aligned} (a+b)n​=(0n​)an+(1n​)an−1⋅b+…+(kn​)an−kbk+…+(nn​)bn=k=0∑n​(kn​)an−kbk​

We will revisit this formula when we discuss probabilities in the next part of the appendix, but lets see a nice example of how it can be used to prove fun stuff.

For example, what do you think should be the alternating sum of the binomial coefficients:

(n0)−(n1)+(n2)−(n3)+…+(−1)n(nn){n \choose 0}-{n \choose 1}+{n \choose 2}-{n \choose 3}+\ldots+\left(-1\right)^{n}{n \choose n}(0n​)−(1n​)+(2n​)−(3n​)+…+(−1)n(nn​)

Well, if nnn is odd we can use the fact that (nk)=(nn−k){n \choose k} = {n \choose n-k}(kn​)=(n−kn​) and "pair them up" to get

(n0)−(n1)+(n2)−(n3)+…−(nn)=((n0)−(nn))+((n1)−(nn−1))+…+((n⌊n/2⌋)−(n⌈n/2⌉))=0\begin{aligned} & {n \choose 0}-{n \choose 1}+{n \choose 2}-{n \choose 3}+\ldots-{n \choose n}\\ & =\left({n \choose 0}-{n \choose n}\right)+\left({n \choose 1}-{n \choose n-1}\right)+\ldots+\left({n \choose \left\lfloor n/2\right\rfloor }-{n \choose \left\lceil n/2\right\rceil }\right)\\ & =0 \end{aligned} ​(0n​)−(1n​)+(2n​)−(3n​)+…−(nn​)=((0n​)−(nn​))+((1n​)−(n−1n​))+…+((⌊n/2⌋n​)−(⌈n/2⌉n​))=0​

For those who do not know these notations, for any xxx, we use ⌊x⌋\left\lfloor x\right\rfloor⌊x⌋ and ⌈x⌉\left\lceil x\right\rceil⌈x⌉ to denote rounding it down or up respectively to the nearest integer.

But that won't work when nnn is even. So what can we do? In fact, we can prove it for all cases (nnn even or odd) in one fell swoop without this ugly "pairing up". We just need to rewrite the sum a little differently:

(n0)−(n1)+(n2)−(n3)+…−(nn)=∑k=0n(−1)k(nk)=∑k=0n1n−k(−1)k(nk)\begin{aligned} & {n \choose 0}-{n \choose 1}+{n \choose 2}-{n \choose 3}+\ldots-{n \choose n}\\ & =\sum_{k=0}^{n}\left(-1\right)^{k}{n \choose k}\\ & =\sum_{k=0}^{n}1^{n-k}\left(-1\right)^{k}{n \choose k} \end{aligned} ​(0n​)−(1n​)+(2n​)−(3n​)+…−(nn​)=k=0∑n​(−1)k(kn​)=k=0∑n​1n−k(−1)k(kn​)​

which is exactly the binomial formula with a=1a=1a=1 and b=−1b=-1b=−1!

We thus get:

∑k=0n1n−k(−1)k(nk)=(1+(−1))n=0\sum_{k=0}^{n}1^{n-k}\left(-1\right)^{k}{n \choose k}=\left(1+\left(-1\right)\right)^{n}=0k=0∑n​1n−k(−1)k(kn​)=(1+(−1))n=0

Exercise: Prove that the sum of nnnth binomial coefficients (n0)+(n1)+…+(nn){n \choose 0} + {n \choose 1} + \ldots + {n \choose n}(0n​)+(1n​)+…+(nn​) is exactly 2n2^n2n. Why is this answer expected?

Pascal's triangle