Skip to main content

Function Composition Calculator

Evaluate f(x), g(x), f(g(x)), and g(f(x)) for two functions at a given x, with a step-by-step substitution for each composition.

Input

A function of x, written in standard math notation (^ for powers, sqrt(), sin(), etc.).

A second function of x, in the same notation.

The value of x to evaluate both functions and their compositions at.

Output

Step-by-Step Derivation
Was this helpful?

More ways to use this tool

REST API

curl -X POST https://api.iotools.cloud/v1/tool/function-composition-calculator \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "functionF": "x + 3",
    "functionG": "x - 3",
    "x": "5"
  }'

Swap in your own key from your account. The tool's fields are the body — no wrapper.

Ask an AI agent

Use the IOTools `function-composition-calculator` tool (Function Composition Calculator) on this input:

YOUR_INPUT_HERE

Paste this at any agent connected to the IOTools MCP server, then add your input.

Embed widget

<iframe
  src="https://iotools.cloud/embed/function-composition-calculator/"
  width="100%" height="520" frameborder="0" scrolling="no" loading="lazy"
  title="Function Composition Calculator — iotools.cloud"
  sandbox="allow-scripts allow-forms allow-same-origin allow-downloads allow-popups allow-popups-to-escape-sandbox"
  allow="clipboard-write"
  style="width:100%;border:1px solid #e5e7eb;border-radius:12px;overflow:hidden"></iframe>
<script src="https://iotools.cloud/embed.js" async></script>

Drop this into your own page — free, no key required, just a link back.

Cost per API/MCP callFrom 5 credits
Need more credits?View pricing

Also available with

Guides

The Function Composition Calculator evaluates two functions, f(x) and g(x), at a given value of x, then combines them into the composite functions f(g(x)) and g(f(x)) — showing every substitution along the way.

It's built for algebra and precalculus students checking composition homework, and anyone who needs to verify how two functions combine without working through the algebra by hand.

How to use it

  1. Enter f(x) and g(x) in terms of x — standard math notation works: ^ for powers, plus sqrt(), sin(), cos(), log(), and the other functions supported by mathjs's expression parser.
  2. Enter the x value to evaluate both functions and their compositions at.
  3. Read f(x), g(x), f(g(x)), and g(f(x)) for the four evaluated results.
  4. Step-by-Step Derivation shows the substitution behind each composition.

Results update automatically as you type. For example, f(x) = x + 3, g(x) = x - 3, at x = 5 gives f(x) = 8, g(x) = 2, f(g(x)) = 5, and g(f(x)) = 5 — since these two functions are inverses of each other, both compositions return the original x.

What is function composition?

Composing two functions means feeding the output of one into the other. f(g(x)) means "first apply g to x, then apply f to that result" — computed as f(g(x)), not f(x) · g(x). g(f(x)) reverses the order: apply f first, then g. The two compositions are generally not equal — composition isn't commutative, which is exactly why this calculator computes both.

Why do f(g(x)) and g(f(x)) usually differ?

Because the order of substitution changes which expression gets plugged into which. For f(x) = 2x + 1 and g(x) = x^2, f(g(x)) = 2x^2 + 1 while g(f(x)) = (2x + 1)^2 — entirely different expressions that only coincide at specific x values, if at all. Checking both, as this calculator does, is the fastest way to confirm which composition a problem is actually asking for.

What functions can I enter?

Anything mathjs's expression evaluator understands: polynomials (x^3 - 2x + 1), trigonometric functions (sin(x), cos(x), tan(x)), roots and logarithms (sqrt(x), log(x)), and combinations of these. Angles in trig functions are in radians by default — write pi for π. If a composition isn't defined at your chosen x (for example, f(x) = sqrt(x) composed with a g(x) that goes negative), the calculator flags it rather than showing an invalid result.

To check whether a function is symmetric rather than compose two of them, see the Function Odd/Even/Neither Checker. To evaluate arbitrary math expressions directly, see the Math Evaluator.

Privacy

This calculator runs entirely in your browser. Your functions and x value are never uploaded, logged, or stored — the computation happens locally on your device.

composite functionfunction compositionf of g of xnested functionsalgebracalculusf(x)g(x)

Love the tools? Lose the ads.

One payment clears every ad from your account, for good. No subscription, no tracking.