What is the composite function?
Type two functions f(x) and g(x). The page gives both composite functions, f(g(x)) and g(f(x)), simplified where that keeps the same domain, and their values at a point if you type one.
- f(g(x)) =
- -2x + 7
For f(x) = 2x + 1 and g(x) = 3 - x, f(g(x)) = -2x + 7.
- g(f(x)) =
- -2x + 2
f(g(x)) =: -2x + 7. For f(x) = 2x + 1 and g(x) = 3 - x, f(g(x)) = -2x + 7.
How to calculate
Finds the composite functions (f ∘ g)(x) = f(g(x)) and (g ∘ f)(x) = g(f(x)), simplified, and their values at x = a.
Example with the default inputs (f(x) 2x + 1, g(x) 3 - x): For f(x) = 2x + 1 and g(x) = 3 - x, f(g(x)) = -2x + 7.
Method: f(g(x)) is f with every x replaced by g(x); the result is expanded or simplified only when the shorter form is the same function on the same domain.
- The variable is x; angles in radians.
- The domain of f(g(x)) is the x where g(x) is in the domain of f.
Worked examples
Each example is checked against the calculator on every build.
- f(x) 2x + 1, g(x) 3 - x gives f(g(x)) = -2x + 7, g(f(x)) = -2x + 2.Source: OpenStax, College Algebra 2e, section 3.4 Composition of Functions (https://openstax.org/books/college-algebra-2e/pages/3-4-composition-of-functions), Example 2: f(g(x)) = 7 − 2x and g(f(x)) = −2x + 2
- f(x) x^2 - x, g(x) 3x + 2, At x = a (optional) 1 gives f(g(a)) 20, f(g(x)) = 9x^2 + 9x + 2.Source: OpenStax, College Algebra 2e, section 3.4 Composition of Functions (https://openstax.org/books/college-algebra-2e/pages/3-4-composition-of-functions), Example 7: f(h(1)) = 20
- f(x) sqrt(x), g(x) 5 - x^2 gives f(g(x)) = sqrt(5 - x^2).Source: OpenStax, College Algebra 2e, section 3.4 Composition of Functions (https://openstax.org/books/college-algebra-2e/pages/3-4-composition-of-functions), Example 10: g(h(x)) = √(5 − x²)
How it works
f and g are functions of x.
- f(g(x)) is f with every x replaced by (g(x)); g(f(x)) is g with every x replaced by (f(x)).
- Each is then expanded and simplified by a computer algebra system (nerdamer, open source). A form replaces the one as substituted only when it is shorter, equals it to 10⁻⁹ at 15 fixed test points (such as −7.31, −0.91, 0.21, 1.33, 8.93), and is a real number at exactly the same test points. Otherwise the composite shows as substituted. The page writes e^(ln(u)) as u; when the composite as written that way is real at other test points (e^(ln(x)) as x), there is no answer.
- At x = a (optional): f(g(a)) and g(f(a)) are worked out from the inside out, in double precision. A value that is not a real number is left out; if neither is real, there is no answer.
Terms are written with powers of x first, highest first, and a constant last. Angles are in radians.
Worked examples by hand
f(x) = 2x + 1, g(x) = 3 − x (OpenStax College Algebra 2e, Example 2). f(g(x)) = 2(3 − x) + 1 = −2x + 7. g(f(x)) = 3 − (2x + 1) = −2x + 2.
f(x) = x² − x, g(x) = 3x + 2, a = 1 (Example 7, with h for g). g(1) = 5 and f(5) = 20, so f(g(1)) = 20. f(g(x)) = (3x + 2)² − (3x + 2) = 9x² + 12x + 4 − 3x − 2 = 9x² + 9x + 2.
f(x) = √x, g(x) = 5 − x² (Example 10). f(g(x)) = √(5 − x²).
Other questions people ask
What is a composite function?
The function you get by applying one function to the output of another. (f ∘ g)(x) = f(g(x)): first g acts on x, then f acts on g(x). For f(x) = 2x + 1 and g(x) = 3 − x, f(g(x)) = 2(3 − x) + 1 = 7 − 2x.
Is f(g(x)) the same as g(f(x))?
Usually not. With the functions above, g(f(x)) = 3 − (2x + 1) = −2x + 2, which differs from f(g(x)) = 7 − 2x. Composition is not commutative. When f(g(x)) = g(f(x)) = x for all x, f and g are inverse functions.
How do I evaluate a composite function at a number?
Work from the inside out: find g(a), then put that value into f. For f(t) = t² − t and h(x) = 3x + 2, h(1) = 5 and f(5) = 25 − 5 = 20, so f(h(1)) = 20. Type a to get both values.
What is the domain of f(g(x))?
The x in the domain of g for which g(x) is in the domain of f. For f(x) = √x and g(x) = 5 − x², f(g(x)) = √(5 − x²) needs 5 − x² ≥ 0, so −√5 ≤ x ≤ √5.
Why does the page not simplify (√x)² to x?
The two differ for x < 0, where √x is not a real number. The page keeps a simpler form only when it is real at exactly the same test points as the composite as written. One point can still drop out: 1/(1/x) is shown as x, though x = 0 is not in its domain.
How do I decompose a function into a composite?
Look for an inside part. √(5 − x²) is g(h(x)) with h(x) = 5 − x² and g(x) = √x. Type those two here to check that the composite gives back the function.