# Transformation of Functions

By applying certain transformations to the graph of a given function we can obtain new functions. This will give the ability to sketch the graphs of many functions quickly based on the old one. It will also be easier to write equations for given graphs.

**Translations**

Suppose `a>0`. To obtain the graph of

- `y=f(x)+a`, shift the graph of `f(x)` `a` units upward.
- `y=f(x)-a`, shift the graph of `f(x)` `a` units downward.
- `y=f(x-a)`, shift the graph of `f(x)` `a` units to the right.
- `y=f(x+a)`, shift the graph of `f(x)` `a` units to the left.

**Example 1.** Draw following graphs of functions: `y=sqrt(x)`, `y=sqrt(x)+5`, `y=sqrt(x)-3`, `y=sqrt(x-3)`, `y=sqrt(x+2)`.

We first draw `y=sqrt(x)`, then we move it 5 units upward to obtain `y=sqrt(x)+5`.

Again we move `y=sqrt(x)` 3 units downward to obtain `y=sqrt(x)-3`.

`y=sqrt(x-3)` is obtained from `y=sqrt(x)` by moving it 3 units to the right.

`y=sqrt(x+2)` is obtained from `y=sqrt(x)` by moving it 2 units to the left.

**Stretching/Compressing and Reflection**

Suppose `b>1`. To obtain the graph of

- `y =bf(x)`, stretch the graph of `y=f(x)` vertically by a factor of `b`.
- `y=1/b f(x)`, compress the graph of `y=f(x)` vertically by a factor of `b`.
- `y=f(bx)`, compress the graph of `y=f(x)` horizontally by a factor of `b`.
- `y=f(x/b)`, stretch the graph of `y=f(x)` horizontally by a factor of `b`.
- `y =-f(x)`, reflect the graph of `y=f(x)` about the x-axis.
- `y =f(-x)`, reflect the graph of `y=f(x)` about the y-axis.

**Example 2.** Draw following graphs of trigonometric functions: `y=sin(x)`, `y=2sin(x)`, `y=1/4 sin(x)`.

We first draw `y=sin(x)`.

Then stretch it vertically by a factor of 2 to obtain `y=2sin(x)`. Again we compress `y=sin(x)` vertically by a factor of 4 to obtain `y=1/4 sin(x)`.

Note, that we have drawn graphs only on interval `[0,2pi]` because sine is periodic function with period `2pi`.

**Example 3.** Draw following graphs of trigonometric functions: `y=sin(x)`, `y=sin(2x)`, `y=sin(1/3 x)`.

We first draw `y=sin(x)`.

Then compress it horizontally by a factor of 2 to obtain `y=sin(2x)`.

Again we stretch `y=sin(x)` horizontally by a factor of 3 to obtain `y=sin(1/3 x)`.

**Example 4.** Draw following graphs of functions: `y=sqrt(x)`,

`y=-sqrt(x)`, `y=sqrt(-x)`.

We first draw `y=sqrt(x)` then reflect it about x-axis to obtain `y=-sqrt(x)`.

Again we reflect `y=sqrt(x)` about y-axis to obtain `y=sqrt(-x)`.

Note that domain of `y=sqrt(x)` and `y=-sqrt(x)` is `x>=0`, while domain of `y=-sqrt(x)` is `x<=0`.

**Example 5.** How can we obtain graph of the function `y=1-2sqrt(x)` from graph of function `y=sqrt(x)`?

We first draw graph of the function `y=sqrt(x)`.

Then we stretch it vertically to obtain `y=2sqrt(x)`.

Then we reflect result about x-axis to obtain `y=-2sqrt(x)`.

Finally, we obtain `y=1-2sqrt(x)` by shifting `y=-2sqrt(x)` 1 unit upward.

Alternatively we could reflect `y=sqrt(x)` about x-axis, then stretch result vertically by a factor of 2 and then shift `y=-2sqrt(x)` 1 unit upward.

**Example 6.** Draw graph of the function `y=2x^2+8x+5`.

First we complete a square: `y=2x^2+8x+8-3=`

`=2(x^2+4x+4)-3=2(x+2)^2-3`.

First of all, let's draw graph of the function `y=x^2`.

Then shift it 2 units to the left.

Then stretch result vertically by a factor of 2.

And finally shift it 3 units downward.

Finalt graph is shown on the picture.