Education

Function Composition Calculator

Find f(g(x)), g(f(x)), and optional numerical values while seeing why the order of function composition matters.

function-composition-calculator
Enter f(x) and g(x) as quadratic or linear polynomials. Use a = 0 when the function is linear. The calculator finds f(g(x)), g(f(x)), and optional values at a selected x.
f(x)=ax²+bx+c and g(x)=dx²+ex+f
Composite functions
f(g(x))
g(f(x))
At selected x

What function composition means

Function composition means using the output of one function as the input of another function. For f(g(x)), g is the inner function and f is the outer function. OpenStax defines composition in the same input-output way in its composition of functions lesson.

The most important detail is order. f(g(x)) means “put g(x) into f,” while g(f(x)) means “put f(x) into g.” In most cases these produce different expressions and different numerical values.

Worked example

f(x) = 2x + 3\ng(x) = x² - x + 4\n\nf(g(x)) = 2(x² - x + 4) + 3\n= 2x² - 2x + 11\n\ng(f(x)) = (2x + 3)² - (2x + 3) + 4\n= 4x² + 10x + 10

The two results are not the same, even though they use the same two functions.

Where students usually get confused

Students often evaluate the functions in the wrong order, especially when the notation includes parentheses inside parentheses. Read f(g(2)) from the inside out: find g(2) first, then put that answer into f. For symbolic composition, replace the variable carefully before expanding.

Common questions

  • f(g(x)) is a composite function. It means you first apply g to x, then apply f to the result. In other words, the entire expression g(x) becomes the input of f. If f(x) = 2x + 1 and g(x) = x², then f(g(x)) = 2(x²) + 1 = 2x² + 1.
  • Usually no. Function composition is order-sensitive. f(g(x)) and g(f(x)) only match in special cases. That is why this calculator shows both forms side by side. It helps students see that changing the order can completely change the expression.
  • Start inside the parentheses. First calculate g(2). Then take that output and plug it into f. For example, if g(2) = 5 and f(x) = 3x - 1, then f(g(2)) = f(5) = 14. The inner function always goes first when you are evaluating a number.
  • If the outer function has a square term and the inner function is also a polynomial, substituting the inner expression into that square can increase the degree. For example, if f(x)=x² and g(x)=x+1, then f(g(x))=(x+1)². If g(x) is quadratic, f(g(x)) can become degree 4.
  • Algebraically, many functions can be composed, but the domain matters. The output of the inner function must be allowed as an input for the outer function. This calculator focuses on polynomial functions, which are defined for all real numbers, so domain restrictions are not an issue in the calculator itself.