How to Find polynomial coefficients using Pascal's Triangle
This post is heavy with math formualae, so may take a few seconds to format correctly.
This post was originally written 2009/05/29, but was never finished. I just
finished the revisions on 2016/09/14 and it is now complete.
I have always had a certain love for math and the neat things you can do with it. Here is a bit of information and shortcuts I have picked up in a few of my math classes.
Pascal's Triangle
Pascal's Triangle is a pretty neat thing. It is very simple to construct and can be used to understand a lot of different ideas. It follows a very simple form: start with a '1' and add the two digits above to get the next number. The first few line look like this:
The line numbers start at 0, and continue on ad infinitum. In order to generate this triangle, programmatically, you would use something like this:
vector<int>pascal(
vector<int> prev,//the current (old) row dataint*len,//the length of the dataint end,//the row to retrieveint cur=0//the current row we are on);
vector<int>pascal(vector<int> prev,int*len,int end,int cur){//return immediately if we are at the last rowif(cur==end)return prev;//if the current vector length is 0, then set it to 1if(*len==0)*len=1;//create a temp vector (all 1's) to store the new row data
vector<int>t((*len)+1,1);//sum the two rowsfor(int i=1;i<(*len);i++)
t[i]=prev[i-1]+prev[i];//increase the length by 1*len=(*len)+1;//return the new row datareturnpascal(t,len,end,cur+1);}
Binomial Expansion
Remember binomials from algebra? They were the pair of numbers used to create or simplify polynomial expressions, something like:
(x+3)3=x3+9x2+27x+27
You can use Pascal's triangle to find the coefficients of the polynomials. Let's begin by solving for the generic case:
(a+b)n=
(a+b)n−1(a+b)=
(a+b)n−2(a+b)2=
(a+b)n−2((a+b)(a+b))=
((a∗a)+(a∗b)+(b∗a)+(b∗b))(a+b)n−1=
(a2+2ab+b2)(a+b)n−1=
See the coefficients so far, with n=2 ? They are [121], which corresponds
to the second row in Pascal's triangle. But this could be a fluke, right, so
let's jump ahead to n=5 to see if that works as well.
There it is! The coefficients correspond to the rows on Pascal's Triangle!
Features
Now, to make things a little simpler, I will note some interesting "features" about what we just did.
General Formula for Binomial Expansion
The general formula for binomial expansion is:
(a+b)n=i=0∑n(Pnian−ibi)
i=1∑ni2=6n(n+1)(2n+1)
Where Pni is the coefficient at row n (starting from 0) and column i in
Pascal's Triangle. The formula means to add from i=0 to n all the terms
(Pnian−ibi) , replacing i with the number you are at. For example,
supposing i=3, you would get:
Note in all the expansions, the first variable counts down from n to 0, while the second variable counts up from 0 to n.
Does your binomial already have coefficients?
If your binomial already has coefficients, simply put them with their terms like so:
i=0∑n(Pni(xa)n−i(yb)i)
Using the commutative property, it can be rewritten as such:
i=0∑n(P3i(xn−iyi)an−ibi)
Let's try an example!
(3a+2b)3=
(1)(3a)3(2b)0+(3)(3a)2(2b)+(3)(3a)(2b)2+(1)(2b)3=
(1)(33)a3+(3)(32∗2)a2b+(3)(3∗22)ab2+(1)(23)b3=
(1)(27)a3+(3)(18)a2b+(3)(12)ab2+(1)(8)b3=
27a3+54a2b+36ab2+8b3
Conclusion
As you can see, it is fairly easy to use Pascal's Triangle as a lookup table for
binomial expansion's coefficients. I hope you have much more fun in your maths!