Unit 4, lesson 33

Composing Functions

How to feed the output of one function into another, write the composite as one formula with correct parentheses, and find the inputs where the composite is defined.

  • Theory part 65
  • Practice part 66
  • Combining and Inverting Functions

A square garden is fenced with a known length of fence. The fence length tells you the side, and the side tells you the area. Two small rules run one after the other, and chaining them gives one rule that goes straight from fence length to area. That chaining is composition, and calculus uses it constantly, most of all in the chain rule.

Key terms

Output used as input

Definition Let gg and ff be functions and let xx be in the domain of gg. The output g(x)g(x) is a number, and if that number lies in the domain of ff, then ff can be evaluated at it, giving the number f(g(x))f(g(x)). If g(x)g(x) is not in the domain of ff, the second step is undefined for that xx.

In plain words The first function produces a number, and the second function treats that number as its own input.

Example Let g(x)=x+3g(x) = x + 3 and f(u)=u2f(u) = u^2. Follow a few inputs through both steps.

xxg(x)g(x)f(g(x))f(g(x))
−3-30000
11441616
22552525

Every middle value is visible, so you can see exactly where each final output came from.

Function composition

Definition The composition of ff with gg is the function f∘gf \circ g, read ”ff composed with gg” or ”ff of gg”, given by

(f∘g)(x)=f(g(x)).(f \circ g)(x) = f(g(x)).

Its domain is the set of all xx in the domain of gg for which g(x)g(x) is in the domain of ff. The small circle is not multiplication. In general (f∘g)(x)(f \circ g)(x) and f(x)⋅g(x)f(x) \cdot g(x) are different numbers.

In plain words Apply gg first, then apply ff to the result. The function written on the right acts first.

Example With f(x)=1xf(x) = \frac{1}{x} and g(x)=x2+1g(x) = x^2 + 1,

(f∘g)(x)=1x2+1.(f \circ g)(x) = \frac{1}{x^2 + 1}.

Here g(x)≥1g(x) \ge 1 for every real xx, so g(x)g(x) is never 00 and the composite is defined for all real numbers. Compare the product f(x)⋅g(x)=x+1xf(x) \cdot g(x) = x + \frac{1}{x}, which is a different function with domain x≠0x \ne 0.

Inner function

Definition In the composite f(g(x))f(g(x)), the function gg is the inner function. It is applied first, directly to xx, and its output g(x)g(x) is called the intermediate value. Writing a given formula as f(g(x))f(g(x)) is called decomposing it. A formula can usually be decomposed in more than one way, and the useful choice is the one whose pieces are simple.

In plain words The inner function is the part that touches xx first, the expression sitting inside the parentheses, the radical or the exponent.

Example Take h(x)=(3x−1)5h(x) = (3x - 1)^5. The first thing done to xx is to compute 3x−13x - 1, so a natural choice is the inner function g(x)=3x−1g(x) = 3x - 1 with outer function f(u)=u5f(u) = u^5. At x=1x = 1 the intermediate value is g(1)=2g(1) = 2, and then h(1)=25=32h(1) = 2^5 = 32.

Outer function

Definition In the composite f(g(x))f(g(x)), the function ff is the outer function. It is applied last, to the intermediate value g(x)g(x). To form the composite formula, replace every occurrence of the input variable in the rule for ff by the whole expression g(x)g(x), written inside parentheses so its grouping is kept.

In plain words The outer rule does not care what its input is called. Whatever you feed it goes into every slot where its variable appeared, wrapped in parentheses.

Example Let f(x)=x2−2xf(x) = x^2 - 2x and g(x)=x+1g(x) = x + 1. Each xx in the rule for ff becomes (x+1)(x + 1).

f(g(x))=(x+1)2−2(x+1)=x2+2x+1−2x−2=x2−1.\begin{aligned} f(g(x)) &= (x + 1)^2 - 2(x + 1) \\[0.4em] &= x^2 + 2x + 1 - 2x - 2 \\[0.4em] &= x^2 - 1. \end{aligned}

Dropping the parentheses would give x+12−2x+1=−x+2x + 1^2 - 2x + 1 = -x + 2, which is wrong. At x=2x = 2 the correct composite gives f(3)=9−6=3f(3) = 9 - 6 = 3, and indeed 22−1=32^2 - 1 = 3.

Composite function

Definition The composite function f∘gf \circ g is a single function in its own right, with one input, one output and its own domain. When a quantity qq depends on a quantity ss through q=f(s)q = f(s), and ss depends on xx through s=g(x)s = g(x), the composite q=f(g(x))q = f(g(x)) expresses qq directly in terms of xx. The units must match along the chain, so the output unit of gg has to be the input unit that ff expects.

In plain words Once the two steps are merged you get one formula, yet you can still say what each piece measures.

Example A square has perimeter PP centimeters, with P>0P > 0. All four sides are equal, so the side length in centimeters is

s(P)=P4.s(P) = \frac{P}{4}.

The area of a square with side s>0s > 0 centimeters is A(s)=s2A(s) = s^2 square centimeters. A squared length is an area, so the unit becomes square centimeters. The composite gives area from perimeter.

A(s(P))=(P4)2=P216 square centimeters,P>0.\begin{aligned} A(s(P)) &= \left(\frac{P}{4}\right)^2 \\[0.4em] &= \frac{P^2}{16} \text{ square centimeters}, \\[0.4em] &P > 0. \end{aligned}

For P=20P = 20 the side is 55 centimeters and the area is 2525 square centimeters, and the single formula agrees since 40016=25\frac{400}{16} = 25. If the perimeter were measured in meters and the area rule expected centimeters, you would first have to convert.

Composite domain

Definition The domain of f∘gf \circ g is

{ x: x∈dom⁡(g) andg(x)∈dom⁡(f) }.\begin{aligned} \{\, x : \ & x \in \operatorname{dom}(g) \ \text{and} \\[0.4em] & g(x) \in \operatorname{dom}(f) \,\}. \end{aligned}

Both conditions are required. The domain is decided by the two original rules, not by how the final formula looks after simplifying.

In plain words An input is allowed only if the inner function accepts it and the outer function accepts what comes out.

Example Let f(x)=1x−2f(x) = \frac{1}{x - 2} and g(x)=xg(x) = \sqrt{x}. The inner function needs x≥0x \ge 0. The outer function needs its input to differ from 22, so we need x≠2\sqrt{x} \ne 2, which rules out x=4x = 4. The composite

f(g(x))=1x−2f(g(x)) = \frac{1}{\sqrt{x} - 2}

has domain [0,4)∪(4,∞)[0, 4) \cup (4, \infty). A simplified formula can hide a condition. With f(x)=x2f(x) = x^2 and g(x)=xg(x) = \sqrt{x} the composite simplifies to xx, yet its domain is still [0,∞)[0, \infty), because g(−1)g(-1) is not a real number.

Order of composition

Definition Composition is generally not commutative. For most pairs of functions f∘gf \circ g and g∘fg \circ f have different formulas, and they can also have different domains and different outputs. The order of operations is read from the inside out, so in f(g(x))f(g(x)) the function gg acts first.

In plain words Putting on socks and then shoes is not the same as shoes and then socks. Which function acts first matters.

Example Let f(x)=x2f(x) = x^2 and g(x)=x+3g(x) = x + 3. Then

f(g(x))=(x+3)2,g(f(x))=x2+3.\begin{gathered} f(g(x)) = (x + 3)^2, \\[0.4em] g(f(x)) = x^2 + 3. \end{gathered}

At x=1x = 1 the first gives 1616 and the second gives 44. Domains can differ too. With f(x)=xf(x) = \sqrt{x} and g(x)=x−4g(x) = x - 4, the composite f(g(x))=x−4f(g(x)) = \sqrt{x - 4} has domain [4,∞)[4, \infty), while g(f(x))=x−4g(f(x)) = \sqrt{x} - 4 has domain [0,∞)[0, \infty).

Check yourself

  1. Let f(x)=2x−1f(x) = 2x - 1 and g(x)=x2+1g(x) = x^2 + 1. Find f(g(x))f(g(x)) and g(f(x))g(f(x)), and evaluate both at x=2x = 2.
Show the answer

Substituting the whole inner expression each time gives

f(g(x))=2(x2+1)−1=2x2+1,g(f(x))=(2x−1)2+1=4x2−4x+2.\begin{aligned} f(g(x)) &= 2(x^2 + 1) - 1 \\[0.4em] &= 2x^2 + 1, \\[0.4em] g(f(x)) &= (2x - 1)^2 + 1 \\[0.4em] &= 4x^2 - 4x + 2. \end{aligned}

At x=2x = 2 the first is 99 and the second is 1010, so the order changes the output.

  1. Let f(x)=x−1f(x) = \sqrt{x - 1} and g(x)=1xg(x) = \frac{1}{x}. Find the domain of f(g(x))f(g(x)).
Show the answer

The inner function needs x≠0x \ne 0. The outer function needs 1x−1≥0\frac{1}{x} - 1 \ge 0, that is 1x≥1\frac{1}{x} \ge 1, which holds exactly when 0<x≤10 < x \le 1. The domain is (0,1](0, 1].

  1. A circle has circumference CC centimeters, with C>0C > 0. Write its area as a function of CC by composing the radius rule with the area rule, and find the area when C=10C = 10.
Show the answer

The radius is r=C2πr = \frac{C}{2\pi} centimeters and the area is πr2\pi r^2 square centimeters, so

A=π(C2π)2=C24π square centimeters,C>0.\begin{aligned} A &= \pi \left(\frac{C}{2\pi}\right)^2 \\[0.4em] &= \frac{C^2}{4\pi} \text{ square centimeters}, \\[0.4em] &C > 0. \end{aligned}

For C=10C = 10 the area is 1004π=25π≈7.96\frac{100}{4\pi} = \frac{25}{\pi} \approx 7.96 square centimeters.

How this lesson connects