Function Composition Calculator — (f∘g)(x)

AlgebraFreeNo sign-up

To find f(g(x)), replace every x in f with the whole expression g(x), then simplify. With f(x) = x² + 1 and g(x) = 2x − 3, f(g(x)) = (2x − 3)² + 1 = 4x² − 12x + 10, while g(f(x)) = 2x² − 1. The function composition calculator below does this for any two functions and also finds the domain of the composition.

Function composition calculator with steps
Reads asReads asf(x) = √x − 3 · g(x) = x2 + 1
Composition
Type x^2 for x², 3x for 3·x, sqrt(x), (x+1)/(x-2), |x|, e^x, ln(x), sin(x). Use brackets for fractions: 1/(x+1).
Try:
Composite function f∘g
f(g(x)) =√x2 − 2
Domain of f∘g(−∞, −√2] ∪ [√2, ∞)
Before simplifying√((x² + 1) − 3)
g(2)5
f(g(2)) = f(5)√2 ≈ 1.41421
−55510(2, 1.41)
f(g(x)) = √(x² − 2)inner function g(x) = x² + 1
Show steps
  1. Meaning(f∘g)(x) means f(g(x)): work from the inside out. First apply g, then put its output into f.
  2. Outer functionf(x) = √x − 3
  3. SubstituteReplace every x in f(x) with g(x) = x² + 1: f(g(x)) = √((x² + 1) − 3)
  4. SimplifySimplify: f(g(x)) = √x2 − 2
  5. Domain of the inner functiong(x) = x² + 1 is defined for all real numbers.
  6. Restriction from ff(x) = √(x − 3) needs: a square root needs an input of at least 0. With x replaced by g(x): x² − 2 ≥ 0, which holds for x ≤ −√2 or x ≥ √2.
  7. Domain of f∘gKeep the x values that pass every test: (−∞, −√2] ∪ [√2, ∞), that is, x ≤ −√2 or x ≥ √2.
  8. Evaluate at x = 2Inside first: g(2) = 5. Then f(5) = √2 ≈ 1.41421. Check with the simplified formula: 1.41421.
The other compositions
g(f(x))x − 2
f(f(x))√√x − 3 − 3
g(g(x))x4 + 2x2 + 2

Order matters: f(g(x)) and g(f(x)) are usually different functions.

Next: graph f(g(x)) · find an inverse function · domain and range calculator

Function Composition Calculator — (f∘g)(x)
Embed this calculator on your site

Free to use on class pages, blogs and course pages. Copy the code below and paste it into your page:

How to use the function composition calculator

  1. Type f(x) and g(x), for example sqrt(x – 3) and x^2 + 1. The “Reads as” line shows how each one was understood, so a missing bracket is easy to spot.
  2. Choose the composition: f(g(x)), g(f(x)), f(f(x)) or g(g(x)).
  3. Optionally enter a value of x. You get the inside value g(a) first, then f(g(a)), exact when possible.
  4. Read the simplified composite function, its domain in interval notation and the graph. Open Show steps for the substitution, the simplification and every domain restriction, and The other compositions to compare the orders.

How composition works

The composition (f∘g)(x), read “f of g of x”, means f(g(x)): start with x, apply g, then feed the result into f. Think of two machines in a row. The inner function g works first, and the outer function f works on whatever g produces.

There are two ways to use it:

  • At a number: work from the inside out. With f(x) = x² + 1 and g(x) = 2x − 3, g(1) = −1, so (f∘g)(1) = f(−1) = 2.
  • As a formula: substitute g(x) into f and simplify. f(g(x)) = (2x − 3)² + 1 = 4x² − 12x + 10. Check: at x = 1 the formula gives 4 − 12 + 10 = 2, the same answer.

Order matters: f(g(x)) versus g(f(x))

Composition is usually not commutative. For the same pair, g(f(x)) = 2(x² + 1) − 3 = 2x² − 1, which is a different function from 4x² − 12x + 10. You can also compose a function with itself: f(f(x)) = (x² + 1)² + 1 = x⁴ + 2x² + 2.

f(x) g(x) f(g(x)) g(f(x))
x² + 1 2x − 3 4x² − 12x + 10 2x² − 1
1/x x − 2 1/(x − 2) 1/x − 2
x² √x x, for x ≥ 0 |x|
3x + 2 (x − 2)/3 x x
x³ x + 1 x³ + 3x² + 3x + 1 x³ + 1

The row with 3x + 2 shows a special case: both compositions give x, so each function undoes the other. That is exactly the test for inverse functions, and the calculator points it out when it happens.

The domain of a composite function

The domain of f∘g is every x that passes two tests:

  1. x is in the domain of the inner function g, and
  2. g(x) is in the domain of the outer function f.

Take f(x) = √(x − 3) and g(x) = x² + 1. The inner function accepts every real number. The square root in f needs its input to be at least 3, so we need x² + 1 − 3 ≥ 0, that is x² ≥ 2. The domain of f(g(x)) = √(x² − 2) is x ≤ −√2 or x ≥ √2, written (−∞, −√2] ∪ [√2, ∞).

Always find the domain before simplifying. With f(x) = x² and g(x) = √x, the formula simplifies to f(g(x)) = x, which looks defined everywhere. But g only accepts x ≥ 0, so the composition is defined only for x ≥ 0. The calculator works from the unsimplified expression and warns you whenever the simplified formula would suggest a larger domain.

Worked examples

Example 1: polynomials, both orders

f(x) = x² + 1 and g(x) = 2x − 3. Substitute: f(g(x)) = (2x − 3)² + 1. Expand (2x − 3)² = 4x² − 12x + 9 and add 1: 4x² − 12x + 10. The other order: g(f(x)) = 2(x² + 1) − 3 = 2x² − 1. Both are polynomials, so both domains are all real numbers.

Example 2: a square root with a restricted domain

f(x) = √(x − 3) and g(x) = x² + 1. f(g(x)) = √((x² + 1) − 3) = √(x² − 2), with domain x ≤ −√2 or x ≥ √2. At x = 2: g(2) = 5, then f(5) = √2 ≈ 1.41421.

Example 3: rational functions

f(x) = (x + 1)/(x − 2) and g(x) = 1/x. Substitute and multiply the top and bottom by x: f(g(x)) = (1/x + 1)/(1/x − 2) = (1 + x)/(1 − 2x) = −(x + 1)/(2x − 1). The domain excludes x = 0 (g is undefined) and x = 1/2 (g(x) = 2, where f is undefined). At x = 3: g(3) = 1/3, and f(1/3) = (4/3)/(−5/3) = −4/5.

Common mistakes to avoid

  • Multiplying instead of composing. f(g(x)) is not f(x) · g(x). With f(x) = x² + 1 and g(x) = 2x − 3, the product is a cubic, but the composition is a quadratic.
  • Working in the wrong order. In f(g(x)) the inside function g goes first, even though f is written first.
  • Dropping brackets. Replacing x with 2x − 3 in x² gives (2x − 3)², not 2x − 3².
  • Taking the domain from the simplified formula. Restrictions from the inner function stay, even when the formula no longer shows them.

Using the calculator for homework

Do the substitution by hand first, then compare with Show steps: the first line that differs from yours is where the mistake is. For a value question, check your answer twice: inside out with numbers, and by plugging the value into the simplified formula. When you finish a problem, change one function slightly and predict the new composition before pressing Compose. Composition also matters later: the chain rule in calculus is the rule for differentiating f(g(x)), and the derivative calculator names it at each step.

Function composition practice quiz: 10 questions

Test yourself with 10 multiple-choice questions. Choose an answer and press Submit to see if you are right and why. Your score appears at the end.

Question 1 of 10
1. If f(x) = 3x + 1 and g(x) = x², what is f(g(x))?

Found a mistake? Let us know!

2. If f(x) = 3x + 1 and g(x) = x², what is g(f(x))?

Found a mistake? Let us know!

3. If f(x) = 2x − 5 and g(x) = x + 4, what is (f∘g)(3)?

Found a mistake? Let us know!

4. If f(x) = x² − 1, what is f(f(x))?

Found a mistake? Let us know!

5. What is the domain of f(g(x)) for f(x) = √x and g(x) = x − 5?

Found a mistake? Let us know!

6. What is the domain of f(g(x)) for f(x) = 1/x and g(x) = x − 3?

Found a mistake? Let us know!

7. For f(x) = x² and g(x) = √x, which statement is true?

Found a mistake? Let us know!

8. Which pair of functions are inverses, so that f(g(x)) = g(f(x)) = x?

Found a mistake? Let us know!

9. If h(x) = (x + 2)³ is written as f(g(x)) with g(x) = x + 2, what is f(x)?

Found a mistake? Let us know!

10. If f(x) = 1/x and g(x) = 1/x, what is f(g(x)) and its domain?

Found a mistake? Let us know!

Frequently asked questions

What does f∘g mean?

f∘g is the composite function "f of g": (f∘g)(x) = f(g(x)). You apply g to x first, then apply f to the result. With g(x) = 2x − 3 and f(x) = x² + 1, (f∘g)(1) = f(g(1)) = f(−1) = 2.

Is f∘g the same as g∘f?

Usually not. With f(x) = x² + 1 and g(x) = 2x − 3, f(g(x)) = 4x² − 12x + 10 but g(f(x)) = 2x² − 1. The two orders agree for special pairs, such as a function and its inverse, where both give x.

How do you find the domain of a composite function?

Keep the x values in the domain of the inner function whose outputs are in the domain of the outer function. For f(x) = √x and g(x) = 4 − x², we need 4 − x² ≥ 0, so the domain of f(g(x)) is −2 ≤ x ≤ 2.

Can I use trig and other functions?

Yes. Besides polynomials, fractions and roots, you can enter sin, cos, tan, e^x, ln, log (base 10), arcsin, arctan and |x|. For example, sin(x) with g(x) = x² gives sin(x²). Domains are worked out for roots, fractions, logarithms and inverse trig; for tan the calculator states the condition cos ≠ 0.

How do you evaluate a composite function at a number?

Work from the inside out: find g(a) first, then put that number into f. For f(x) = √(x − 3) and g(x) = x² + 1 at x = 2, g(2) = 5 and f(5) = √2.

Related calculators

More algebra calculators

Browse all 544 calculators

Related to This Article

What people say about "Composition of Functions Calculator: f(g(x)) Steps & Domain"?

No one replied yet.

Leave a Reply