Transformations, Composition, and Inverses

Learn how functions move, combine, compose, and reverse.

Learning objectives

After this lesson you should be able to:

  • describe vertical and horizontal shifts, stretches, compressions, and reflections;
  • interpret parameters in a*f(b*(x-h)) + k;
  • compute sums, differences, products, quotients, and compositions of functions;
  • track domain restrictions under operations and composition;
  • explain what an inverse function does and when it exists.

Motivation

Once you understand a basic function family, transformations let you build many related functions without starting from scratch.

For example, y = x^2 is a base shape. The function:

y = 2(x - 3)^2 + 1

is still a quadratic, but it has been shifted, stretched, and moved. Being able to read this immediately is essential for graphing, modeling, optimization, and calculus.

The transformation template

A useful general template is:

g(x) = a*f(b*(x - h)) + k

where:

  • a vertically stretches/compresses and may reflect across the x-axis;
  • b horizontally compresses/stretches and may reflect across the y-axis;
  • h shifts the graph horizontally;
  • k shifts the graph vertically.
WarningHorizontal transformations feel backward

The expression f(x - 3) shifts the graph right by 3, not left. The input must be 3 units larger before the base function sees the same internal value.

Visual example

Compare f(x)=x^2 with g(x)=2(x-3)^2+1.

\(\displaystyle 2 x^{2} - 12 x + 19\)

The base vertex (0, 0) becomes (3, 1), and the graph becomes narrower because of the vertical stretch by 2.

Function arithmetic

If two functions have compatible domains, we can combine them:

(f + g)(x) = f(x) + g(x)
(f - g)(x) = f(x) - g(x)
(f*g)(x) = f(x)g(x)
(f/g)(x) = f(x)/g(x), where g(x) != 0

Example:

f(x) = x^2
g(x) = 3x - 1

Then:

(f + g)(x) = x^2 + 3x - 1
(f*g)(x) = x^2(3x - 1) = 3x^3 - x^2

For a quotient, the denominator creates restrictions.

Composition

Composition means feeding the output of one function into another.

(f ∘ g)(x) = f(g(x))

If:

f(x) = x^2
g(x) = x + 1

then:

(f ∘ g)(x) = f(g(x)) = f(x + 1) = (x + 1)^2

But:

(g ∘ f)(x) = g(f(x)) = g(x^2) = x^2 + 1

Composition usually does not commute:

f(g(x)) != g(f(x))

Domain under composition

The domain of f(g(x)) must satisfy two requirements:

  1. x must be allowed in g.
  2. g(x) must be allowed as an input to f.

Example:

f(x) = sqrt(x)
g(x) = x - 2

Then:

f(g(x)) = sqrt(x - 2)

So we require:

x - 2 >= 0

Therefore:

x >= 2

Inverse functions

An inverse function reverses the effect of another function.

If:

f(x) = 2x + 3

then:

f^{-1}(x) = (x - 3)/2

because:

f^{-1}(f(x)) = x

and:

f(f^{-1}(x)) = x

One-to-one functions

A function has an inverse function only when it is one-to-one: each output comes from exactly one input.

The horizontal line test checks this on a graph. If any horizontal line hits the graph more than once, the function is not one-to-one.

Example:

  • f(x)=2x+3 is one-to-one.
  • f(x)=x^2 over all real numbers is not one-to-one because f(2)=4 and f(-2)=4.

However, f(x)=x^2 restricted to x >= 0 does have an inverse:

f^{-1}(x) = sqrt(x)

Worked examples

Example 1: describe a transformation

Describe:

g(x) = -3(x + 2)^2 - 5

From f(x)=x^2:

  • x + 2 = x - (-2), so shift left 2;
  • multiply by -3, so reflect across the x-axis and vertically stretch by 3;
  • subtract 5, so shift down 5.

Example 2: compose functions

Let:

f(x) = 1/(x - 1)
g(x) = x^2

Then:

f(g(x)) = 1/(x^2 - 1)

Domain restriction:

x^2 - 1 != 0

so:

x != -1 and x != 1

Example 3: find an inverse

Find the inverse of:

f(x) = 5x - 4

Write:

y = 5x - 4

Swap x and y:

x = 5y - 4

Solve for y:

x + 4 = 5y
y = (x + 4)/5

So:

f^{-1}(x) = (x + 4)/5

Common mistakes

Reversing the horizontal shift

f(x - 4) shifts right by 4; f(x + 4) shifts left by 4.

Assuming composition commutes

Usually f(g(x)) and g(f(x)) are different functions.

Forgetting quotient restrictions

For (f/g)(x), any input where g(x)=0 must be excluded.

Finding an inverse without checking one-to-one behavior

Some functions need a restricted domain before an inverse function exists.

Practice

  1. Describe the transformation from y=x^2 to y=(x-5)^2+2.
  2. Describe the transformation from y=sqrt(x) to y=-sqrt(x+1).
  3. If f(x)=x^2 and g(x)=x+3, compute f(g(x)).
  4. If f(x)=x^2 and g(x)=x+3, compute g(f(x)).
  5. Find the domain of 1/(x^2 - 4).
  6. Find the inverse of f(x)=3x+7.
  7. Explain why f(x)=x^2 is not one-to-one over all real numbers.
  8. Restrict the domain of f(x)=x^2 so that it has inverse sqrt(x).
  9. Let f(x)=sqrt(x) and g(x)=x-6. Find the domain of f(g(x)).
  10. Challenge: create a function whose inverse is itself.

Solutions

Shift right 5 and up 2.

x+1 shifts left 1. The negative sign reflects the graph across the x-axis.

f(g(x)) = f(x+3) = (x+3)^2.

g(f(x)) = g(x^2) = x^2 + 3.

The denominator cannot be zero. x^2 - 4 = (x-2)(x+2), so exclude x=2 and x=-2.

Let y=3x+7. Swap variables: x=3y+7. Solve: y=(x-7)/3. So f^{-1}(x)=(x-7)/3.

f(2)=4 and f(-2)=4, so two different inputs produce the same output.

Restrict to x >= 0. Then each output has exactly one input, and the inverse is sqrt(x).

f(g(x)) = sqrt(x - 6), so require x - 6 >= 0. The domain is x >= 6.

One example is f(x)=x. Another is f(x)=1/x on the domain x != 0, because applying it twice returns the original input.

Why this matters later

  • Calculus: the chain rule is about composition.
  • Probability/statistics: transformations of variables change distributions.
  • Optimization: parameters shift and stretch objective functions.
  • Linear algebra: inverse functions generalize to inverse transformations.

Subtopic guided practice and checkpoints

Transformations and composition are easier when you track the order of actions. Always guess the effect before doing algebra.

Lab 1: read a transformed function

Guess first. Compared with f(x) = x^2, does g(x) = 3(x - 2)^2 - 5 move left or right?

Guided exercise.

Use the template a f(x - h) + k.

a = 3        vertical stretch by 3
h = 2        shift right 2
k = -5       shift down 5

The vertex moves from (0, 0) to (2, -5).

Checkpoint. Describe the transformation from f(x) = |x| to g(x) = -2|x + 4| + 1.

Lab 2: function arithmetic

Guess first. If f(x) = x + 1 and g(x) = x^2, is (f + g)(2) equal to f(g(2))?

Guided exercise.

(f + g)(2) = f(2) + g(2) = 3 + 4 = 7
f(g(2)) = f(4) = 5

Function addition and composition are different operations.

Checkpoint. For f(x) = 2x - 1 and g(x) = x + 5, compute (f - g)(3) and f(g(3)).

Lab 3: composition step by step

Guess first. For f(x) = x^2 + 1 and g(x) = 3x, will f(g(x)) equal g(f(x))?

Guided exercise.

f(g(x)) = f(3x) = (3x)^2 + 1 = 9x^2 + 1
g(f(x)) = g(x^2 + 1) = 3(x^2 + 1) = 3x^2 + 3

They are not equal, so composition usually does not commute.

Checkpoint. Let f(x) = x - 4 and g(x) = x^2. Find f(g(x)) and g(f(x)).

Lab 4: find an inverse

Guess first. If f(x) = 2x - 7, should the inverse undo subtracting 7 before or after undoing multiplying by 2?

Guided exercise.

y = 2x - 7
x = 2y - 7              swap x and y
x + 7 = 2y              add 7
y = (x + 7)/2           divide by 2

So f^{-1}(x) = (x + 7)/2.

Checkpoint. Find the inverse of f(x) = 5x + 3. Then check by computing f(f^{-1}(x)).

Guessing game checkpoint

Before moving to the Python/SymPy appendix, practice the core moves from this lesson. This short quiz may show an expression, graph, equation, solution set, or description and ask you to choose the matching mathematical object.

Using this lesson with edumath and SymPy

Use transformed_expression to generate transformed functions and then compare the base and transformed graphs.

from edumath.algebra import transformation_scene, transformed_expression

transformed_expression("x**2", vertical_scale=2, horizontal_shift=3, vertical_shift=1)

\(\displaystyle 2 x^{2} - 12 x + 19\)

scene = transformation_scene("x**2", vertical_scale=2, horizontal_shift=3, vertical_shift=1)
fig, ax = scene.render()

Further reading