# formula of pascal's triangle

I want to make a program for pascal's triangle,I was reading through the details and found something like this:

0:                                1
1:                             1     1
2:                           1    2    1
3:                         1   3     3   1
4:                       1   4    6    4   1
5:                      1  5   10   10   5   1


by looking at row number 5 of the triangle, one can quickly read off that:

$$(x + y)^5 = 1\cdot x^5 + 5\cdot x^4y + 10\cdot x^3y^2 + 10\cdot x^2y^3 + 5\cdot x y^4 + 1\cdot y^5$$

but I haven't been able to understand what are these x and y and what shall be their values.and also how shall I proceed for further rows. I shall be really thatnkful if someone explained this to me.

-

The $x,y$ are just formal symbols; the can stand for anything (for instance numbers) that you can add and multiply; in order for the binomial formula you wrote to be valid, one must assume they commute: $xy=yx$ (so they cannot stand for an arbitrary pair of square matrices). For the formula itself the nature of $x$ and $y$ have no importance; thus the formula expresses a very general fact.

To compute these formulas requires just rearranging symbols a bit. Mulitplying the formula for $(x+y)^n$ by $x+y$ and gathering terms, you can see that each new coefficient is obtained as the sum of two previous ones; denoting as is conventional the (binomial) coefficient of $x^ky^{n-k}$ in $(x+y)^n$ by $\binom nk$, you get the relation $$\binom{n+1}k=\binom n{k-1}+\binom nk\qquad\text{for 0<k\leq n,}$$ which is known as Pascal's recurrence. Using it allows computing Pascal's triangle more rapidly and safely (if you are using integers of bounded size) than using the explicit multiplicative formula for individual binomial coefficients.

-

Look at binomial coefficients. the number in the rth position in the nth row is given by n choose r, calculated by ${n \choose r} = \frac{n!}{r!(n-r)!}$. This gives you the number of ways of choosing r objects from a set of n, you can see why we want to consider this since in your expansion of $(x+y)^5$ we want to count the various ways to get the different powers of xy.

-

These $x$ and $y$ are your variables. They can be any number in your domain(if it's a polynomial over the real, then $x$ and $y$ are real numbers; if it's a polynomial over the complex, then $x$ and $y$ are complex numbers.). They are arbitrary. So don't worry about what value to put in. This binomial theorem gives you a way to deal with things in general.

-