Compositions of Functions Calculator
Chain three linear functions f, g and h. The calculator collapses the whole chain into one composed formula and evaluates it at every x you enter.
First applied: h
h(x) = a·x + b
Then: g
g(x) = a·x + b
Last: f
f(x) = a·x + b
Up to 12 values. The chain runs h first, then g, then f for each one.
Composed chain
(f ∘ g ∘ h)(x) =
Reverse order (h ∘ g ∘ f)(x) =
Step-by-step values
| x | h(x) | g(h(x)) | (f ∘ g ∘ h)(x) | (h ∘ g ∘ f)(x) |
|---|
Two functions chained together are useful. Three chained together start to look like real mathematics, the kind that powers computer graphics, signal processing, and multi-stage pricing models.
The notation (f ∘ g ∘ h)(x) looks dense, but it describes a simple assembly line: x enters h, the result enters g, and that result enters f. The only hard part is keeping the order straight.
The calculator above does the bookkeeping for you. You enter three linear functions, and it collapses the whole chain into a single composed formula, then evaluates it at every x value you list.
What the Compositions of Functions Calculator Does
This tool chains three linear functions, f, g, and h, into one composition. You type the slope a and intercept b for each function, then list the x values you want evaluated, separated by commas.
It returns two things: the simplified composed formula for the forward chain (f ∘ g ∘ h)(x) and for the reverse chain (h ∘ g ∘ f)(x), plus a table showing every intermediate value at each of your x points.
How to Use the Compositions of Functions Calculator
Fill in the three panels from right to left in application order: h is applied first, then g, then f. Each panel only needs a slope and an intercept, since every function here is a straight line.
Then type your x values into the box, like 0, 1, 2, 5, and press Calculate. Up to twelve values are evaluated at once, each one traced through the full chain step by step.
Reading (f∘g∘h)(x) From Right to Left
Composition notation reads right to left for application order. In (f ∘ g ∘ h)(x), h touches x first even though f is written first.
The expanded form makes this obvious:
(f ∘ g ∘ h)(x) = f(g(h(x)))
The innermost parentheses always win. Students who read left to right get the chain backwards, so train your eye to start at the rightmost function.
Why Order Changes Everything
Each function in the chain transforms its input before passing it on, so rearranging the stages rearranges the result. A steep slope applied early gets amplified by everything after it.
This is why the calculator shows the reverse order too. Comparing (f ∘ g ∘ h)(x) with (h ∘ g ∘ f)(x) for the same numbers is the clearest possible demonstration that composition order is not interchangeable.
The Composed Formula: One Line That Replaces Three
Chaining three lines always produces another line. If f(x) = a₁x + b₁, g(x) = a₂x + b₂, and h(x) = a₃x + b₃, the whole chain collapses to:
(f ∘ g ∘ h)(x) = (a₁a₂a₃)x + (a₁a₂b₃ + a₁b₂ + b₁)
One evaluation replaces three. The calculator derives this formula automatically and displays it above the table, so you can reuse it anywhere without recomputing the chain.
How the Calculator Builds the Composed Formula
The math happens in two substitutions. First h(x) goes into g, giving a new line with slope a₂a₃ and intercept a₂b₃ + b₂. Then that line goes into f, multiplying the slope by a₁ and folding the intercepts together.
You never see this algebra on screen, but the displayed formula is exactly what you would get doing it by hand. Check it once with pencil and paper and you will trust it forever.
Evaluating at Multiple Points
Real problems rarely ask about a single x. Plotting a composed function, testing a model, or checking homework all need several points, and recomputing the chain each time is tedious.
The comma-separated input handles this. Each x gets its own table row with h(x), g(h(x)), and the final composed value, so patterns across inputs jump out immediately.
Left-to-Right vs Right-to-Left Order
The calculator treats the two orders as separate questions. Forward order applies h, then g, then f. Reverse order applies f, then g, then h.
Both share the same overall slope a₁a₂a₃, because multiplication commutes, but their intercepts differ. The intercept is where order leaves its fingerprint, and the table lets you watch that difference grow or shrink across x values.
Identity Check: When Composition Returns x
If every function is y = x, meaning a = 1 and b = 0 in all three panels, the chain does nothing and the composed formula is simply x. This is a great sanity check.
Try it: with all slopes 1 and all intercepts 0, every table row should show the input x unchanged through every stage. If it does, the calculator is reading your functions correctly.
Zero Slopes and Constant Results
Setting any slope to 0 makes that stage a constant function, and a constant anywhere in the chain flattens everything after it into a constant too.
For example, if g has a = 0 and b = 5, then every x emerges from g as 5, and the final answer is just f(5) regardless of input. The table makes this beautifully obvious: a whole column of identical numbers.
Common Chaining Mistakes
The classic error is applying the functions left to right: computing f(x) first. The parentheses forbid this, since h(x) is innermost, but the written order f, g, h tempts the eye.
The second classic error is adding slopes instead of multiplying them. Slopes multiply through a chain: a stage that doubles followed by a stage that triples gives an overall factor of six, not five.
How to Interpret Your Result Correctly
The composed formula is the headline: it is the entire chain reduced to one line. The table below it is the proof, showing each stage's output at each x so nothing is hidden.
Use the intermediate columns h(x) and g(h(x)) to verify by hand. If those match your own arithmetic, the composed values are guaranteed correct, because they are built from the same steps.
Where Triple Composition Shows Up
Graphics software chains transformations this way: scale, then rotate, then translate a point, with each step a function of the previous result. Currency conversion through an intermediate currency is another chain of three.
In machine learning, data flows through layer after layer of simple functions. Each layer is easy alone; the composition is where the intelligence lives.
Worked Example: A Simple Chain
Let f(x) = 2x + 1, g(x) = x + 3, and h(x) = 3x − 2. Evaluate at x = 1.
First: h(1) = 3(1) − 2 = 1. Then: g(1) = 1 + 3 = 4. Then: f(4) = 2(4) + 1 = 9.
The composed formula is (2·1·3)x + (2·1·(−2) + 2·3 + 1) = 6x + 3, and 6(1) + 3 = 9. The formula and the step-by-step walk agree.
Worked Example: Fractional Slopes
Let f(x) = 0.5x + 2, g(x) = 4x − 1, and h(x) = x + 0.5. Evaluate at x = 2.
First: h(2) = 2.5. Then: g(2.5) = 4(2.5) − 1 = 9. Then: f(9) = 0.5(9) + 2 = 6.5.
The composed formula is 2x + 2.5, and 2(2) + 2.5 = 6.5. Fractions flow through the chain without any special handling.
Worked Example: Negative Coefficients
Let f(x) = −x + 4, g(x) = 2x − 3, and h(x) = −2x + 1. Evaluate at x = 0.
First: h(0) = 1. Then: g(1) = 2(1) − 3 = −1. Then: f(−1) = −(−1) + 4 = 5.
The composed formula is 4x + 5, and at x = 0 that gives 5. Negative slopes flip direction mid-chain, but the formula absorbs all of it.
Worked Example: Both Orders Compared
Let f(x) = 2x, g(x) = x + 5, and h(x) = 3x. Evaluate at x = 1.
Forward: h(1) = 3, g(3) = 8, f(8) = 16. The forward formula is 6x + 10, giving 16.
Reverse: f(1) = 2, g(2) = 7, h(7) = 21. The reverse formula is 6x + 15, giving 21.
Same slope of 6 in both, but the intercepts 10 and 15 tell the two orders apart. This is order dependence made visible.
Frequently Asked Questions
1. What does (f ∘ g ∘ h)(x) mean?
It means apply h to x first, then g to the result, then f to that result. In expanded form, (f ∘ g ∘ h)(x) = f(g(h(x))). Evaluation always starts with the innermost, rightmost function.
2. Why do I read the chain from right to left?
Because the rightmost function sits closest to x inside the nested parentheses. Parentheses dictate the order: the deepest nesting computes first, which happens to be the function written last.
3. Is the composition of three lines always a line?
Yes. Substituting one line into another multiplies the slopes and combines the intercepts, and doing it twice still leaves you with the form Ax + B. The calculator shows you that final A and B directly.
4. How is this different from composing just two functions?
It is the same idea with one more stage. Where (f ∘ g)(x) = f(g(x)), the triple version is f(g(h(x))). Everything you know about two-function composition applies, just with an extra inside-out step.
5. Do the forward and reverse chains share anything?
They share the overall slope, which is the product a₁a₂a₃ in both orders. They differ in the intercept, because each intercept gets scaled by the slopes of the stages applied after it.
6. What happens if one function is constant?
A zero slope anywhere turns that stage into a constant, and every later stage then operates on that same constant. The final composition becomes a flat horizontal line, which the table reveals as an unchanging column.
7. Can I use this for functions that are not lines?
This calculator is built for linear functions only, since those collapse into a clean composed formula. For quadratics or exponentials in a two-function chain, use our Composition Function Calculator instead.
8. Why does the table show intermediate columns?
The h(x) and g(h(x)) columns let you verify each stage by hand. If the intermediates match your own arithmetic, the final composed values must be right, because they are computed from those same intermediates.
9. How many x values can I evaluate at once?
Up to twelve, separated by commas. That is enough to sketch the composed line's behavior or check a full homework set without retyping the functions each time.
10. What if I enter the x values in the wrong format?
Separate values with commas, like 0, 1, 2, 5. Spaces are fine and empty entries are ignored. Anything that is not a number is skipped, but you need at least one valid value to get results.
11. Does composition order matter if all slopes are 1?
With all slopes equal to 1, the chain just adds up the intercepts, and addition commutes, so forward and reverse give the same answer. Order starts to matter as soon as any slope differs from 1.
12. Where is triple composition used in real life?
Computer graphics chains scale, rotate, and translate operations on every point. Currency conversion through an intermediate currency is a three-stage chain, and neural networks stack simple functions into deep compositions.
13. Can composition be undone?
Sometimes. If each function has an inverse, applying the inverses in reverse order undoes the chain. With lines this is always possible unless a slope is zero, which destroys information permanently.
14. Why multiply slopes instead of adding them?
Because each stage scales the output of the previous one. A stage that doubles followed by a stage that triples multiplies every input by six overall. Substitution, not addition, is what composition does.
15. How do I check the composed formula by hand?
Substitute step by step: put h(x) into g to get a new line, then put that line into f. Compare your final Ax + B with the calculator's displayed formula. Then test both at x = 0 and x = 1 for a quick numerical confirmation.