Advanced maths

Function composition calculator

Evaluate both orders of function composition, follow the inner and outer steps and compare the functions in an SVG graph.

Your numbers

Use explicit multiplication, such as 2*x. Angles are radians; log and ln are natural logarithms.
Use explicit multiplication, such as 2*x. Angles are radians; log and ln are natural logarithms.

Calculated on your device. Your inputs aren’t sent to us.

Your result

Ready when you are

Enter your inputs and select Calculate.

Report an issue

Try it, understand it

Explore the result

Composition sends an input through one function and then through another. The output of the inner function becomes the input of the outer function. Each stage has to be defined over the real numbers.

Worked example comparison
ExampleOutputWhat to notice
Worked examplef(g(x))11With f(x)=2*x+3 and g(x)=x^2, f(g(2))=11. Reversing the order gives g(f(2))=49.
Reverse the orderg(f(x))49The same functions produce forty-nine, demonstrating that order matters.
A shifted square rootf(g(x))1The inner value is one and its real square root is one.

Check your understanding

Can I compare both orders?

Yes. Switch the composition order; the steps and graph update for the chosen order.

Is x² written as x^2?

Yes. Use ^ for powers and explicit * for multiplication.

Behind the numbers

How this calculation works

Composition sends an input through one function and then through another. The output of the inner function becomes the input of the outer function. Each stage has to be defined over the real numbers.

THE FORMULA(f ∘ g)(x) = f(g(x))

A worked example

With f(x)=2*x+3 and g(x)=x^2, f(g(2))=11. Reversing the order gives g(f(2))=49.

Good to know

Bounded real expressions and floating-point arithmetic. Finite graph samples can miss singularities, isolated features or behavior outside the selected window. Original domain exclusions still apply.

Follow the two function machines in order

Read f(g(x)) from the inside outward. With x=2 and g(x)=x², the first output is four. Use four as the input to f(x)=2x+3 to obtain eleven. Substituting the original input into both functions separately would calculate a different task.

Switch the order control to g(f(x)) to send two through f first. The intermediate value is seven and its square is forty-nine. The steps retain these intermediate values so you can locate a mistake rather than simply compare final answers.

Check the domain of the inner output

An original input can be acceptable to the inner function and still fail at the second stage. If f(x)=sqrt(x) and g(x)=x−3, the composite requires x≥3. Entering x=2 therefore produces a domain error, even though the inner subtraction itself is valid.

The component graphs help show why these exclusions occur. A missing sample breaks a drawn curve; a narrow excluded interval between samples may still escape the picture. Domain analysis belongs in the algebraic explanation as well as the graph.

Composition is different from multiplication

The expression f(g(x)) is function substitution. It is different from f(x)×g(x), just as converting Celsius to Fahrenheit and then applying a billing rule differs from multiplying temperature by cost. Order describes the process being modeled.

Composing a function with itself is also legitimate. For f(x)=x+1, f(f(x)) adds two; for f(x)=x², self-composition produces x⁴. Try these examples before using inverse-function identities, because inverse statements apply only on the appropriate restricted domains.

Use the graph to compare behavior

The graph draws f, g and the selected composition over the same input interval. A large composed output can expand the vertical scale and make the component curves appear flat. Reduce the half-width when examining local behavior.

The derivative calculator with function and tangent graph can then analyze how a composition changes. The chain rule connects these tasks: the derivative of f(g(x)) combines the derivative of the outer function at the inner output with the derivative of the inner function. The function composition calculator establishes those inputs first.

A few questions, answered

Can I compare both orders?

Yes. Switch the composition order; the steps and graph update for the chosen order.

Is x² written as x^2?

Yes. Use ^ for powers and explicit * for multiplication.

Does a domain error mean the parser is broken?

Not necessarily. An inner output may be outside the outer function’s real domain.

Find your calculator

Start typing to explore the library.