math.wiki
Functions › Combining and composing functions › Adding, subtracting and multiplying functions
Open on the map
Algebra 2 · F.BF.A.1B

Adding, subtracting and multiplying functions

Two quantities each depend on the same input. How do you get one function that gives their total, their gap or their product at every input?

Where you are 5 in Combining and composing functions

When you reach for it

A shop’s takings and its costs both depend on how many items it sells; the profit is one minus the other. A rectangle’s width and length both depend on some measurement x; its area is one times the other. In each case two functions share an input, and the question is about a third quantity built from their two outputs at that same input.

Rather than work out the two outputs and combine them afresh every time, you can build one new function whose output already is the total, the gap or the product. That new function has its own name, its own formula, its own table and its own graph, and it can be evaluated, graphed or solved like any other. This lesson builds sums, differences, products and constant multiples of functions given by formulas, by tables and by graphs. Dividing one function by another is left to Dividing functions and the domain of a combination, because there the bottom output can be zero.

The procedure

The new functions are defined output by output

For two functions f and g whose outputs are numbers, and any constant c, the new functions f + g, f - g, fg and cf are defined by what they do to each input x:

\begin{aligned} (f + g)(x) &= f(x) + g(x)\\ (f - g)(x) &= f(x) - g(x)\\ (fg)(x) &= f(x)\,g(x)\\ (cf)(x) &= c\,f(x) \end{aligned}

Read the left side carefully in Function notation. The bracket (f + g) is the name of the new function, in the way f is a name, and the (x) after it is the input being fed in. So (f + g)(2) means: put 2 into the function f + g. The right side says how that function works: put the same 2 into f and into g, then add the two outputs. The product fg is sometimes written f \cdot g; both mean multiply the outputs.

Nothing here needs proving, because these lines are definitions: they say what the new symbols mean. What does need a reason is each step of simplifying a combined formula, and those reasons are the rules of algebra you already have.

Combining two formulas

Suppose f(x) = 4x^2 - 3x + 6 and g(x) = x^2 + 4x - 7. By the definition, (f + g)(x) = (4x^2 - 3x + 6) + (x^2 + 4x - 7). Each rule goes in whole, inside brackets, exactly as in Evaluating a function at an expression: the definition puts all of g(x) in that place, not just its first term. From there the work is Adding and subtracting polynomials: drop the brackets, gather like terms (the commutative and associative properties of addition let you reorder and regroup), and combine.

For a difference the brackets matter more. (f - g)(x) = (4x^2 - 3x + 6) - (x^2 + 4x - 7), and the minus sign subtracts all of g(x). Subtracting is adding the opposite, and the opposite of a sum is the sum of the opposites (the distributive property with -1), so every term of g(x) changes sign: -x^2 - 4x + 7.

For a product, (fg)(x) = (4x^2 - 3x + 6)(x^2 + 4x - 7), and the distributive property sends each term of the first bracket across every term of the second, as in Multiplying polynomials. For a constant multiple, (3f)(x) = 3(4x^2 - 3x + 6), the same property sends the 3 to each term.

Two routes to one value

To find (f + g)(2) you may evaluate first or combine first:

  • evaluate f(2) and g(2) and add the two numbers, which is the definition read literally;
  • or simplify (f + g)(x) to one formula and put 2 into that.

The two always agree. The simplified formula was reached from f(x) + g(x) by steps (reordering, regrouping, distributing) that are true for every number x, so the simplified formula and f(x) + g(x) give the same output at every input, 2 included. This makes the second route a check on the first. Use the first when you need one or two values; build the formula when you need many values, a graph, or an equation to solve.

Combining tables and graphs

The definition never asks for a formula. It asks only for f(x) and g(x) at the same x, so it works on any description that gives outputs.

From a table, combine the two output entries in the same input column. This is the same entry-by-entry rule as for adding matrices, and it needs both entries to be there.

From a graph, read each output off its graph at the same input, then combine the numbers. Pictured, the point of f + g above an input sits at the height of f plus the height of g there, so the sum’s graph can be built point by point. Two facts can be read without any arithmetic. The difference (f - g)(x) is 0 exactly where f(x) = g(x), which is where the two graphs cross. The product (fg)(x) is 0 exactly where one of the outputs is 0, because a product of two numbers is zero only when a factor is; that is where one of the graphs meets the horizontal axis.

Multiplying by a constant c multiplies every height by c: this is the vertical stretch of the graph, a stretch for c > 1, a squash for 0 < c < 1, and a flip across the horizontal axis as well when c < 0.

Which rules carry over

Because each operation is done on numbers, one input at a time, the rules of number arithmetic carry over. Addition and multiplication of functions are commutative, f + g = g + f and fg = gf, and associative. A constant spreads over a sum, c(f + g) = cf + cg. Subtraction is not commutative: (g - f)(x) = -(f - g)(x) at every input, so g - f is the opposite of f - g, not the same function.

Worked examples

Example 1

Sum and difference from formulas

Let f(x) = 4x^2 - 3x + 6 and g(x) = x^2 + 4x - 7. Find (f + g)(x) and (f - g)(x). Then find (f + g)(2) and (f - g)(-1) both ways, and find (g - f)(x).

Solution

The definition puts each whole rule in brackets:

\begin{aligned} (f + g)(x) &= (4x^2 - 3x + 6) + (x^2 + 4x - 7)\\ &= (4x^2 + x^2) + (-3x + 4x) + (6 - 7)\\ &= 5x^2 + x - 1 \end{aligned}

The middle line regroups like terms, which the commutative and associative properties of addition allow. For the difference, the minus sign changes the sign of every term of g(x):

\begin{aligned} (f - g)(x) &= (4x^2 - 3x + 6) - (x^2 + 4x - 7)\\ &= 4x^2 - 3x + 6 - x^2 - 4x + 7\\ &= 3x^2 - 7x + 13 \end{aligned}

Now the values. Evaluating first: f(2) = 16 - 6 + 6 = 16 and g(2) = 4 + 8 - 7 = 5, so (f + g)(2) = 16 + 5 = 21. From the formula: 5(2)^2 + 2 - 1 = 20 + 2 - 1 = 21. The two routes agree, as they must.

For (f - g)(-1): f(-1) = 4 + 3 + 6 = 13 and g(-1) = 1 - 4 - 7 = -10, so (f - g)(-1) = 13 - (-10) = 23. From the formula: 3(-1)^2 - 7(-1) + 13 = 3 + 7 + 13 = 23.

Finally, g - f subtracts in the other order. Every output of g - f is the opposite of the output of f - g at the same input, so (g - f)(x) = -3x^2 + 7x - 13.

Example 2

A product of two functions

With the same f(x) = 4x^2 - 3x + 6 and g(x) = x^2 + 4x - 7, find (fg)(x) and (fg)(1).

Solution

By the definition, (fg)(x) = (4x^2 - 3x + 6)(x^2 + 4x - 7). The distributive property multiplies each term of the first bracket by the whole second bracket:

\begin{aligned} 4x^2(x^2 + 4x - 7) &= 4x^4 + 16x^3 - 28x^2\\ -3x(x^2 + 4x - 7) &= -3x^3 - 12x^2 + 21x\\ 6(x^2 + 4x - 7) &= 6x^2 + 24x - 42 \end{aligned}

Adding the three rows and combining like terms (16x^3 - 3x^3, then -28x^2 - 12x^2 + 6x^2, then 21x + 24x):

(fg)(x) = 4x^4 + 13x^3 - 34x^2 + 45x - 42

For the value, evaluating first is quicker: f(1) = 4 - 3 + 6 = 7 and g(1) = 1 + 4 - 7 = -2, so (fg)(1) = 7 \cdot (-2) = -14. The formula agrees: 4 + 13 - 34 + 45 - 42 = -14. A product of two quadratics has degree 4, because the highest powers multiply, x^2 \cdot x^2 = x^4.

Example 3

Constant multiples and a combination of both

With the same f and g, find (3f)(x) and (2f - 3g)(x), and check (2f - 3g)(0).

Solution

By the definition, (3f)(x) = 3f(x) = 3(4x^2 - 3x + 6). Distributing the 3 to each term gives (3f)(x) = 12x^2 - 9x + 18.

The function 2f - 3g is the difference of the two constant multiples 2f and 3g, so

\begin{aligned} (2f - 3g)(x) &= 2(4x^2 - 3x + 6) - 3(x^2 + 4x - 7)\\ &= 8x^2 - 6x + 12 - 3x^2 - 12x + 21\\ &= 5x^2 - 18x + 33 \end{aligned}

The -3 multiplies every term of g(x), which is why -7 becomes +21. Check at 0: f(0) = 6 and g(0) = -7, so 2(6) - 3(-7) = 12 + 21 = 33, and the formula gives 33 at x = 0 too.

Example 4

Combining two tables

Two functions m and n are known only from a table.

x-2-10123
m(x)52-1047
n(x)-31462not given

Make a table for m + n, m - n and mn, and say what can be said about (m + n)(3).

Solution

Each new entry uses only the two entries in its own column. For instance at x = 0: (m + n)(0) = -1 + 4 = 3, (m - n)(0) = -1 - 4 = -5, and (mn)(0) = (-1)(4) = -4. Doing the same in each column:

x-2-1012
(m + n)(x)23366
(m - n)(x)81-5-62
(mn)(x)-152-408

The 0 in the last row at x = 1 comes from m(1) = 0: a product is zero when either factor is.

At x = 3 the table gives m(3) = 7 but no value of n(3). The definition (m + n)(3) = m(3) + n(3) needs both, so (m + n)(3) has no value from this information. The combined functions are known only at inputs where both m and n are.

Example 5

Reading a sum, difference and product from graphs

The graphs of u and v are shown below. Find (u + v)(1), (u - v)(0), (uv)(1) and (uv)(3), find every x where (u - v)(x) = 0, and sketch u + v.

x y −2 −1 1 2 3 4 2 4 6 8 10 u v
Figure 1The functions u and v of Example 5. Where the graphs cross, u(x) - v(x) = 0.
Solution

Read each output at the same input. At x = 1, the line is at height 4 and the parabola at height 6, so u(1) = 4, v(1) = 6 and (u + v)(1) = 4 + 6 = 10. At x = 0, u(0) = 3 and v(0) = 5, so (u - v)(0) = 3 - 5 = -2.

For the products, (uv)(1) = u(1)\,v(1) = 4 \cdot 6 = 24, and at x = 3 the readings are u(3) = 6 and v(3) = 2, so (uv)(3) = 6 \cdot 2 = 12.

The difference (u - v)(x) is 0 exactly when u(x) = v(x), so at the inputs where the graphs cross: x = -1 (both heights 2) and x = 2 (both heights 5).

For the sketch, add heights column by column:

x-10123
u(x)23456
v(x)25652
(u + v)(x)4810108

Plotting these points and joining them smoothly gives the solid curve below.

x y −2 −1 1 2 3 4 2 4 6 8 10 u + v u v
Figure 2Each dot on u + v sits at the height of u plus the height of v at the same input.

As a check: the line is u(x) = x + 3, which fits all the readings, and the parabola is v(x) = -x^2 + 2x + 5, which gives v(-1) = 2, v(0) = 5, v(1) = 6, v(2) = 5, v(3) = 2. Then (u + v)(x) = -x^2 + 3x + 8, which gives exactly the bottom row of the table.

Example 6

Revenue and profit at a theater

Ilvar’s theater has found that when a ticket costs x dollars, it sells N(x) = 600 - 20x tickets, for prices from 0 to 30 dollars. Running a show costs 4000 dollars whatever the price. Build the revenue function R and the profit function P, find the profit at 15 dollars, and say why N + R would mean nothing.

Solution

Revenue is price times tickets sold. The price is the input itself, x dollars per ticket, and N(x) counts tickets, so the product has units of (dollars per ticket) times (tickets), which is dollars:

R(x) = x\,(600 - 20x) = 600x - 20x^2

This is the product of the function x \mapsto x with N. The cost is the constant function C(x) = 4000, in dollars. Profit is revenue minus cost, and both are in dollars, so the difference is meaningful:

P(x) = (R - C)(x) = 600x - 20x^2 - 4000

At a price of 15 dollars, P(15) = 9000 - 4500 - 4000 = 500, so the show makes 500 dollars. Through the pieces: N(15) = 300 tickets, R(15) = 15 \cdot 300 = 4500 dollars, and 4500 - 4000 = 500.

The sum N + R would add a number of tickets to a number of dollars. The arithmetic can be done, but the result measures nothing. Multiplying quantities with different units is meaningful (it makes a new unit); adding or subtracting them needs the same units.

Example 7

Working backwards, and how the degree behaves

With f(x) = 4x^2 - 3x + 6 and g(x) = x^2 + 4x - 7:

(a) A function k satisfies (f - k)(x) = 2x^2 + x + 9. Find k(x).

(b) Find (f - 4g)(x) and compare its degree with the degrees of f and g.

Solution

(a) At every input, f(x) - k(x) = 2x^2 + x + 9. Adding k(x) to both sides and subtracting 2x^2 + x + 9 from both gives k(x) = f(x) - (2x^2 + x + 9), so

\begin{aligned} k(x) &= (4x^2 - 3x + 6) - (2x^2 + x + 9)\\ &= 2x^2 - 4x - 3 \end{aligned}

Check: (4x^2 - 3x + 6) - (2x^2 - 4x - 3) = 2x^2 + x + 9.

(b) (4g)(x) = 4x^2 + 16x - 28, so

\begin{aligned} (f - 4g)(x) &= (4x^2 - 3x + 6) - (4x^2 + 16x - 28)\\ &= -19x + 34 \end{aligned}

Both f and g have degree 2, but f - 4g has degree 1: the multiple 4 made the x^2 terms equal, and they canceled. A sum or difference of polynomials has degree at most the larger of the two degrees, and it can be smaller when the leading terms cancel. A product never loses its top term, which is why fg in Example 2 had degree exactly 2 + 2 = 4.

Boundaries

Only at shared inputs. (f + g)(x), (f - g)(x) and (fg)(x) exist exactly when both f(x) and g(x) exist. So the domain of each combination is the set of inputs that lie in the domain of f and in the domain of g. In Example 4 that left x = 3 out. Simplifying a formula can hide this: if \displaystyle w(x) = \sqrt{x}, then (w - w)(x) = 0, but only for x \ge 0, since w(-4) does not exist as a real number. The function w - w is not the zero function on every real number. A quotient adds a further restriction, where the bottom output is zero, which is the subject of Dividing functions and the domain of a combination.

Outputs that can be combined. The operations act on outputs, so the outputs must be numbers. For a sum or a difference that describes something real, the two outputs also need the same units, as Example 6 showed.

Order matters for subtraction. f - g and g - f are different functions, each the opposite of the other. Sums and products do not depend on the order.

A product is not a composition. (fg)(x) multiplies f(x) by g(x). Feeding the output of g into f is a different operation, written f(g(x)) and taught in Composing functions algebraically. With Example 1’s functions, (fg)(0) = 6 \cdot (-7) = -42, while f(g(0)) = f(-7) = 196 + 21 + 6 = 223.

Where this goes next

Dividing outputs gives the quotient \displaystyle \frac{f}{g}, defined everywhere except where g(x) = 0; that gap in the domain is the new difficulty in Dividing functions and the domain of a combination. Feeding one function’s output into another, rather than combining the two outputs, is composition, the other half of Combining and composing functions.

Reading formulas as combinations also works in reverse. A quadratic ax^2 + bx + c is the sum of three simple functions, ax^2, bx and the constant c, and a factored polynomial is a product of linear functions, which is why its graph meets the axis exactly where one factor is zero. In calculus the rules for rates of change are stated for exactly these combinations: a rule for the rate of change of a sum, of a constant multiple, and of a product.

Exercises

Combining formulas

Let a(x) = 3x^2 - 7x + 2 and b(x) = x^2 + 9x - 6.

  1. Find (a + b)(x).
  2. Find (a - b)(x).
  3. Find (b - a)(x), and say how it relates to your answer to Exercise 2.
  4. Find (a + b)(-2) in two ways: from a(-2) and b(-2), and from your formula in Exercise 1.

Let r(t) = 3t - 4 and s(t) = 2t^2 + t - 5.

  1. Find (rs)(t).
  2. Find (rs)(2) in two ways.
  3. Find (5r)(t) and (-2s)(t).
  4. Find (2r - s)(t), and find every t with (2r - s)(t) = 0.
  5. Find (r \cdot r)(t).

Combining tables

The functions h and k are given by this table.

x01234
h(x)3-1406
k(x)-2517-3
  1. Make a table of (h + k)(x) for x = 0, 1, 2, 3, 4.
  2. Find (h - k)(3) and (k - h)(3).
  3. Make a table of (hk)(x) for x = 0, 1, 2, 3, 4.
  4. Find (3h - k)(1).
  5. Find (h + k)(4), and say whether the table gives a value of (h + k)(5).

Combining graphs

Use the graphs of p and q.

x y −3 −2 −1 1 2 3 4 5 −5 −4 −3 −2 −1 1 2 3 p q
Figure 3The functions p and q for Exercises 15 to 18.
  1. Find (p + q)(2).
  2. Find (p - q)(-2).
  3. Find (pq)(3) and (pq)(4).
  4. Find every x with (p - q)(x) = 0.

In context

  1. Odalric’s food truck takes in R(n) = 9n dollars and spends C(n) = 3n + 240 dollars on a day it sells n meals. Find the profit function P = R - C, the profit on a day with 50 meals, and the number of meals at which the profit is zero.
  2. A rectangle has width w(x) = x + 3 meters and length l(x) = 2x + 1 meters. Find its area A(x) = (wl)(x) as a polynomial, and the area when x = 4.
  3. On day t of a fair, N(t) people visit and each spends on average S(t) dollars. Which of N + S and NS means something, and what? Find it for day 3 if N(3) = 120 and S(3) = 15.

Reasoning

  1. Explain why (f + g)(x) = (g + f)(x) at every input, but (f - g)(x) and (g - f)(x) are opposites.
  2. Give two quadratic functions whose sum is a constant function. Then explain why the product of a polynomial of degree 2 and one of degree 3 always has degree exactly 5.
  3. Explain why the graph of f + g meets the horizontal axis exactly at the inputs where the graphs of f and -g cross.
  4. Explain why (fg)(x) = 0 exactly at the inputs where f(x) = 0 or g(x) = 0, and use it to find the zeros of (fg)(x) for f(x) = x - 5 and g(x) = 2x + 3.
Answers
  1. (a + b)(x) = 4x^2 + 2x - 4. Gather like terms: 3x^2 + x^2, -7x + 9x, 2 - 6.
  2. (a - b)(x) = 2x^2 - 16x + 8. Subtracting changes every sign of b(x): 3x^2 - 7x + 2 - x^2 - 9x + 6.
  3. (b - a)(x) = -2x^2 + 16x - 8, the opposite of a - b: each output of b - a is the opposite of the output of a - b at the same input.
  4. (a + b)(-2) = 8. Evaluating first: a(-2) = 12 + 14 + 2 = 28 and b(-2) = 4 - 18 - 6 = -20, so 28 + (-20) = 8. From the formula: 4(4) + 2(-2) - 4 = 16 - 4 - 4 = 8.
  5. (rs)(t) = 6t^3 - 5t^2 - 19t + 20. Distribute: 3t(2t^2 + t - 5) = 6t^3 + 3t^2 - 15t and -4(2t^2 + t - 5) = -8t^2 - 4t + 20, then combine like terms.
  6. (rs)(2) = 10. Evaluating first: r(2) = 2 and s(2) = 8 + 2 - 5 = 5, so 2 \cdot 5 = 10. From the formula: 48 - 20 - 38 + 20 = 10.
  7. (5r)(t) = 15t - 20 and (-2s)(t) = -4t^2 - 2t + 10. The constant multiplies every term.
  8. (2r - s)(t) = -2t^2 + 5t - 3, which is 0 at t = 1 and \displaystyle t = \frac{3}{2}. First 6t - 8 - (2t^2 + t - 5) = -2t^2 + 5t - 3. Setting it to 0 and multiplying by -1: 2t^2 - 5t + 3 = (2t - 3)(t - 1) = 0.
  9. (r \cdot r)(t) = 9t^2 - 24t + 16. This is (3t - 4)^2 = 9t^2 - 12t - 12t + 16.
  10. (h + k)(x) is 1, 4, 5, 7, 3 for x = 0, 1, 2, 3, 4. Column by column: 3 + (-2), -1 + 5, 4 + 1, 0 + 7, 6 + (-3).
  11. (h - k)(3) = -7 and (k - h)(3) = 7. h(3) - k(3) = 0 - 7 and k(3) - h(3) = 7 - 0.
  12. (hk)(x) is -6, -5, 4, 0, -18 for x = 0, 1, 2, 3, 4. Column by column: 3(-2), (-1)(5), 4(1), 0(7), 6(-3).
  13. (3h - k)(1) = -8. 3h(1) - k(1) = 3(-1) - 5 = -3 - 5.
  14. (h + k)(4) = 3, from 6 + (-3). The table gives no value of (h + k)(5): neither h(5) nor k(5) is given, and the sum needs both.
  15. (p + q)(2) = -4. From the graphs p(2) = -1 and q(2) = -3.
  16. (p - q)(-2) = -6. From the graphs p(-2) = -5 and q(-2) = 1, so -5 - 1 = -6.
  17. (pq)(3) = 0 and (pq)(4) = 1. p(3) = 0, so the product is 0 whatever q(3) is; and p(4) = 1, q(4) = 1.
  18. x = 0 and x = 4, where the graphs cross: p(0) = q(0) = -3 and p(4) = q(4) = 1.
  19. P(n) = 6n - 240 dollars; P(50) = 60 dollars; the profit is zero at n = 40 meals. 9n - (3n + 240) = 6n - 240, then 6(50) - 240 = 60, and 6n - 240 = 0 gives n = 40.
  20. A(x) = 2x^2 + 7x + 3 square meters, and A(4) = 63 square meters. (x + 3)(2x + 1) = 2x^2 + x + 6x + 3. At x = 4 the sides are 7 and 9 meters, and 7 \cdot 9 = 63.
  21. NS means something: (people) times (dollars per person) is dollars, the total spent on day t. N + S adds people to dollars and measures nothing. On day 3, (NS)(3) = 120 \cdot 15 = 1800 dollars.
  22. At each input x, (f + g)(x) = f(x) + g(x) and (g + f)(x) = g(x) + f(x), and these two numbers are equal because addition of numbers is commutative. Subtraction of numbers is not: g(x) - f(x) = -(f(x) - g(x)), so each output of g - f is the opposite of the output of f - g at that input.
  23. For example x^2 + 1 and -x^2 + 4, whose sum is 5 at every input: the x^2 terms cancel, and so do the (zero) x terms. For the product, the top terms ax^2 and bx^3, with a and b not zero, multiply to abx^5, and ab \ne 0. Every other pair of terms multiplies to a lower power, so nothing can cancel the x^5 term, and no term of higher power appears.
  24. The graph of f + g meets the horizontal axis where (f + g)(x) = 0, that is, where f(x) + g(x) = 0. Subtracting g(x) from both sides, that is where f(x) = -g(x): where the graph of f and the graph of -g have the same height at the same input, which is where they cross.
  25. (fg)(x) is the product of the two numbers f(x) and g(x), and a product of two real numbers is 0 exactly when at least one of them is 0 (the zero product property). For f(x) = x - 5 and g(x) = 2x + 3 the zeros are x = 5 and \displaystyle x = -\frac{3}{2}.
unattributed · CC-BY-SA-4.0