All algebra students in the U.S. learn how to multiply expressions like (x + 2)(x - 5) by using the FOIL method. FOIL stands for "First, Outer, Inner, Last". To be honest, I dislike the use of the FOIL acronym and other ones like it because they try to oversimplify procedures in ways that make it difficult for students to extend them to more complicated problems.
If we think about the FOIL method, we see that it is telling us two things: the main thing is to multiply each term of the first group by each term of the second group, but it's also telling us what order to do the multiplications in. So, we end up with x2 -5x + 2x -10 which then simplifies to x2 -3x -10. But the order of the multiplications does not actually matter since addition is commutative (A + B = B + A and A + B + C + D = B + C + A + D and so on). We could have solved this problem by doing OIFL, getting -5x +2x +x2 - 10 which we could then rearrange as x2 -3x -10.
In my view, it would be better if teachers simply taught students that they have to multiply each term of the first group by each term of the second group and never mentioned FOIL. Students are smart enough to keep track of all the terms and find their own system for keeping track of them to make sure that they don't leave any out. If teachers adopted this approach, most algebra students would immediately know how to solve harder problems that have more than two terms in one or more of the groups.
For instance, we can use the "multiply each term of the first group by each term of the second group" rule on (x2 + 2x + 5)(4x2 - 3x -3). Before reading further, I suggest you try this yourself. Then you can compare what you get to what I got.
OK. When I followed the rule, I got the following result:
4x4 - 3x3 - 3x2 + 8x3 - 6x2 - 6x + 20x2 - 15x - 15
Note that there are 3 terms in the first group and 3 terms in the second group. Since 3*3 = 9, we should end up with 9 terms. And we did! (If you did this yourself and ended up with the same 9 terms ordered differently, that is ok.) Now we can simplify further by combining terms that have the same expontents. This gives us:
4x4 + 5x3 + 11x2 - 21x - 15
If you did this yourself and originally ordered the 9 terms differently, you should still end up with the same answer after simplifying and ordering the terms in descending powers of x. Solving the second problem takes more time than the first problem, but it's not actually any harder if you use the rule I have given you. The only thing that makes it seem harder is the FOIL acronym which obscures the actual method that you need to use. So, forget about FOIL and just remember to multiply all terms of each group by all terms of the other group.