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.
Show steps
- Meaning(f∘g)(x) means f(g(x)): work from the inside out. First apply g, then put its output into f.
- Outer functionf(x) = √x − 3
- SubstituteReplace every x in f(x) with g(x) = x² + 1: f(g(x)) = √((x² + 1) − 3)
- SimplifySimplify: f(g(x)) = √x2 − 2
- Domain of the inner functiong(x) = x² + 1 is defined for all real numbers.
- 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.
- Domain of f∘gKeep the x values that pass every test: (−∞, −√2] ∪ [√2, ∞), that is, x ≤ −√2 or x ≥ √2.
- Evaluate at x = 2Inside first: g(2) = 5. Then f(5) = √2 ≈ 1.41421. Check with the simplified formula: 1.41421.
The other compositions
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
How to use the function composition calculator
- 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.
- Choose the composition: f(g(x)), g(f(x)), f(f(x)) or g(g(x)).
- Optionally enter a value of x. You get the inside value g(a) first, then f(g(a)), exact when possible.
- 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:
- x is in the domain of the inner function g, and
- 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.
Replace x in f with g(x) = x²: f(x²) = 3x² + 1. (3x + 1)² is g(f(x)), the other order.
g(f(x)) = (3x + 1)² = 9x² + 6x + 1. Forgetting the middle term 6x is a common slip.
(√x)² = x, but √x only accepts x ≥ 0, so the composition keeps that restriction even though the formula is just x.
(2x + 6 − 6)/2 = x and 2·(x − 6)/2 + 6 = x, so both compositions give x.
The inner function adds 2 and the outer function cubes the result: f(x) = x³ gives f(g(x)) = (x + 2)³.
f(1/x) = 1/(1/x) = x, but g(x) = 1/x is undefined at x = 0, so 0 stays excluded.
Quiz complete
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
- Inverse function calculator
- Domain and range calculator
- Function grapher
- Derivative calculator
- Difference quotient calculator
More algebra calculators
Related to This Article
More math articles
- Kansas Algebra 1 Free Worksheets: 64 Free Printable Algebra 1 Worksheets with Step-by-Step Keys
- The Best Grade 2 English Worksheets for Kentucky Students
- Chemistry, pH, Water, and Contact Time
- South Carolina SC READY Grade 3 Math Worksheets — 49 Free Printable Single-Skill PDFs
- How to Balance the Scales: Inequalities with Addition and Subtraction of Mixed Numbers
- How to Identify Rational and Irrational Numbers?
- The Ultimate TNReady Algebra 1 Course (+FREE Worksheets)
- Words for Quantity and Degree
- Sum and Difference of Trigonometric Functions Formulas
- Free Grade 4 English Worksheets for Virginia Students





What people say about "Composition of Functions Calculator: f(g(x)) Steps & Domain"?
No one replied yet.