F Of G Calculator
Evaluate the composite function f(g(x)) step by step. Pick a form for f and g, enter the coefficients and your x value.
Outer function f
Linear uses a and b only. Quadratic uses a, b and c. Reciprocal uses a only. Leave unused boxes at 0.
Inner function g
Same rule: linear uses a and b, quadratic uses a, b and c, reciprocal uses a only.
The input fed into g first, then the result of g is fed into f.
Function composition is one of those ideas that looks intimidating in a textbook and turns out to be beautifully simple once you see it in action. The notation f(g(x)) just means: take x, run it through the function g, then take whatever comes out and run it through the function f. Two machines in a row. The output of the first becomes the input of the second. That is the whole idea, and everything else is arithmetic.
Students usually meet composition in algebra and precalculus, and it shows up again in calculus with the chain rule, in computer science with piped functions, and in applied math wherever one formula feeds another. The classic stumbling block is order. People compute g(f(x)) when they meant f(g(x)), or they substitute x into the outer function first. A step-by-step calculator removes that confusion by showing the inner evaluation first, then the outer evaluation, with the substitution written out so you can follow every number.
This guide explains what f(g(x)) means, how to evaluate it by hand, the three function forms this calculator supports, and the domain traps that catch students out, especially with reciprocal functions. You will find worked examples with concrete numbers and answers to the fifteen most common questions. Whether you are checking homework, studying for an exam or just curious, the goal is the same: by the end, composition should feel mechanical rather than mysterious.
What f(g(x)) Really Means
Read f(g(x)) from the inside out. The parentheses tell you the order of operations, exactly like nested parentheses in arithmetic. First evaluate g at x. Call the result something, say u. Then evaluate f at u. The final answer is f(u), which we write as f(g(x)). The function on the inside always goes first, no matter how the expression looks on the page.
A concrete picture helps. Suppose g doubles its input and f adds ten. Then f(g(3)) means: g(3) is 6, and f(6) is 16. The answer is 16. Notice that g(f(3)) would be different: f(3) is 13, and g(13) is 26. Composition is not commutative. Swapping the order almost always changes the answer, which is why keeping track of which function is inner and which is outer is the single most important habit in this topic.
The Three Function Forms in This Calculator
This calculator supports three classic forms for each function. A linear function has the shape a times x plus b, a straight line with slope a. A quadratic has the shape a times x squared plus b times x plus c, a parabola. A reciprocal has the shape a divided by x, a hyperbola with a gap at zero. These three cover the large majority of composition problems in school algebra.
When you pick a form, only the coefficients that form needs matter. Linear needs a and b. Quadratic needs a, b and c. Reciprocal needs only a. The unused boxes can stay at zero without affecting anything. This mirrors how mathematicians think about these families: each form is defined by its pattern, and the coefficients just tune the specific curve.
Evaluating Composition Step by Step
The reliable method has exactly two steps. Step one: compute the inner value. Write down g(x) with your number substituted, simplify it, and box the result. Step two: feed that result into f. Write f of that number, substitute, simplify. Done. Writing the intermediate result down instead of doing it in your head is what separates correct answers from the very common mistake of plugging x into both functions.
Consider f(x) = 2x minus 5 and g(x) = 3x plus 1, evaluated at x = 2. Step one: g(2) = 3 times 2 plus 1 = 7. Step two: f(7) = 2 times 7 minus 5 = 9. So f(g(2)) = 9. The calculator shows exactly this layout, including the substituted expression, so you can verify each line against your own working.
Domain Traps: Where Composition Breaks
Composition is only defined where both steps make sense. The classic trap is the reciprocal. If g(x) = 4 / x, then x = 0 is forbidden for the inner function. But there is a subtler trap: even if x is fine for g, the value g(x) might be forbidden for f. If f(x) = 5 / x and g(2) comes out as 0, then f(g(2)) is undefined, because the outer function would divide by zero.
The practical rule: after computing g(x), always check that the result is allowed as an input to f. For reciprocal functions that means checking the value is not zero. For square root functions, which this calculator does not include, it would mean checking the value is not negative. Students lose more marks to domain errors than to arithmetic errors in this topic, so make the check a habit.
Composing the Same Functions in Reverse
One of the most instructive exercises is computing both f(g(x)) and g(f(x)) for the same pair of functions and comparing. Take f(x) = x plus 2 and g(x) = 3x. Then f(g(4)) = f(12) = 14, while g(f(4)) = g(6) = 18. Different answers from the same ingredients. The rare cases where the two orders agree are special: inverse functions undo each other, so f(g(x)) = x, and a few symmetric pairs commute by coincidence.
This asymmetry is not a quirk; it is the point. Composition models processes where order matters: put on socks then shoes gives a different result from shoes then socks. In mathematics the same principle governs everything from function machines to matrix multiplication. Whenever a problem asks for g(f(x)) instead of f(g(x)), slow down and relabel which function is inner before touching any numbers.
From Numbers to Formulas
Once you can evaluate f(g(x)) at a number, the next step is finding the formula for f(g(x)) as a function of x. The method is the same, but instead of a number you substitute the whole expression for g. If f(x) = 2x plus 1 and g(x) = x squared, then f(g(x)) = 2 times x squared plus 1. The x squared, the entire output pattern of g, goes wherever x appeared in f.
This skill pays off in calculus, where the chain rule differentiates composite functions by exactly this structure, and in programming, where piping data through a chain of functions is everyday work. The numeric evaluation you practice here is the foundation. If you can do f(g(3)) reliably, the formula version is one small step further, and most students find it clicks once the two-step numeric habit is solid.
Worked Example: Linear Inside Linear
Let f(x) = 2x minus 5 and g(x) = 3x plus 1, with x = 2. Step one: g(2) = 3 times 2 plus 1 = 6 plus 1 = 7. Step two: f(7) = 2 times 7 minus 5 = 14 minus 5 = 9. Therefore f(g(2)) = 9. As a sanity check, the reverse order gives g(f(2)) = g(minus 1) = 3 times minus 1 plus 1 = minus 2, confirming that order matters.
Worked Example: Quadratic Outside, Linear Inside
Let f(x) = x squared plus 2x plus 1 and g(x) = 2x minus 3, with x = 4. Step one: g(4) = 2 times 4 minus 3 = 8 minus 3 = 5. Step two: f(5) = 5 squared plus 2 times 5 plus 1 = 25 plus 10 plus 1 = 36. Therefore f(g(4)) = 36. Notice that f is the expansion of (x plus 1) squared, so f(5) = 36 is also 6 squared, a nice cross-check.
Worked Example: Reciprocal in the Mix
Let f(x) = 6 / x and g(x) = x plus 2, with x = 1. Step one: g(1) = 1 plus 2 = 3. Step two: f(3) = 6 / 3 = 2. Therefore f(g(1)) = 2. Now try x = minus 2: g(minus 2) = 0, and f(0) would divide by zero, so f(g(minus 2)) is undefined. This is the domain trap in action, and the calculator flags it instead of silently producing nonsense.
Worked Example: Finding the Composite Formula
Let f(x) = 4x plus 7 and g(x) = x squared minus 1. To find the formula for f(g(x)), substitute the whole of g into f: f(g(x)) = 4 times (x squared minus 1) plus 7 = 4x squared minus 4 plus 7 = 4x squared plus 3. Checking at x = 2: g(2) = 3, f(3) = 19, and the formula gives 4 times 4 plus 3 = 19. The formula and the numeric route agree, as they must.
Frequently Asked Questions
1. What does f(g(x)) mean?
It means apply g to x first, then apply f to the result. The inner function g acts first, and its output becomes the input of the outer function f. Read it inside out, following the parentheses, and you will always get the order right.
2. Which function do I evaluate first in f(g(x))?
Always g, the inner one. Compute g(x), write down the result, then feed that result into f. Evaluating f first is the most common mistake in this topic and it changes the answer.
3. Is f(g(x)) the same as g(f(x))?
Almost never. Composition is generally not commutative, so swapping the order changes the result. With f(x) = 2x and g(x) = x plus 5, f(g(1)) = 12 but g(f(1)) = 7. Always check which function the problem names first.
4. What is the difference between f(g(x)) and f(x) times g(x)?
They are completely different operations. f(g(x)) feeds the output of g into f, while f(x) times g(x) multiplies the two outputs together. For f(x) = x plus 1 and g(x) = 2x at x = 3: f(g(3)) = 7, but f(3) times g(3) = 4 times 6 = 24.
5. How do I find f(g(x)) as a formula instead of a number?
Substitute the entire expression for g(x) wherever x appears in f, then simplify. With f(x) = 3x minus 2 and g(x) = x squared, f(g(x)) = 3 times x squared minus 2. The parentheses around g(x) keep the substitution clean.
6. What happens if g(x) equals zero and f is a reciprocal?
Then f(g(x)) is undefined, because the outer function would divide by zero. Always check that the value coming out of g is an allowed input for f. A good calculator flags this instead of dividing by zero.
7. Can I compose three functions, like f(g(h(x)))?
Yes. Work from the innermost outward: compute h(x), feed it into g, feed that result into f. The same two-step habit extends naturally. For h(x) = x plus 1, g(x) = 2x, f(x) = x squared at x = 2: h gives 3, g gives 6, f gives 36.
8. What is the domain of a composite function?
All x values such that x is in the domain of g and g(x) is in the domain of f. Both conditions must hold. For f(x) = 1/x and g(x) = x minus 4, x = 4 is excluded because g(4) = 0 is not allowed into f.
9. Why do unused coefficient boxes not matter?
Because each function form only reads the coefficients it needs. A linear function uses a and b, so whatever sits in c is ignored. This matches the mathematics: the form defines the pattern, and extra numbers outside the pattern have no meaning.
10. How is composition used in calculus?
The chain rule is composition in action: the derivative of f(g(x)) is f prime of g(x) times g prime of x. Every time you differentiate something like sin(x squared), you are undoing a composition. Fluency with numeric composition makes the chain rule far less mysterious.
11. What does it mean if f(g(x)) equals x?
Then f and g are inverse functions, each undoing the other. For example f(x) = 2x and g(x) = x/2 compose to x in both orders. Inverse pairs are the special case where order genuinely does not matter.
12. Can the inner and outer functions be the same?
Yes, that is called iteration. f(f(x)) applies f twice. With f(x) = 2x plus 1 at x = 3: f(3) = 7, then f(7) = 15, so f(f(3)) = 15. Iteration shows up in fractals, population models and repeated processes.
13. How do I check my answer by hand?
Recompute the two steps separately on paper: first g(x) with the substitution written out, then f of that result. Then try the reverse order or a nearby x value to make sure the method is stable. If a formula version exists, evaluate it at the same x and confirm both routes agree.
14. Why is it called the outer and inner function?
Because of how they sit in the notation f(g(x)). The g is nested inside the parentheses, closer to x, so it is inner and acts first. The f wraps around the whole thing, so it is outer and acts last. The visual nesting mirrors the order of evaluation.
15. Where does function composition appear outside math class?
Everywhere pipelines exist. Image filters apply one effect then another, spreadsheets nest formulas inside formulas, and programs pipe data through chains of functions. Anytime the output of one process becomes the input of the next, you are looking at composition.