# Universal Formula for Expanding Brackets

I know how to expand brackets such as the following in general, using the foil or crab-claw methods, but my tutor mentioned that there is a universal formula/algorithm for an expansion.

E.g Bracket:

(x + y) (2x - 7xy)

Please can you tell me what it is?

Thanks,

Max.

-
Nothing fancy, just take the sum of each term in the first bracket times each term in the second: $(x) (2x) + (x)(-7xy) + (y)(2x) + (y)(-7xy)$. –  Robert Israel Oct 1 '12 at 0:06
Hi Robert, the foil and crab-claw methods use that implementation, that's the method that I generally use. I thought that there was a formula (something fancy!) in order to get the result a bit quicker? –  user43211 Oct 1 '12 at 1:24
Perhaps you're meaning to talk about expansions involving the use of Pascal's triangle? –  Joe Oct 1 '12 at 1:30
@Joe no, I'm not. –  user43211 Oct 1 '12 at 1:40

It is just applying the distributive law repeatedly ($a(b+c) = ab + ac$), adding the exponents of terms with a common base (e.g., $(x)(2x)$ becomes $2x^2$), and collecting terms with the same bases and exponents (e.g., $(-7xy) + (2xy)$ becomes $-5xy$). You keep on doing this until nothing else can be done.

In your case, as Robert Israel stated, the distributive law applied twice gives $(x)(2x)+(x)(−7xy)+(y)(2x)+(y)(−7xy)$. Adding the exponents of parts of terms with common bases gives $(2x^2)-(7x^2y)+(2xy)-(7xy^2)$. There are no terms with the sames bases and exponents, so you can remove the parentheses and you are done.

-
Thanks Marty, so in layman's terms, there is no other way via use of an algorithm or formula? –  user43211 Oct 1 '12 at 1:41
@user43211 In what way is this not an algorithm or formula? –  MJD Oct 1 '12 at 2:08
@MJD: this is certainly (a sketch of) an algorithm-a well-defined series of steps that leads to the solution. It is recursive, in that it breaks the problem at hand down to a simpler version, then says to do to the same to the simpler version. It is not a formula like (a+b)(c+d)=ac+ad+bc+bd, but those get hard to right out for an unknown number of terms. I could certainly write $$(\sum a_i)(\sum b_j)=\sum\sum a_ib_j$$, which is true, but doesn't feel like what you want in a formula either. –  Ross Millikan Oct 1 '12 at 13:02

Perhaps by "something fancy" you mean this. Suppose each of your sums is a polynomial in $x$. Thus you want to write $$(a_0 + a_1 x + a_2 x^2 + \ldots + a_m x^m)(b_0 + b_1 x + \ldots + b_n x^n) = c_0 + c_1 x + \ldots + c_{m+n} x^{m+n}$$ where the coefficients $a_j, b_j, c_j$ don't contain $x$.
Then $$c_k = \sum_{i=\max(0,i-n)}^{\min(m,k)} a_i b_{k-i}$$ But there's also an asymptotically much faster way to compute the coefficients, using Fast Fourier Transform and interpolation. See e.g. http://www.cs.iastate.edu/~cs577/handouts/polymultiply.pdf

-