Sin, Cos and All That James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University March 9, 2017
Outline 1 Sin, Cos and all that! 2 A New Power Rule 3 Derivatives of Complicated Things
This lecture will go over some basic material about sin and cos functions. We want to take their derivatives and so forth. You should have been exposed to some trigonometry in high school, but even if your past experience with it was yucky and brief, you ll know enough to get started. So we will assume you know about sin and cos and their usual properties. After all, you have seen this before! What we want to do it something new with them find their derivatives. So if you are rusty about these two functions, crack open one of your old texts and refresh your mind. We need to find the derivatives of the sin and cos functions. We will do this indirectly.
Sin, Cos and all that! Look at this figure. Height is sin(x) A O Inner Sector x Width is cos(x) B The circle here has radius 1 and the angle x determines three areas: the area of the inner sector, 1 2 cos2 (x) x, the area of triangle OAB, 1 2 sin(x) and the area of the outer sector, 1 2 x. We see the areas are related by 1 2 cos2 (x) x < 1 2 sin(x) < 1 2 x.
Sin, Cos and all that! From it, we can figure out three important relationships. from high school times, you should know a number of cool things about circles. The one we need is the area of what is called a sector. Draw a circle of radius r in the plane. Measure an angle x counterclockwise from the horizontal axis. Then look at the pie shaped wedge formed in the circle that is bounded above by the radial line, below by the horizontal axis and to the side by a piece of the circle. It is easy to see this in the figure.
Sin, Cos and all that! From it, we can figure out three important relationships. from high school times, you should know a number of cool things about circles. The one we need is the area of what is called a sector. Draw a circle of radius r in the plane. Measure an angle x counterclockwise from the horizontal axis. Then look at the pie shaped wedge formed in the circle that is bounded above by the radial line, below by the horizontal axis and to the side by a piece of the circle. It is easy to see this in the figure. Looking at the picture, note there is a first sector or radius cos(x) and a larger sector of radius 1. It turns out the area of a sector is 1/2r 2 θ where θ is the angle that forms the sector. From the picture, the area of the first sector is clearly less than the area of the second one. So we have (1/2) cos 2 (x) x < (1/2) x
Sin, Cos and all that! Now if you look at the picture again, you ll see a triangle caught between these two sectors. This is the triangle you get with two sides having the radial length of 1. The third side is the straight line right below the arc of the circle cut out by the angle x. The area of this triangle is (1/2) sin(x) because the height of the triangle is sin(x). This area is smack dab in the middle of the two sector areas. So we have (1/2) cos 2 (x) x < (1/2) sin(x) < (1/2) x.
Sin, Cos and all that! Now if you look at the picture again, you ll see a triangle caught between these two sectors. This is the triangle you get with two sides having the radial length of 1. The third side is the straight line right below the arc of the circle cut out by the angle x. The area of this triangle is (1/2) sin(x) because the height of the triangle is sin(x). This area is smack dab in the middle of the two sector areas. So we have (1/2) cos 2 (x) x < (1/2) sin(x) < (1/2) x. These relationships work for all x and canceling all the (1/2) s, we get cos 2 (x) x < sin(x) < x.
Sin, Cos and all that! Now if you look at the picture again, you ll see a triangle caught between these two sectors. This is the triangle you get with two sides having the radial length of 1. The third side is the straight line right below the arc of the circle cut out by the angle x. The area of this triangle is (1/2) sin(x) because the height of the triangle is sin(x). This area is smack dab in the middle of the two sector areas. So we have (1/2) cos 2 (x) x < (1/2) sin(x) < (1/2) x. These relationships work for all x and canceling all the (1/2) s, we get cos 2 (x) x < sin(x) < x. Now as long as x is positive, we can divide to get cos 2 (x) < sin(x)/x < 1.
Sin, Cos and all that! Almost done. From our high school knowledge about cos, we know it is a very smooth function and has no jumps. So it is continuous everywhere and so lim x 0 cos(x) = 1 since cos(0) = 1.
Sin, Cos and all that! Almost done. From our high school knowledge about cos, we know it is a very smooth function and has no jumps. So it is continuous everywhere and so lim x 0 cos(x) = 1 since cos(0) = 1. If that is true, then the limit of the square is 1 2 or still 1. So lim x 0 sin(x)/x is trapped between the limit of the cos 2 term and the limit of the constant term 1. So we have to conclude lim sin(x)/x = 1. x 0 + We can do the same thing for x 0, so we know lim x 0 sin(x)/x = 1
Sin, Cos and all that! Almost done. From our high school knowledge about cos, we know it is a very smooth function and has no jumps. So it is continuous everywhere and so lim x 0 cos(x) = 1 since cos(0) = 1. If that is true, then the limit of the square is 1 2 or still 1. So lim x 0 sin(x)/x is trapped between the limit of the cos 2 term and the limit of the constant term 1. So we have to conclude lim sin(x)/x = 1. x 0 + We can do the same thing for x 0, so we know lim x 0 sin(x)/x = 1 Hah you say. Big deal you say. But what you don t know is the you have just found the derivative of sin at 0!
Sin, Cos and all that! Note ( sin(h) sin(0) sin(x)) (0) = lim h 0 h = lim h 0 sin(h) h because we know sin(0) = 0.
Sin, Cos and all that! Note ( sin(h) sin(0) sin(x)) (0) = lim h 0 h = lim h 0 sin(h) h because we know sin(0) = 0. Now if lim x 0 sin(x)/x = 1, it doesn t matter if we switch letters! We also know lim h 0 sin(h)/h = 1. Using this, we see ( sin(h) sin(x)) (0) = lim h 0 h as cos(0) = 1! ( Review, Review...). = 1 = cos(0)
Sin, Cos and all that! This result is the key. Consider the more general result ( sin(x)) = lim h 0 sin(x + h) sin(x). h
Sin, Cos and all that! This result is the key. Consider the more general result ( sin(x)) = lim h 0 sin(x + h) sin(x). h Now dredge up another bad high school memory: the dreaded sin identities. We know and so sin(u + v) = sin(u) cos(v) + cos(u) sin(v) sin(x + h) = sin(x) cos(h) + cos(x) sin(h).
Sin, Cos and all that! Using this we have ( sin(x + h) sin(x) sin(x)) = lim h 0 h sin(x) cos(h) + cos(x) sin(h) sin(x) = lim h 0 h sin(x) ( 1 + cos(h)) + cos(x) sin(h) = lim. h 0 h
Sin, Cos and all that! Using this we have ( sin(x + h) sin(x) sin(x)) = lim h 0 h Now regroup a bit to get sin(x) cos(h) + cos(x) sin(h) sin(x) = lim h 0 h sin(x) ( 1 + cos(h)) + cos(x) sin(h) = lim. h 0 h ( ( 1 + cos(h)) sin(x)) = lim sin(x) h 0 h + cos(x) sin(h). h
Sin, Cos and all that! We are about done. Let s rewrite (1 cos(h))/h by multiplying top and bottom by 1 + cos(h). This gives sin(x) ( 1 + cos(h)) h = sin(x) ( 1 + cos(h)) h = sin(x) (1 cos2 (h)) h (1 + cos(h)) (1 + cos(h)) 1 (1 + cos(h)).
Sin, Cos and all that! We are about done. Let s rewrite (1 cos(h))/h by multiplying top and bottom by 1 + cos(h). This gives sin(x) ( 1 + cos(h)) h = sin(x) ( 1 + cos(h)) h = sin(x) (1 cos2 (h)) h (1 + cos(h)) (1 + cos(h)) 1 (1 + cos(h)). Now 1 cos 2 (h) = sin 2 (h), so we have sin(x) ( 1 + cos(h)) h = sin(x) sin2 (h) h = sin(x) sin(h) h 1 (1 + cos(h)) sin(h) 1 + cos(h).
Sin, Cos and all that! We are about done. Let s rewrite (1 cos(h))/h by multiplying top and bottom by 1 + cos(h). This gives sin(x) ( 1 + cos(h)) h = sin(x) ( 1 + cos(h)) h = sin(x) (1 cos2 (h)) h (1 + cos(h)) (1 + cos(h)) 1 (1 + cos(h)). Now 1 cos 2 (h) = sin 2 (h), so we have sin(x) ( 1 + cos(h)) h = sin(x) sin2 (h) h = sin(x) sin(h) h 1 (1 + cos(h)) sin(h) 1 + cos(h). Now sin(h)/h goes to 1 and sin(h)/(1 + cos(h)) goes to 0/2 = 0 as h goes to zero. So the first term goes to sin(x) 1 0 = 0. Since cos(0) = 1 and cos is continuous, the first limit is sin(x) (0).
Sin, Cos and all that! We also know the second limit is cos(x) (1). So we conclude ( sin(x)) = cos(x). And all of this because of a little diagram drawn in Quadrant I for a circle of radius 1 plus some high school trigonometry.
Sin, Cos and all that! We also know the second limit is cos(x) (1). So we conclude ( sin(x)) = cos(x). And all of this because of a little diagram drawn in Quadrant I for a circle of radius 1 plus some high school trigonometry. What about cos s derivative? The easy way to remember that sin and cos are shifted versions of each other. We know cos(x) = sin(x + π/2). So by the chain rule ( cos(x)) = ( sin(x + π/2)) = cos(x + π/2) (1).
Sin, Cos and all that! Now remember another high school trigonometry thing. cos(u + v) = cos(u) cos(v) sin(u) sin(v) and so cos(x + π/2) = cos(x) cos(π/2) sin(x) sin(π/2). We also know sin(π/2) = 1 and cos(π/2) = 0. So we find ( cos(x)) = sin(x).
Sin, Cos and all that! Now remember another high school trigonometry thing. cos(u + v) = cos(u) cos(v) sin(u) sin(v) and so cos(x + π/2) = cos(x) cos(π/2) sin(x) sin(π/2). We also know sin(π/2) = 1 and cos(π/2) = 0. So we find ( cos(x)) = sin(x). Let s summarize: (sin(x)) = cos(x) (cos(x)) = sin(x) And, of course, we can use the chain rule too!! As you can see, in this class, the fun never stops (that s a reference by the way to an old Styx song...)
Sin, Cos and all that! Example Simple chain rule! Find ( sin(4t)). Solution This is easy: ( sin(4t)) = cos(4t) 4 = 4 cos(4t).
Sin, Cos and all that! Example Chain rule! Differentiate sin 3 (t) Solution The derivative is ( sin 3 (t) ) = 3 sin 2 (t) ( (sin) (t) ) = 3 sin 2 (t) cos(t)
Sin, Cos and all that! Example ( Find sin 3 (x 2 + 4)). Solution ( sin 3 (x 2 + 4)) = 3 sin 2 (x 2 + 4) cos(x 2 + 4) (2x).
Sin, Cos and all that! Example Chain and product rule Find (sin(2x) cos(3x)). Solution ( sin(2x) cos(3x)) = 2 cos(2x) cos(3x) 3 sin(2x) sin(3x).
Sin, Cos and all that! Example Quotient rule! Find (tan(x)). Solution We usually don t simplify our answers, but we will this time as we are getting a new formula! ( tan(x)) = = ( ) sin(x) cos(x) cos(x) cos(x) sin(x) ( sin(x)) cos 2 (x) = cos2 (x) + sin 2 (x) cos 2. (x)
Sin, Cos and all that! Solution (Continued): Next, recall cos 2 (x) + sin 2 (x) = 1 always and so ( 1 tan(x)) = cos 2 (x). Now if you remember, 1/cos 2 (x) is called sec 2 (x). So we have a new formula: (tan(x)) = sec 2 (x)
A New Power Rule Now that we have more functions to work with, let s use the chain rule in the special case of a power of a function. We have used this already, but now we state it as a theorem. Theorem Power Rule For Functions If f is differentiable at the real number x, then for any integer p, (f p (x)) = p ( f p 1 (x) ) f (x) Example Differentiate (1 + sin 3 (2t)) 4 Solution d dt ((1 + sin3 (2t)) 4 ) = 4 (1 + sin 3 (2t)) 3 3 sin 2 (2t) cos(2t) 2
A New Power Rule Let f (x) = x 3/7. Then (f (x)) 7 = x 3. Let x n x be any sequence converging to x. Then lim n (f (x n )) 7 = lim n x 3 n = x 3. Thus, since the function u 7 is continuous, we have (lim n f (x n )) 7 = x 3. So, lim n f (x n )) = f (lim n x n ) = x 3/7. This shows f (x) = x 3/7 is continuous. A little thought shows this argument works for f (x) = x p/q for any rational number p/q. Now what about differentiability? We have for x 0, f (x + h) f (x) is not zero and so we can write 3x 2 = d dx (f (x))7 = lim h 0 (f (x + h)) 7 (f (x)) 7 f (x + h) f (x) (f (x+h)) Since we know lim 7 (f (x)) 7 h 0 f (x+h) f (x) the ratio of two known limits and so f (x + h) f (x) lim h 0 h = f (x + h) f (x) h = 7(f (x)) 6, the limit we seek is 3x 2 7(f (x)) 6 = 3 7 x 4/7.
A New Power Rule Note this argument fails for this next example. We let f (x) = { 1, x Q 1, x IR Then (f (x)) 2 = 1 which is differentiable. But we can t write 0 = d dx (f (x))2 = lim h 0 (f (x + h)) 2 (f (x)) 2 f (x + h) f (x) because f (x + h) f (x) is never locally not zero. f (x + h) f (x) h
Derivatives of Complicated Things We will often need to find the derivatives of more interesting things than simple polynomials. Finding rate of change is our mantra now! Let s look at a small example of how an excitable neuron transforms signals that come into it into output signals called action potentials. For now, think of an excitable neuron as a processing node which accepts inputs x and transforms them using a processing function we will call σ(x) into an output y.
Derivatives of Complicated Things We will often need to find the derivatives of more interesting things than simple polynomials. Finding rate of change is our mantra now! Let s look at a small example of how an excitable neuron transforms signals that come into it into output signals called action potentials. For now, think of an excitable neuron as a processing node which accepts inputs x and transforms them using a processing function we will call σ(x) into an output y. As we know, neural circuits are built out of thousands of these processing nodes and we can draw them as a graph which shows how the nodes interact. Look at the simple example in next figure.
Derivatives of Complicated Things Figure: A simple neural circuit: 1-2-1
Derivatives of Complicated Things In the picture you ll note there are four edges connecting the neurons. We ll label them like this: E 1 2, E 1 3, E 2 4 and E 3 4.
Derivatives of Complicated Things In the picture you ll note there are four edges connecting the neurons. We ll label them like this: E 1 2, E 1 3, E 2 4 and E 3 4. When an excitable neuron generates an action potential, the action potential is like a signal. The rest voltage of the cell is about 70 millivolts and if the action potential is generated, the voltage of the cell rises rapidly to about 80 millivolts or so and then falls back to rest.
Derivatives of Complicated Things In the picture you ll note there are four edges connecting the neurons. We ll label them like this: E 1 2, E 1 3, E 2 4 and E 3 4. When an excitable neuron generates an action potential, the action potential is like a signal. The rest voltage of the cell is about 70 millivolts and if the action potential is generated, the voltage of the cell rises rapidly to about 80 millivolts or so and then falls back to rest. The shape of the action potential is like a scripted response to the conditions the neuron sees as the input signal.
Derivatives of Complicated Things In many ways, the neuron response is like a digital on and off signal, so many people have modeled the response as a curve that rises smoothly from 0 ( the off ) to 1 ( the on ). Such a curve looks like the one shown in the figure below. Figure: A Simple Neural Processing Function
Derivatives of Complicated Things The standard neural processing function has a high derivative value at 0 and small values on either side. You can see this behavior in the figure below.
Derivatives of Complicated Things We can model this kind of function using many approaches: for example, σ(x) = 0.5(1 + tanh(x)) works and we can also build σ using exponential functions which we will get to later.
Derivatives of Complicated Things We can model this kind of function using many approaches: for example, σ(x) = 0.5(1 + tanh(x)) works and we can also build σ using exponential functions which we will get to later. Now the action potential from a neuron is fed into the input side of other neurons and the strength of that interaction is modeled by the edge numbers E i j for our various i and j s.
Derivatives of Complicated Things We can model this kind of function using many approaches: for example, σ(x) = 0.5(1 + tanh(x)) works and we can also build σ using exponential functions which we will get to later. Now the action potential from a neuron is fed into the input side of other neurons and the strength of that interaction is modeled by the edge numbers E i j for our various i and j s. To find the input into a neuron, we take the edges going in and multiply them by the output of the node the edge is coming from. If we let Y 1, Y 2, Y 3 and Y 4 be the outputs of our four neurons, then if x is the input fed into neuron one, this is what happens in our small neural model Y 1 = σ(x) Y 2 = σ(e 1 2 Y 1 ) Y 3 = σ(e 1 3 Y 1 ) Y 4 = σ(e 2 4 Y 2 + E 3 4 Y 3 ).
Derivatives of Complicated Things Note that Y 4 depends on the initial input x in a complicated way. Here is the recursive chain of calculations.
Derivatives of Complicated Things Note that Y 4 depends on the initial input x in a complicated way. Here is the recursive chain of calculations. First, plug in for Y 2 and Y 3 to get Y 4 in terms of Y 1. ( ) Y 4 = σ E 2 4 σ(e 1 2 Y 1 ) + E 3 4 σ(e 1 3 Y 1 ).
Derivatives of Complicated Things Note that Y 4 depends on the initial input x in a complicated way. Here is the recursive chain of calculations. First, plug in for Y 2 and Y 3 to get Y 4 in terms of Y 1. ( ) Y 4 = σ E 2 4 σ(e 1 2 Y 1 ) + E 3 4 σ(e 1 3 Y 1 ). Now plug in for Y 1 to see finally how Y 4 depends on x. ( ( ) Y 4 (x) = σ E 2 4 σ E 1 2 σ(x) ( + E 3 4 σ E 1 3 σ(x)) ).
Derivatives of Complicated Things For the randomly chosen edge values E 1 2 = 0.11622, E 1 3 = 1.42157, E 2 4 = 1.17856 and E 3 4 = 0.68387, we can calculate the Y 4 output for this model for all x values from 3 to 3 and plot them. Now negative values correspond to inhibition and positive values are excitation.
Derivatives of Complicated Things For the randomly chosen edge values E 1 2 = 0.11622, E 1 3 = 1.42157, E 2 4 = 1.17856 and E 3 4 = 0.68387, we can calculate the Y 4 output for this model for all x values from 3 to 3 and plot them. Now negative values correspond to inhibition and positive values are excitation. our simple model generates outputs between 0.95 for strong inhibition and 0.65 for strong excitation. Probably not realistic! But remember the edge weights were just chosen randomly and we didn t try to pick them using realistic biologically based values. We can indeed do better. But you should see a bit of how interesting biology can be illuminated by mathematics that comes from this class! See the next figure.
Derivatives of Complicated Things Figure: Y 4 output for our neural model
Derivatives of Complicated Things Note that this is essentially a σ(σ(σ))) series of function compositions! So the idea of a composition of functions is not just some horrible complication mathematics courses throw at you. It is really used in biological systems.
Derivatives of Complicated Things Note that this is essentially a σ(σ(σ))) series of function compositions! So the idea of a composition of functions is not just some horrible complication mathematics courses throw at you. It is really used in biological systems. Note, while we know very well how to calculate the derivative of this monster, Y 4 (x) using the chain rule, it requires serious effort and the answer we get is quite messy. Fortunately, over the years, we have found ways to get the information we need from models like this without finding the derivatives by hand! Also, just think, real neural subsystems have hundreds or thousands or more neurons interacting with a vast number of edge connections. Lots of sigmoid compositions going on!
Derivatives of Complicated Things Note that this is essentially a σ(σ(σ))) series of function compositions! So the idea of a composition of functions is not just some horrible complication mathematics courses throw at you. It is really used in biological systems. Note, while we know very well how to calculate the derivative of this monster, Y 4 (x) using the chain rule, it requires serious effort and the answer we get is quite messy. Fortunately, over the years, we have found ways to get the information we need from models like this without finding the derivatives by hand! Also, just think, real neural subsystems have hundreds or thousands or more neurons interacting with a vast number of edge connections. Lots of sigmoid compositions going on! Let s do a bit more here. We know we can approximate the derivative using a slope term. Here that is Y 4 (x) = Y 4 (p) + Y 4(p)(x p) + E(x, p).
Derivatives of Complicated Things since E(h)/(h) is small near x too, we can say near x. Y 4 (p + h) Y 4 (p) h Y 4(p)
Derivatives of Complicated Things since E(h)/(h) is small near x too, we can say near x. Y 4 (p + h) Y 4 (p) h Y 4(p) We can use this idea to calculate the approximate value of the derivative of Y 4 and plot it. As you can see from the figure below, the derivative is not that large, but it is always negative. Remember, derivatives are rates of change and looking at the graph of Y 4 we see it is always going down, so the derivative should always be negative.
Derivatives of Complicated Things Figure: Y 4 s Approximate Derivative Using h =.01
Derivatives of Complicated Things Homework 24 24.1 Let f (x) = { x, x Q x, x IR Explain why (f (x)) 2 is differentiable but f (x) is not ever. 24.2 Calculate Y 4 explicitly for our small neural circuit example. ( ( ) ( Y 4 (x) = σ E 2 4 σ E 1 2 σ(x) + E 3 4 σ E 1 3 σ(x)) ). where σ(x) = 0.5(1 + tanh(x)). This is just messy really. It is a bunch of chain rules!
Derivatives of Complicated Things Homework 24 f (x+h) f (x h) 24.3 If f is differentiable at x, prove lim h 0 2h = f (x). f (x+h) f (x h) Hence, 2h is an approximation to f. Hint: We know there is δ 1 and δ 2 so that 0 < h < min(δ 1, δ 2 ) implies f (x + h) f (x) f (x) h < ɛ/2, f (x h) f (x) f (x) h < ɛ/2 Now use the above with the add and substract trick below to finish: f (x + h) f (x h) f (x) 2h = f (x + h) f (x) + f (x) f (x h) f (x) 2h Use your favorite computational tool and generate plots of the true f vs this approximation for h = 0.6, h = 0.3 and h = 0.1 for f (x) = 5x 4 + 3x 2 4x + 7 for the interval [ 2, 2].