# 1.1: Algebra Tips and Tricks Part I (Combining Terms, Distributing, Functions, Graphing)

$$\newcommand{\vecs}{\overset { \rightharpoonup} {\mathbf{#1}} }$$ $$\newcommand{\vecd}{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}}$$$$\newcommand{\id}{\mathrm{id}}$$ $$\newcommand{\Span}{\mathrm{span}}$$ $$\newcommand{\kernel}{\mathrm{null}\,}$$ $$\newcommand{\range}{\mathrm{range}\,}$$ $$\newcommand{\RealPart}{\mathrm{Re}}$$ $$\newcommand{\ImaginaryPart}{\mathrm{Im}}$$ $$\newcommand{\Argument}{\mathrm{Arg}}$$ $$\newcommand{\norm}{\| #1 \|}$$ $$\newcommand{\inner}{\langle #1, #2 \rangle}$$ $$\newcommand{\Span}{\mathrm{span}}$$ $$\newcommand{\id}{\mathrm{id}}$$ $$\newcommand{\Span}{\mathrm{span}}$$ $$\newcommand{\kernel}{\mathrm{null}\,}$$ $$\newcommand{\range}{\mathrm{range}\,}$$ $$\newcommand{\RealPart}{\mathrm{Re}}$$ $$\newcommand{\ImaginaryPart}{\mathrm{Im}}$$ $$\newcommand{\Argument}{\mathrm{Arg}}$$ $$\newcommand{\norm}{\| #1 \|}$$ $$\newcommand{\inner}{\langle #1, #2 \rangle}$$ $$\newcommand{\Span}{\mathrm{span}}$$$$\newcommand{\AA}{\unicode[.8,0]{x212B}}$$

Here are a few algebra tips and tricks to get you started. In later chapters, we will have some “just-in-time” algebra review, so you’ll review an algebra concept just before you need it.

## Combining Like terms

A term is one or more things multiplied together: for example, $$xyz$$ is a term since it is $$x$$ times $$y$$ times $$z$$, $$b^2$$ is a term, since it is $$b$$ times $$b.$$ and $$x$$ is a term. If there is also a number multiplied in front of a term, that is called the coefficient (if no coefficient is present, the coefficient is $$1$$). Two terms are like terms if they have the same variables multiplied (but may have different coefficients). If two like terms are added together, they can be combined into one term by adding the coefficients.

Combine like terms: $$ab - a^2 + 2ab - 3a^2$$.

\begin{align*} ab - a^2 + 2ab - 3a^2 & = 1ab + (-1)a^2 + 2ab + (-3)a^2 \qquad \text{(Clarify coefficients)} \\ & = 1ab + 2ab + (-1)a^2 + (-3)a^2 \qquad \text{(Group like terms)} \\ & = (1+2)ab + (-1+-3)a^2 \qquad \text{(Add coefficients)} \\ & = \boxed{3ab - 4a^2} \end{align*}

## Distributing

If you are multiplying by a sum in parentheses, the rule is to distribute

$$a(b + c) = ab + ac$$

Here is another version in “table” form.

$$\begin{array}{c|cc} & b & +c \\ \hline a & ab & +ac \end{array}$$

It works, check it out:

\begin{align*} 3(4 + 5) & = 3(4) + 3(5) \\ 3(9) & = 12 + 15 \\ 27 & = 27 \end{align*}

Here is an example:

Distribute and combine like terms: $$3a(2a - b) - (b-a^2)$$.

\begin{align*} 3a(2a - b) - (b-a^2) & = 3a(2a - b) + -1(b - a^2) \\ & = 6a^2 - 3ab - b + a^2 \qquad \text{(Notice the \mathbf{+a^2})}\\ & = \boxed{7a^2 - 3ab - b} \end{align*}

## Foiling

When multiplying two sums, every term of the first must be multiplied by every term of the second. Thus, if there are two terms in the first sum and two in the second, there are four total terms in the product: the (f)irst two terms, the (o)utside terms, the (i)nside terms, and the (l)ast two terms. We can use the acronym “foil”:

$$(a + b)(c + d) = ac + ad + bc + bd$$

Here is the same calculation in table form:

$$\begin{array}{c|cc} & c & +d \\ \hline a & ac & +ad \\ +b & +bc & +bd \end{array}$$

Here is an example:

Foil: $$(3a + 4b)(a^2 - ab)$$.

\begin{align*} (3a + 4b)(a^2 - ab) & = (3a)(a^2) + (3a)(-ab) + (4b)(a^2) + (4b)(-ab) \\ & = 3a^3 - 3a^2b +4a^2b - 4ab^2 \\ & = \boxed{3a^3 + a^2b - 4ab^2} \end{align*}

## Distributing with three terms

When you have three expressions multiplied together, things get a bit trickier. Let’s do some examples.

Find $$(x - 2)(x + 1)(x + 3)$$.

To do this, we first multiply the $$(x - 2)(x + 1)$$. This is $$x^2 +x - 2x - 2 = x^2 - x - 2$$. We then multiply $$(x^2 - x - 2)(x + 3)$$. This is done by combining every term in the first product with every term in the last product. One way to do this is $$x$$ times everything in $$x^2 - x - 2$$, plus $$3$$ times everything in $$x^2 - x - 2$$.

\begin{align*} (x - 2)(x + 1)(x + 3) & = (x^2 - x - 2)(x + 3) \\ & = (x^2 - x - 2)(x) + (x^2 - x - 2)(3) \\ & = x^3 - x^2 - 2x + 3x^2 - 3x - 6 \\ & = \boxed{x^3 + 2x^2 - 5x - 6} \end{align*}

There you go.

Alternatively, we can use the table method. We start by foiling two of the terms together

$$\begin{array}{c|cc} & x & - 2 \\ \hline x & \color{blue}{x^2} & \color{blue}{-2x} \\ +1 & \color{blue}{+1x} & \color{blue}{-2} \end{array}$$

Adding the blue terms, we get an intermediate answer of $$\color{blue}{x^2 - x -2}$$. Now we can multiply this by $$x+3$$.

$$\begin{array}{c|ccc} & \color{blue}{x^2} & \color{blue}{-x} & \color{blue}{-2} \\ \hline x & \color{red}{x^3} & \color{red}{-x^2} & \color{red}{-2x} \\ +3 & \color{red}{+3x^2} & \color{red}{-3x} & \color{red}{+6} \end{array}$$

Combining like terms gives the answer $$\boxed{\color{red}{x^3 + 2x^2 - 5x + 6}}$$, the same answer we got before!

Find $$(x + 4)^3$$.

We see this is the same thing as $$(x + 4)(x + 4)(x + 4)$$. We then can do

\begin{align*} (x + 4)(x + 4)(x + 4) & = (x^2 + 8x + 16)(x + 4) \\ & = (x^2 + 8x + 16)(x) + (x^2 + 8x + 16)(4) \\ & = x^3 + 8x^2 + 16x + 4x^2 + 32x + 64 \\ & = \boxed{x^3 + 12x^2 + 48x + 64} \end{align*}

I won’t do it this time, but you could use the table method if you prefer that!

## Functions

A function is anything that produces an output for every possible input. So for example, $$f(x) = 2x$$ is the function that take in an input $$x$$, and outputs double $$x$$ (i.e. $$f(3) = 6$$, $$f(4) = 8$$, $$f(5) = 10$$, etc.).

Here are some examples:

If $$g(x) = 2^x$$, find $$g(3)$$ and $$g(4)$$.

We see that $$g(3) = 2^3 = \boxed{8}$$, and $$g(4) = 2^4 = \boxed{16}$$.

If $$h(x) = 2x + 3$$, find $$h(5)$$, $$h(y)$$, and $$h(x + 1)$$.

In each case, just replace the $$x$$ with the input to the function. For example, $$h(5) = 2(5) + 3 = 13$$, and $$h(y) = 2(y) + 3 = \boxed{2y + 3}$$.

A tricky one is $$h(x + 1)$$. Here, we replace the $$x$$ with $$(x + 1)$$ in the formula.

Tip: Always do substitutions or replacements like this in parentheses to keep it all together.

Here is what it would look like:

\begin{align*} h({\color{red} x}) & = 2{\color{red} x} + 3 \\ h({\color{blue} x+1}) & = 2{\color{blue} (x+1)} + 3 \\ & = 2x + 2 + 3 \\ & = \boxed{2x+5}. \end{align*}

If $$m(x) = 3x - 1$$, find $$m(4x + 1)$$.

We have to replace the $$x$$ with $$4x+1$$ in the formula. So we have

\begin{align*} m(x) & = 3x - 1 \\ m(4x+1) & = 3(4x+1) - 1 \\ & = 12x + 3 - 1 \\ & = \boxed{12x + 2}. \end{align*}

If $$f(x) = x^2 - 4x$$ and $$g(x) = 2x+5$$, what is $$f(g(x))$$?

Here, the idea is to replace $$x$$ with $$g(x)$$ in the formula. In other words, $$x$$ becomes $$2x+5$$:

\begin{align*} f(x) & = x^2 - 4x \\ f(g(x)) = f(2x+5) & = (2x+5)^2 - 4(2x+5) \\ & = 4x^2 + 10x + 10x + 25 - 8x - 20 \\ & = \boxed{4x^2 + 12x + 5}. \end{align*}

## Graphing Functions

Graphing is a great way to visualize a function. For example, consider the graph of $$f(x) = x^2$$. Choose any point on the curve. If you go down to the $$x$$-axis, you’ll get the input value, and if you go directly left (or right) to the $$y$$-axis, you’ll get the output value. For example, This reflects the fact that $$f(2) = 2^2 = 4$$.

Note: Anything with multiple outputs for one input is considered not a function. A handy way to determine this is the “vertical line test” — any vertical line should hit a function only once. ## Table method for graphing

If you want to graph a function by hand, a way that works for virtually any function is the table method. Say we want to do the following:

Graph $$g(x) = x^2 + 2x$$ using the table method.

We can just start by plugging in some values like $$x = -2$$, $$x = -1$$, $$x = 0$$, etc., and fill out a whole table. For example, for $$x = -2$$, we can compute $$g(-2) = (-2)^2 + 2(-2) = 4 -4 = 0$$. Since $$g(-2) = 0$$, we know that the point $$(x, y) = (-2, 0)$$ lies on the graph. Filling out the rest of the table, we get

$\[\begin{array}{cccc} \mathbf{x} & \mathbf{x^2 + 2x} & \mathbf{g(x)} & \mathbf{(x, y)} \\ -2 & (-2)^2 + 2(-2) & 0 & (-2, 0) \\ -1 & (-1)^2 + 2(-1) & -1 & (-1, -1) \\ 0 & (0)^2 + 2(0) & 0 & (0, 0) \\ 1 & (1)^2 + 2(1) & 3 & (1, 3) \\ 2 & (2)^2 + 2(2) & 8 & (2, 8) \end{array}$\]

We can then plot these input-output pairs on the graph, and they trace out a curve. (Note that the pair $$(2, 8)$$ didn’t fit on the graph.) This page titled 1.1: Algebra Tips and Tricks Part I (Combining Terms, Distributing, Functions, Graphing) is shared under a CC BY 4.0 license and was authored, remixed, and/or curated by Tyler Seacrest via source content that was edited to the style and standards of the LibreTexts platform; a detailed edit history is available upon request.