FOIL in simple words
FOIL is a way to multiply two brackets that each have two terms, like (2x + 3)(x − 4). The letters stand for First, Outer, Inner, Last: the four pairs you multiply.
First: the first term in each bracket, 2x × x = 2x². Outer: the two ends, 2x × (−4) = −8x. Inner: the two middle terms, 3 × x = 3x. Last: the last term in each bracket, 3 × (−4) = −12.
Then add the four answers and join the terms that have the same letter and power (like terms): −8x + 3x = −5x. So (2x + 3)(x − 4) = 2x² − 5x − 12.
The calculator can also go the other way for a difference of two squares, turning 9x² − 25 into (3x + 5)(3x − 5).
The FOIL method
FOIL is the distributive property applied to two binomials. Multiply the First terms, the Outer terms, the Inner terms and the Last terms, then combine the like terms: (ax + b)(cx + d) = acx² + (ad + bc)x + bd.
Example: (2x + 3)(x − 4). First 2x·x = 2x², Outer 2x·(−4) = −8x, Inner 3·x = 3x, Last 3·(−4) = −12. Combined, that is 2x² − 5x − 12.
Difference of two squares
A²x² − B² factors as (Ax + B)(Ax − B). When you FOIL the factors back out, the outer and inner terms cancel. Example: 9x² − 25 = (3x + 5)(3x − 5), and FOIL gives 9x² − 15x + 15x − 25 = 9x² − 25.
If P or Q is not a perfect square, the factors contain square roots, for example 5x² − 4 = (√5x + 2)(√5x − 2). Over the integers, such an expression does not factor.