Learning Center / Algebra

Functions: how to graph a function, domain, range and f(g(x))

Function notation, how to graph a function from its formula, how to find its domain and range, and how composite functions such as f(g(x)) work.

3 min readUpdated 2 November 2026By Sumzo team (AI-assisted)Reviewed by Sumzo AI (owner-delegated review)

A function is a rule that gives exactly one output for each input. We write it as f(x)f(x), read “f of x”: if f(x)=2x+3f(x) = 2x + 3, then f(4)=2(4)+3=11f(4) = 2(4) + 3 = 11. To graph a function, plot the points (x,f(x))(x, f(x)) — this lesson shows how to graph a function from its formula, how to move a graph you already know with transformations, and how to find the domain and range.

If plotting points from a table, drawing straight lines or sketching a basic parabola is new to you, start with the lesson on how to graph an equation; this lesson builds on it.

Function notation

Worked example

Easy: evaluate a function

If f(x)=x2−3x+2f(x) = x^2 - 3x + 2, find f(5)f(5).

Show the working
  1. Replace every xx with 5.
    f(5)=52−3(5)+2f(5) = 5^2 - 3(5) + 2
  2. Work it out.
    25−15+2=1225 - 15 + 2 = 12

Answer: f(5)=12f(5) = 12

Checked by Sumzo’s math engine

How to graph a function

  1. Find the domain: which xx-values are allowed?
  2. Find the key points: the y-intercept f(0)f(0), the x-intercepts where f(x)=0f(x) = 0, and any turning point.
  3. Make a table of values for a few more xx-values.
  4. Plot the points and draw a smooth curve; watch for values of xx that are not allowed.

Worked example

Medium: graph f(x)=x2−2x−3f(x) = x^2 - 2x - 3

Find the key points of f(x)=x2−2x−3f(x) = x^2 - 2x - 3 and describe its graph.

Show the working
  1. y-intercept: f(0)=−3f(0) = -3.
  2. x-intercepts: factor and set to zero.
    (x−3)(x+1)=0⇒x=3 or x=−1(x - 3)(x + 1) = 0 \Rightarrow x = 3 \text{ or } x = -1
  3. Turning point (vertex): halfway between the roots, x=1x = 1, where f(1)=1−2−3=−4f(1) = 1 - 2 - 3 = -4.
    (1,−4)(1, -4)
  4. The x2x^2 term is positive, so the parabola opens upwards.

Answer: A parabola through (−1,0)(-1, 0), (3,0)(3, 0) and (0,−3)(0, -3) with its lowest point at (1,−4)(1, -4).

Checked by Sumzo’s math engine

Graphing a function with transformations

Often you don’t need a table at all: if you know the graph of y=f(x)y = f(x), small changes to the formula move it in predictable ways.

  • f(x)+kf(x) + k moves the graph up by kk (down if kk is negative).
  • f(x−h)f(x - h) moves it right by hh — note the minus sign: f(x+2)f(x + 2) moves left by 2.
  • −f(x)-f(x) reflects it in the x-axis; f(−x)f(-x) reflects it in the y-axis.
  • a⋅f(x)a \cdot f(x) stretches it vertically by a factor aa.

Worked example

Medium: move the graph of x2x^2

Sketch g(x)=(x−3)2−4g(x) = (x - 3)^2 - 4 using the graph of y=x2y = x^2.

Show the working
  1. Start from y=x2y = x^2, whose vertex is (0,0)(0, 0).
  2. Replacing xx with x−3x - 3 moves it 3 to the right; subtracting 4 moves it 4 down.
    vertex (3,−4)\text{vertex } (3, -4)
  3. Find where it crosses the x-axis.
    (x−3)2=4⇒x−3=±2⇒x=5 or x=1(x - 3)^2 = 4 \Rightarrow x - 3 = \pm 2 \Rightarrow x = 5 \text{ or } x = 1
  4. y-intercept: g(0)=9−4=5g(0) = 9 - 4 = 5.

Answer: The U shape of y=x2y = x^2 with its vertex moved to (3,−4)(3, -4), crossing the x-axis at 1 and 5 and the y-axis at 5.

Checked by Sumzo’s math engine

Domain and range

The domain is the set of inputs a function accepts; the range is the set of outputs it produces. Two things limit the domain of the functions you meet most: you can’t divide by zero, and you can’t take the square root of a negative number.

  • f(x)=x2−2x−3f(x) = x^2 - 2x - 3: domain all real numbers; range y≥−4y \geq -4 (the vertex is the lowest point).
  • g(x)=1x−2g(x) = \frac{1}{x - 2}: domain all real numbers except x=2x = 2.
  • h(x)=x−1h(x) = \sqrt{x - 1}: domain x≥1x \geq 1; range y≥0y \geq 0.

Composite functions

A composite function applies one function and then another. f(g(x))f(g(x)) means “do gg first, then ff”: replace every xx in ff with the whole of g(x)g(x).

Worked example

Hard: f(g(x))f(g(x)) and g(f(x))g(f(x))

With f(x)=2x+3f(x) = 2x + 3 and g(x)=x2g(x) = x^2, find f(g(x))f(g(x)), g(f(x))g(f(x)) and f(g(2))f(g(2)).

Show the working
  1. Put g(x)=x2g(x) = x^2 into ff.
    f(g(x))=2x2+3f(g(x)) = 2x^2 + 3
  2. Put f(x)=2x+3f(x) = 2x + 3 into gg.
    g(f(x))=(2x+3)2=4x2+12x+9g(f(x)) = (2x + 3)^2 = 4x^2 + 12x + 9
  3. Inside out: g(2)=4g(2) = 4, then f(4)=11f(4) = 11.
    f(g(2))=11f(g(2)) = 11

Answer: f(g(x))=2x2+3f(g(x)) = 2x^2 + 3, g(f(x))=4x2+12x+9g(f(x)) = 4x^2 + 12x + 9 and f(g(2))=11f(g(2)) = 11 — the order matters.

Checked by Sumzo’s math engine

Common mistakes

  • Reading f(x)f(x) as f×xf \times x — it means “f evaluated at x”.
  • Composing in the wrong order: f(g(x))f(g(x)) applies gg first.
  • Forgetting brackets when substituting: f(−3)f(-3) for f(x)=x2f(x) = x^2 is (−3)2=9(-3)^2 = 9, not −9-9.
  • Leaving out excluded values from the domain, such as x=2x = 2 for 1x−2\frac{1}{x - 2}.

Frequently asked questions

How do you graph a function?

Find the domain, then the intercepts and any turning point, make a table of values, plot the points and join them smoothly. A graphing calculator is a quick way to check the shape.

What is the difference between domain and range?

The domain is every input xx the function accepts; the range is every output f(x)f(x) it can give.

Is f(g(x)) the same as g(f(x))?

Usually not. With f(x)=2x+3f(x) = 2x + 3 and g(x)=x2g(x) = x^2, f(g(x))=2x2+3f(g(x)) = 2x^2 + 3 but g(f(x))=4x2+12x+9g(f(x)) = 4x^2 + 12x + 9.

Stuck on a problem? Ask Sumzo AI