Function Squashing

There are cool things you can do by just messing around with constants in equations. As an example, I'll explore the things you can do with periodic functions like sine and cosine. I'll explore translation and vertical and horizontal scaling.

First, you should review periodic functions.

Let's start with a graph of good old f(x) = sin(x) and go from there.

Outside of the function

Manipulations we do outside of the function manipulate what we've already got from the function, so simple constants will move the function around or scale it in terms of y (the range).

Multiplying the function by a constant -

The first thing we will do is look at f(x) = A*sin(x). What this means is, that for each point on the original graph, the new point is multiplied by the constant c and thus is pulled into or pushed away from the X-axis, depending on whether A is less than or greater than 1. If A=1, then our formula hasn't changed and we have the same graph. One of the tangible results of this is that, if the highest point of some function was c, then the highest point of the new function is A*c. sin(x) has an amplitude of 1, so 3*sin(x) has an amplitude of 3 and sin(x)/2 has an amplitude of 1/2.

Adding some number to the function -

This is fairly straight forward. If we add some number to a function, it will move vertically by that number. That is, if f(x) = g(x)+c, then for each x in the domain of g(x), f(x) will be offset vertically c units from g(x).

Inside of the function

Manipulations of what we give to a function are a little more complicated. What we're doing when we do this is manipulating where the function is generating from. Thus, we can move the function around in terms of x (the domain).

Multiplying the variable by a constant -

This is like stretching or shrinking the domain from which we're generating the function. If f(x) = g(B*x), than for each unit we cover in f(x), we will be covering B units in g(x). So, if B=2, then what g(x) covers in two units, f(x) will cover in one, making a function that looks shrunk in x. If B=1/3, then what f(x) covers in one units, g(x) will cover in one third. Or, what f(x) covers in three units, g(x) will cover in one. In our case sin(x) has a period of 2. f(x)=sin(2x) covers that in half the distance and has a period of 2/2=. In addition, f(x)=sin(x/8) would have a period of 8*2=16.

In general, if g(x) has a period of p and f(x)=g(B*x), then f(x) has a period of p/B.
For sin(x), this means that sin(cx) has a period of 2/c.

Adding some number to the variable -

By adding some constant C to a variable we are basically saying to the function "get the value for this point from where you would normally get the value C units away." In effect, if f(x)=g(x+C) this means a shifting of the function left or right. If C is negative, it means a shift to the right. If C is positive it means a shift to the left.

Summary:

If f(x)=g(x+C)+D, then the function is translated up D units up and C units to the left.
If g(x) is a periodic function and f(x)=A*g(B*x+C)+D, then the new period = (Period of g(x))/B, and the new amplitude = A*(Amplitude of g(x)).

If we want to find out where one cycle of f(x) is, we try to see where the cycle starting at 0 in g(x) takes place in f(x), using only those variables needed for the domain:

```f(x) = g(B*x+C)
B*xStart+C = 0
xStart = -C/B
```
So we know that the period starting at 0 in g(x) starts at -C/B in f(x). Where does it end? We find out by finding out where one period (p) ends up:
```f(x) = g(B*x+C)
B*xEnd+C = p
xEnd = (p-C)/B
```
Now we know where it starts and ends. And, since we don't know anything about where g(x) is (it could be centered at y=50, who knows?), we can't really tell where it will end up in terms of y (range). If we are looking at sin(x) or cos(x), though, which we know are centered aroung y=0 and have an amplitude of 1, we know that the new curve will be centered around the line y=D and have an amplitude of A.
-David