Skip to main content
Mathematics LibreTexts

5.3: Algebra of functions

  • Page ID
    45054
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\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]{\| #1 \|}\) \( \newcommand{\inner}[2]{\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]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    In the previous section, we used the newly defined function notation to make sense of expressions such as \(f(x + 1)\) or \(f(2a)\) for a given function \(f\). It would seem natural, then, that functions should have their own arithmetic which is consistent with the arithmetic of real numbers, i.e., addition and subtraction.

    Add and Subtract Functions

    Definition

    If \(x\) in the domains of functions \(f\) and \(g\), where \((f + g)(x)\) and \((f − g)(x)\) is defined for all \(x\), then

    • the sum \(f + g\) is given by \((f + g)(x) = f(x) + g(x)\)
    • the difference \(f − g\) is given by \((f − g)(x) = f(x) − g(x)\)
    Note

    In other words, to add two functions, we add their outputs; to subtract two functions, we subtract their outputs, and so on.

    Note

    Note, that while the formula \((f + g)(x) = f(x) + g(x)\) looks suspiciously like some kind of distributive property, it is nothing of the sort; the addition on the left-hand side of the equation is function addition, and we are using this equation to define the output of the new function \(f +g\), the sum of the real number outputs from \(f\) and \(g\).

    Example 5.3.1

    Let \(f(x)=2x^2+x-3\) and \(g(x)=-x^2-2x+1\). Find

    1. \((f+g)(2)\)
    2. \((f-g)\left(-\dfrac{3}{2}\right)\)
    3. \((f+g)(x)\)
    4. \((f-g)(x)\)

    Solution

    1. We apply the definition of addition of functions to \((f + g)(2)\), then evaluate. \[\begin{array}{rl}(f+g)(2)=f(2)+g(2)&\text{Apply the definition} \\ (f+g)(2)=\underset{f(2)}{\underbrace{(2\color{blue}{(2)}\color{black}{}^2+\color{blue}{(2)}\color{black}{}-3)}}+\underset{g(2)}{\underbrace{(-\color{blue}{(2)}\color{black}{}^2-2\color{blue}{(2)}\color{black}{}+1)}}&\text{Evaluate} \\ (f+g)(2)=0&\text{The sum of the outputs }f(2)+g(2)\end{array}\nonumber\]
    2. We apply the definition of subtraction of functions to \((f − g)\left(-\dfrac{3}{2}\right)\), then evaluate. \[\begin{array}{rl}(f-g)\left(-\dfrac{3}{2}\right)=f\left(-\dfrac{3}{2}\right)-g\left(-\dfrac{3}{2}\right)&\text{Apply the definition} \\ (f-g)\left(-\dfrac{3}{2}\right)=\underset{f(-\dfrac{3}{2})}{\underbrace{\left(2\color{blue}{\left(-\dfrac{3}{2}\right)}\color{black}{}^2+\color{blue}{\left(-\dfrac{3}{2}\right)}\color{black}{}-3\right)}}-\underset{g(-\dfrac{3}{2})}{\underbrace{\left(-\color{blue}{\left(-\dfrac{3}{2}\right)}\color{black}{}^2-2\color{blue}{\left(-\dfrac{3}{2}\right)}\color{black}{}+1\right)}}&\text{Evaluate} \\ (f-g)\left(-\dfrac{3}{2}\right)=-\dfrac{7}{4}\end{array}\nonumber\] Thus, the difference of the outputs \(f\left(-\dfrac{3}{2}\right)-g\left(-\dfrac{3}{2}\right)\).
    3. We apply the definition of addition of functions to \((f + g)(x)\), then simplify by combining like terms. \[\begin{array}{rl}(f+g)(x)=f(x)+g(x)&\text{Apply the definition} \\ (f+g)(x)=\underset{f(x)}{\underbrace{(2x^2+x-3)}}+\underset{g(x)}{\underbrace{(-x^2-2x+1)}}&\text{Simplify by combining like terms} \\ (f+g)(x)=2x^2+x-3-x^2-2x+1 \\ (f+g)(x)=x^2-x-2&\text{The sum of all outputs }f(x)+g(x)\end{array}\nonumber\]
    4. We apply the definition of subtraction of functions to \((f −g)(x)\), then simplify by combining like terms. \[\begin{array}{rl}(f-g)(x)=f(x)-g(x)&\text{Apply the definition} \\ (f-g)(x)=\underset{f(x)}{\underbrace{(2x^2+x-3)}}-\underset{g(x)}{\underbrace{(-x^2-2x+1)}}&\text{Distribute the negative} \\ (f-g)(x)=2x^2+x-3\color{blue}{+}\color{black}{}x^2\color{blue}{+}\color{black}{}2x\color{blue}{-}\color{black}{}1&\text{Simplify by combining like terms} \\ (f+g)(x)=3x^2+3x-4&\text{The difference of all outputs }f(x)-g(x)\end{array}\nonumber\]
    Note

    In these last two examples, essentially we are combining a function with another function. The interesting part about these examples is when we combine a function with another function, we are creating an entirely new function. How awesome, right?

    Composition of Functions

    We can think back to Examples 5.1.10 and 5.1.11, where we wanted to evaluate \(g(3x)\) and \(p(t + 1)\). After we evaluated these functions, we obtained entirely new functions. In general, when we substitute a function into another function’s input, we call this a composition of two functions. We can compose more than two functions, but, in this section, we demonstrate composition only with two functions.

    Definition: Composed

    If \(x\) is in the domains of functions \(f\) and \(g\), then \(f\) composed of \(g\) is given by \[(f\circ g)(x)=f(g(x)),\nonumber\] i.e., we substitute every \(x\) in \(f\) with the function \(g(x)\).

    \((f\circ g)(x)\) implies that \(x\) is in the domain of \(g(x)\) and \(g(x)\) is in the domain of \(f(x)\).

    Note

    The term function came from Gottfried Wihelm Leibniz, a German mathematician from the late \(17^{\text{th}}\) century.

    Let’s look at a graphical representation of the above definition.

    clipboard_e24ae811075abade3b1f4e95f5f807557.png
    Figure 5.3.1 : In the figure, we see the composition of \(g\) and \(x\) followed by \(f\). Thus, \((f ◦ g)(x)\) is composing \(x\) into \(g\) first, then composing \(g(x)\) into \(f\), getting an entirely new function.
    Example 5.3.2

    If \(a(x) = x^2 − 2x + 1\) and \(b(x) = x − 5\), find \((a ◦ b)(3)\).

    Solution

    Let’s rewrite \((a ◦ b)(3)\) using the definition, then evaluate.

    \[\begin{array}{rl}(a\circ b)(3)=a(b(3))&\text{Apply the definition} \\ (a\circ b)(3)=a\underset{b(3)}{\underbrace{(\color{blue}{3-5}\color{black}{})}}&\text{Simplify }3-5 \\ (a\circ b)(3)=a(\color{blue}{-2}\color{black}{})&\text{Evaluate }a(-2) \\ (a\circ b)(3)=(\color{blue}{-2}\color{black}{})^2-2(\color{blue}{-2}\color{black}{})+1&\text{Simplify} \\ (a\circ b)(3)=9&\text{The value of the composition}\end{array}\nonumber\]

    Recall, when we evaluate functions at particular values, we are really obtaining ordered-pairs on the graph of the function. Since we are composing two functions in this case, then the ordered-pair of the new function is \((3, 9)\).

    Example 5.3.3

    Let \(f(x)=x^2-x\) and \(g(x)=x+3\).

    1. Find \((f\circ g)(x)\).
    2. Find \((g\circ f)(x)\).
    3. Find \((f\circ f)(x)\).

    Solution

    1. We start by rewriting \((f ◦ g)(x)\) using the definition, then simplify. Note, after we simplify, we obtain an entirely new function. \[\begin{array}{rl}(f\circ g)(x)=f(g(x))&\text{Replace }g(x)\text{ with }x+3 \\ (f\circ g)(x)=f\underset{g(x)}{\underbrace{(\color{blue}{x+3}\color{black}{})}}&\text{Replace the variables in }f\text{ with }(x+3) \\ f(\circ g)(x)=(\color{blue}{x+3}\color{black}{})^2-(\color{blue}{x+3}\color{black}{})&\text{Simplify} \\ (f\circ g)(x)=(x^2+6x+9)-(x+3)&\text{Combine like terms} \\ (f\circ g)(x)=x^2+5x+6&\text{The composition of }f\text{ and }g\end{array}\nonumber\] As we assumed, composing \(f\) and \(g\) resulted in entirely new function.
    2. Notice, \((g\circ f)(x)\), where we are composing \(g\) and \(f\). Just like the chocolate covered strawberries with whipped cream, order matters. We will have to put \(f\) in \(g\), unlike the previous example. \[\begin{array}{rl}(g\circ f)(x)=g(f(x))&\text{Replace }f(x)\text{ with }x^2-x \\ (g\circ f)(x)=g\underset{f(x)}{\underbrace{\color{blue}{(x^2-x)}}}&\text{Replace the variables in }g\text{ with }(x^2-x) \\ (g\circ f)(x)=(\color{blue}{x^2-x}\color{black}{})+3&\text{Simplify} \\ (g\circ f)(x)=x^2-x+3&\text{The composition of }g\text{ and }f\end{array}\nonumber\] As we assumed, composing \(g\) and \(f\), where we dipped \(f\) into \(g\) resulted in entirely different function than the previous example.
    3. Notice, \((f\circ f)(x)\), where we are composing \(f\) with itself. We will substitute the function \(f\) into itself for every \(x\). \[\begin{array}{rl}(f\circ f)(x)=f(f(x))&\text{Replace }f(x)\text{ with }x^2-x \\ (f\circ f)(x)=f\underset{f(x)}{\underbrace{\color{blue}{(x^2-x)}}}&\text{Replace the variables in }f\text{ with }(x^2-x) \\ (f\circ f)(x)=(\color{blue}{x^2-x}\color{black}{})^2-(\color{blue}{x^2-x}\color{black}{})&\text{Simplify} \\ (f\circ f)(x)=x^4-2x^3+x^2-x^2+x&\text{Combine like terms} \\ (f\circ f)(x)=x^4-2x^3+x&f\text{ composed with itself}\end{array}\nonumber\] Notice, even when we compose a function with itself, it still results in an entirely new function.
    Note

    With composition of functions, essentially, we are composing a function with another function. The interesting part about these examples is when we compose a function with another function, we are creating an entirely new function.

    Algebra of Functions Homework

    Given the functions, perform the indicated operations and simplify.

    Exercise 5.3.1

    \(g(a) = a^3 + 5a^2\) and \(f(a) = 2a + 4\); find \(g(3) + f(3)\)

    Exercise 5.3.2

    \(g(a) = 3a + 3\) and \(f(a) = 2a − 2\); find \((g + f)(9)\)

    Exercise 5.3.3

    \(g(x) = x + 3\) and \(f(x) = −x + 4\); find \((g − f)(3)\)

    Exercise 5.3.4

    \(g(x) = x^2 + 2\) and \(f(x) = 2x + 5\); find \((g − f)(0)\)

    Exercise 5.3.5

    \(g(t) = t − 3\) and \(h(t) = −3t^3 + 6t\); find \(g(1) + h(1)\)

    Exercise 5.3.6

    \(h(t) = t + 5\) and \(g(t) = 3t − 5\); find \((h − g)(5)\)

    Exercise 5.3.7

    \(h(n) = 2n − 1\) and \(g(n) = 3n − 5\); find \(h(0) + g(0)\)

    Exercise 5.3.8

    \(f(a) = −2a − 4\) and \(g(a) = a^2 + 3\); find \((f + g)(a)\)

    Exercise 5.3.9

    \(g(x) = −x^3 − 2\) and \(h(x) = 4x\); find \((g − h)(x)\)

    Exercise 5.3.10

    \(f(x) = −3x + 2\) and \(g(x) = x^2 + 5x\); find \((f − g)(x)\)

    Exercise 5.3.11

    \(g(x) = 4x + 5\) and \(h(x) = x^2 + 5x\); find \((g + h)(x)\)

    Exercise 5.3.12

    \(f(x) = −3x^2 + 3x\) and \(g(x) = 2x + 5\); find \((f + g)(−4)\)

    Exercise 5.3.13

    \(g(x) = 4x + 3\) and \(h(x) = x^3 − 2x^2\); find \((g − h)(−1)\)

    Exercise 5.3.14

    \(g(x) = −4x + 1\) and \(h(x) = −2x − 1\); find \(g(5) + h(5)\)

    Exercise 5.3.15

    \(f(n) = n − 5\) and \(g(n) = 4n + 2\); find \((f + g)(−8)\)

    Exercise 5.3.16

    \(g(a) = 3a − 2\) and \(h(a) = 4a − 2\); find \((g + h)(−10)\)

    Exercise 5.3.17

    \(g(x) = x^2 − 2\) and \(h(x) = 2x + 5\); find \(g(−6) + h(−6)\)

    Exercise 5.3.18

    \(g(n) = n^2 − 3\) and \(h(n) = 2n − 3\); find \((g − h)(n)\)

    Exercise 5.3.19

    \(g(x) = 2x − 3\) and \(h(x) = x^3 − 2x^2 + 2x\); find \((g − h)(x)\)

    Exercise 5.3.20

    \(f(x) = 2x\) and \(g(x) = −3x − 1\); find \((f + g)(−4 − x)\)

    Exercise 5.3.21

    \(f(t) = t^2 + 4t\) and \(g(t) = 4t + 2\); find \(f(t^2) + g(t^2)\)

    Exercise 5.3.22

    \(f(n) = −3n^2 + 1\) and \(g(n) = 2n + 1\); find \((f − g)\left(\dfrac{n}{3}\right)\)

    Exercise 5.3.23

    \(f(x) = −4x + 1\) and \(g(x) = 4x + 3\); find \((f ◦ g)(9)\)

    Exercise 5.3.24

    \(h(a) = 3a + 3\) and \(g(a) = a + 1\); find \((h ◦ g)(5)\)

    Exercise 5.3.25

    \(g(x) = x + 4\) and \(h(x) = x^2 − 1\); find \((g ◦ h)(10)\)

    Exercise 5.3.26

    \(f(x) = 4x − 4\) and \(g(x) = 3x^2 − 5\); find \((f + g)(x)\)

    Exercise 5.3.27

    \(f(x) = 2x + 4\) and \(g(x) = 4x − 5\); find \(f(x) − g(x)\)

    Exercise 5.3.28

    \(g(t) = t^3 + 3t^2\) and \(h(t) = 3t − 5\); find \(g(t) − h(t)\)

    Exercise 5.3.29

    \(f(n) = 3n + 4\) and \(g(n) = n^3 − 5n\); find \(f\left(\dfrac{n}{2}\right)-g\left(\dfrac{n}{2}\right)\)

    Exercise 5.3.30

    \(g(x) = x − 1\); find \((g ◦ g)(7)\)

    Exercise 5.3.31

    \(g(t) = t + 3\) and \(h(t) = 2t − 5\); find \((g ◦ h)(3)\)

    Exercise 5.3.32

    \(f(a) = 2a − 4\) and \(g(a) = a^2 + 2a\); find \((f ◦ g)(−4)\)

    Exercise 5.3.33

    \(f(n) = −4n + 2\) and \(g(n) = n + 4\); find \((f ◦ g)(9)\)

    Exercise 5.3.34

    \(g(x) = 2x − 4\) and \(h(x) = 2x^3 + 4x^2\); find \((g ◦ h)(3)\)

    Exercise 5.3.35

    \(g(x) = x^2 − 5x\) and \(h(x) = 4x + 4\); find \((g ◦ h)(x)\)

    Exercise 5.3.36

    \(f(a) = −2a + 2\) and \(g(a) = 4a\); find \((f ◦ g)(a)\)

    Exercise 5.3.37

    \(g(x) = 4x + 4\) and \(f(x) = x^3 − 1\); find \((g ◦ f)(x)\)

    Exercise 5.3.38

    \(g(x) = −x + 5\) and \(f(x) = 2x − 3\); find \((g ◦ f)(x)\)

    Exercise 5.3.39

    \(f(t) = 4t + 3\) and \(g(t) = −4t − 2\); find \((f ◦ g)(t)\)

    Exercise 5.3.40

    \(g(x) = 3x + 4\) and \(h(x) = x^3 + 3x\); find \((g ◦ h)(3)\)

    Exercise 5.3.41

    \(g(a) = a^2 + 3\); find \((g ◦ g)(−3)\)

    Exercise 5.3.42

    \(g(a) = 2a + 4\) and \(h(a) = −4a + 5\); find \((g ◦ h)(a)\)

    Exercise 5.3.43

    \(g(t) = −t − 4\); find \((g ◦ g)(t)\)

    Exercise 5.3.44

    \(f(n) = −2n^2 − 4n\) and \(g(n) = n + 2\); find \((f ◦ g)(n)\)

    Exercise 5.3.45

    \(g(t) = t^3 − t\) and \(f(t) = 3t − 4\); find \((g ◦ f)(t)\)

    Exercise 5.3.46

    \(f(x) = 3x − 4\) and \(g(x) = x^3 + 2x^2\); find \((f ◦ g)(x)\)


    This page titled 5.3: Algebra of functions is shared under a CC BY-NC-SA 4.0 license and was authored, remixed, and/or curated by Darlene Diaz (ASCCC Open Educational Resources Initiative) via source content that was edited to the style and standards of the LibreTexts platform; a detailed edit history is available upon request.