Writing the Function for a Sine or Cosine Graph
To determine the equation, we need to identify each value in the general form of a sinusoidal function.
[latex]y=A\sin\left(Bx-C\right)+D[/latex]
[latex]y=A\cos\left(Bx-C\right)+D[/latex]
The graph could represent either a sine or a cosine function that is shifted and/or reflected. When [latex]x=0[/latex], the graph has an extreme point, [latex](0,0)[/latex]. Since the cosine function has an extreme point for [latex]x=0[/latex], let us write our equation in terms of a cosine function.
Let’s start with the midline. We can see that the graph rises and falls an equal distance above and below [latex]y=0.5[/latex]. This value, which is the midline, is D in the equation, so D=0.5.
The greatest distance above and below the midline is the amplitude. The maxima are 0.5 units above the midline and the minima are 0.5 units below the midline. So |A|=0.5. Another way we could have determined the amplitude is by recognizing that the difference between the height of local maxima and minima is 1, so |A|=[latex]\frac{1}{2}[/latex]. Also, the graph is reflected about the x-axis so that A=0.5.
The graph is not horizontally stretched or compressed, so B=0 and the graph is not shifted horizontally, so C=0.
Putting this all together,
[latex]g(x)=0.5\cos\left(x\right)+0.5[/latex]
Determine the formula for the sine function in the graph.
![A graph of sin(x)+2. Period of 2pi, amplitude of 1, and range of [1, 3].](https://s3-us-west-2.amazonaws.com/courses-images/wp-content/uploads/sites/3675/2018/09/27003945/CNX_Precalc_Figure_06_01_016.jpg)
[latex]f(x)=\sin(x)+2[/latex]
[latex]B=\frac{2π}{P}=\frac{2π}{6}=\frac{π}{3}[/latex]
So far, our equation is either [latex]y=3\sin(\frac{\pi}{3}x−C)−2[/latex] or [latex]y=3\cos(\frac{\pi}{3}x−C)−2[/latex]. For the shape and shift, we have more than one option. We could write this as any one of the following:
- a cosine shifted to the right
- a negative cosine shifted to the left
- a sine shifted to the left
- a negative sine shifted to the right
While any of these would be correct, the cosine shifts are easier to work with than the sine shifts in this case because they involve integer values. So our function becomes
[latex]y=3\cos(\frac{π}{3}x−\frac{π}{3})−2[/latex] or [latex]y=−3\cos(\frac{π}{3}x+\frac{2π}{3})−2[/latex]
Again, these functions are equivalent, so both yield the same graph.
![A graph of 4sin((pi/5)x-pi/5)+4. Graph has period of 10, amplitude of 4, range of [0,8].](https://s3-us-west-2.amazonaws.com/courses-images/wp-content/uploads/sites/3675/2018/09/27003949/CNX_Precalc_Figure_06_01_018n.jpg)
two possibilities are: [latex]y=4\sin(\frac{π}{5}x−\frac{π}{5})+4[/latex] or [latex]y=−4sin(\frac{π}{5}x+4\frac{π}{5})+4[/latex]