Function Composition Calculator

Enter two linear functions and a point x to compute f(g(x)).

How it is calculated

The tool composes two straight-line functions, f(x) = a1x + b1 and g(x) = a2x + b2. Composition applies g first, then f: g(x) = a2x + b2 and (f∘g)(x) = a1 × g(x) + b1. Expanded, the composite is again a line with slope a1a2 and intercept a1b2 + b1. All five fields are required and any real number is accepted, including zero and negatives, as long as every result stays below about 9 × 1015 in size; larger values show no result. Results are rounded to two decimals. The order matters: (g∘f)(x) is a different function, with intercept a2b1 + b2, so swap the two functions to get it. If a1 is 0, f is constant and the composite has slope 0.

Worked example

Let f(x) = 2x + 3, g(x) = -1x + 4 and x = 5. First g: -1 × 5 + 4 = -1, so g(5) is -1.00. Then f: 2 × (-1) + 3 = 1. Composite slope: 2 × (-1) = -2. Composite intercept: 2 × 4 + 3 = 11. Result: 1.00 for (f∘g)(5), with composite slope -2.00 and intercept 11.00. Check: -2 × 5 + 11 = 1.

Try this example →

Common mistakes

  • Applying the functions in the wrong order. (f∘g)(x) puts x into g first and the result into f; swapping them gives intercept 1 instead of 11 for this example.
  • Entering the intercept with the wrong sign. For g(x) = 4 − x, the slope is -1 and the intercept is 4, not the other way round.
  • Leaving a field blank when the function has no x term. A constant function such as f(x) = 7 needs a1 = 0 and b1 = 7; with a blank field there is no result.
  • Multiplying the two functions instead of composing them. f(x) × g(x) is a quadratic, whereas composition gives a straight line with slope a1a2.
  • Expecting nonlinear functions to work. Only functions of the form ax + b are supported, so f(x) = x² cannot be entered.

About this calculator

Function composition (f∘g)(x) means feeding the output of one function directly into another: first compute g(x), then plug that result into f. For two linear functions f(x) = a₁x + b₁ and g(x) = a₂x + b₂, the composite works out to (f∘g)(x) = a₁(a₂x + b₂) + b₁ = (a₁a₂)x + (a₁b₂ + b₁), which is itself a linear function with slope a₁a₂ and intercept a₁b₂ + b₁.

Composition is a core idea in algebra and precalculus courses because it generalizes far beyond lines — the chain rule in calculus is essentially the derivative version of composing functions, and chaining together simple transformations (like scaling, then shifting, then scaling again) to build a more complex one is a technique used throughout math, computer graphics, and signal processing.

Was this helpful?

You can pick up to 3 reactions.

Be the first to comment.

Popular calculators

All Calculators