Hi everyone and welcome to our lecture on modeling with power functions. So first before we talk about modeling with power functions, let's review what a power function actually is. So we will recall the definition. So a power function is of the form y = cx to the k, and c and k are just real numbers. They are constants. The variable here is in terms of x. So here is an example of a couple power functions that you know, this y = x squared is a great one. This is what c is one and k is two, y = x cubed, of course, is another type of power function. How about y = x to the fourth? So in particular case of positive integers, these just becoming polynomials. These are nice and they have different flavors and different sizes, different shapes, but you've seen a few of these before. But there's nothing that's stopping k from being perhaps a rational number, it doesn't have to be an integer. So in that particular case you have y = x to the one-half. Now remember x equals one half, of course is the square root function and that is a very different behavior then x squared, x cubed, x to the fourth. You can also have another example say y = x to the -1. Usually negative exponents are written in the denominator with them being positive. So there's a little measuring 1here. And these are all graphs that you should have the basic shape of, but the key is that they are very different. So power functions come in many many flavors, there are more, let's say a variety of shapes, sizes and behaviors to work with. And they are a powerful tool in your arsenal when you are modeling with things. Just to show you that these power functions come up in real life, other examples that you have seen have an area of a circle. So in geometry pi r squared, this is a power function. Your coefficient in front is pi, as you see, and your exponent k is a 2. So it's 2, this the area of a circle. And also if we did area of a square, about side squared, that's another example of power function. So here the coefficient in front is 1, and your exponent is 2. So these functions come naturally in other courses, and so it's good to describe them with a general term called power function. Now, here's the tricky part. Let's just take the easiest type of power function y = x squared. If I say to you, hey, draw the parabola. Most people start a flow and they go high, and we label it y = x squared. And if I say to you, well, hey, I don't want to confuse these with the other kind of functions that we saw. Remember, the other kind of functions we saw were exponential functions that go low to high. So if I said, hey, just draw in quadrant one, the exponential function y = e to the x, the hand sketch of these two look very similar. And that's going to be the challenge, at least in the beginning when we're working with power functions, because we want a way to differentiate when we want a power function model versus an exponential model. They both sort of have the same behavior, and if these were scatter plots and the dots were moving in this direction, low to high arching up, what is the best way to do that? So that's we are going to go there, the direction we're going to go. So I use desmos.com to graph an exponential versus power function. And stare at this video, look at the two graphs if you can, and decide which one is an exponential function and which one is a power function. And you see what I mean where they are very, very similar if you graph the equations, and if this were a scatterplot, it gets even harder. One of the obvious differences is that one graph goes through the origin and one graph does not. I think that's the the giveaway here. But in terms of like how they go off towards infinity, it's pretty tough to eyeball. If you said that the left graph was the exponential function, you are correct. This is y = e to the x, again, the y intercept, I think is the key here. If you plug in o, you get e to the 0, that's one. On the other graph is y = x squared, that if you plug in 0, of course you get 0. So that goes through there. So but not every scatterplot has a y intercept and that's the challenge. So you can imagine if we had like a scatterplot that was going around the curve and maybe on the other side as well, just some data points that were moving in this direction, maybe an outlier here there. Would you be able to tell which one, what model is best for your data without an intercept? We need to come up with a way to do that. Friendly reminder, this e to the x function, this is an exponential function. And y = x squared is our new function that we're going to use to model. This is our power function. The general equation for an exponential function is y = ce to the kx. A power function is y = cx to the k. It's important to realize where the variable lives in both of these. They look similar, students get confused all the time, exponential function has a constant base, we usually pick e. And a power function has the variable in the base and a constant exponent just like x squared. So let's start off with a power function. And let's do the same trick that we did when we looked at our semi-log plots and we turned an exponential function into a linear function. And this allowed us to use linear regression, which we have a theory for to measure how good a fit the line is, the best line fit the least squares line. And let's see if we do that again. So let's take the log of both sides. This is that amazing move where, why would I introduce logs when they aren't logs to begin with? Don't they make things more complicated? Well, in this particular example, it's going to make things easier. So we take a log of both sides perfectly legal moves, whatever you do on one side, you must do to the other side. And then let's use properties of logarithms. We have a product here c the coefficient in front times x to the k. So let's break that off as log of c + log of x to the k. And then we'll use one more rule of logarithms that says, if I have an exponent, an exponent comes out front. And I get the natural log is the log of c + k ln of x, I stare at this for a minute, we're staring at three logarithms. You may say, well, that's not better, is it? Well, let's rewrite some things with substitution. Call the ln y, this is our new output. So let's just call this like y prime for a minute. And then the log of c. This is some constant. C is a constant, logarithm constant and we just get back some constant. And for reasons to be apparent in about two seconds, I'm going to call this b, k we'll call it m. And then log of x, this is my new input variable, just like before we switch. We're going to call this like x prime. And so what happens when you do this substitution you get y prime = b + m x prime. Stare at that for a minute, what are you looking at? This is a line, this is linear. So this is linear. By taking a log of both sides you turn a power function into linear in log both variables, your input variable and your output variables. So the key to measure how good this is, you start off, so step one is like you graph your scatterplot in x and y, and then substituted tested, you take log of x and log of y, and you re-plot the data points. So hopefully if you think that data points are moving in sort of an exponential model, well, when do you do this log-log plot as it's called. So weird to say log-log plot, but there's two logs, so it makes sense. It should turn the data into a linear model. And then once it's linear, you can apply linear regression. So we can use line of best fit so we can measure how good a fit it is with R squared. And these are well defined numbers for linear regression. So this is what we're going to do. One thing that I also want to point out for- and this is sort of interesting here, the slope. So we have this new hopefully nice line, we get our slope, y = mx + b for our linear regression. The slope of the linear regression is the exponent k of the power function. Let me say that one more time, that's important thing to realize, that the slope of the linear regression becomes the exponent k of the power function. Now how do you get c then, or how do you get the linear coefficient? Well, remember that the intercept, so that is the first point in the intercept, b will then be the log of c. So of course now how do you find c? Well, let's get rid of the log. So therefore, c = e to the b. So you exponentiate the intercept. And from that process of linear regression, that's why we do linear regression first, you can find the missing coefficients in your power function of best fit. There's one little caveat, there's one little warning that we should talk about here. And this assumes, this argument here assumes that the data is positive. Think about that for a second. Why do we assume that the data values are positive? Why do I need to graph this scatterplot inside of quadrant one. That is because in the second step, I take the log of both sides. Think about what the domain is for the logarithm, domain for a logarithm is positive real numbers, I need positive numbers to even have the second equation make sense. You can't take a log of a negative number. It's just not in the domain. There are ways to work around that. If you really have a negative data set and you start taking absolute values. You can use some symmetry in the problem, you can manipulate your data, or you manipulate the equation, those are all possible things. There's other more advanced techniques, if you've seen a little bit of statistics before, there's other advanced techniques that we're not going to get into in this class, but we're going to assume the data is positive. There are lots of data sets that are positive or that you can make positive. So this argument is really important, if you try this for non-positive data, you will break the calculator, you'll throw back errors because you're taking the log of negative numbers. So just watch out for that. Now let's do a small example with a data set here just consisting of 6 entry points. So I have a small table, 6 values for x, 1 through 6, and then y, 8.2, 28, 63, 114, 167 and 304. All right, so you're handed this data again, small example just to sort of prove a point. The first thing you do when you're looking at some data is you want to visualize the data. So we go to Insert, and let's insert a scatterplot. And as promised, the data starts low and goes high. And now we are on the quest to see what is the best model of this data? So let's just give this thing a better title. How about x,y scatterplot, so we have this in mind. And I don't know, what do you think? Is this going to be exponential, is it polynomial? What is the best way to do this? So let's go through the process of really being data analysts and saying what do we do with this thing? So the first thing that we should try is, well, maybe it's a exponential growth, I don't know. But maybe it's linear. Maybe we should leave that for a second. So doesn't look linear, but we should still go through it. So let's add a trendline. Just for fun here. And let's look at how good a linear fit it is. So let's add to my trendline, the R squared value and we'll move it to a place where it's readable and you get 0.09. So R squared is 0.9. So if we look at R, linear correlation coefficient, this would be the square root. Let's use Excel's calculator here. So 0.9011, in that particular case, you get 0.94. So it's actually pretty good. Remember, the closer you are to 1, the better off your model is. So linear is a pretty good fit. Let's see if we could do better though. So it's really small data sets. Maybe that's not surprising. All right, so let's look at x, same thing and we'll look at a log. We'll do the semi-log plot. So let's take the natural log of y. Now inside of Excel again, you can use whatever program you want. We're going to copy the x values, and then we're going to take the logarithm in Excel to do the logarithm you do =log, and we grab the first number. And we have all these decimals. So you let Excel calculate these things for you. This is my new data set. This is going to be my semi-log plot. And let's go ahead and graph that. So we highlight the data. Let's insert a scatterplot. And this scatterplot looks something like this. So let's give it a better title. So this is my x, ln y scatter. Called my semi-log plot. And remember what this is trying to test. This is my test for exponential. So what do I do with this? I add to this now linear trendline. And I want to know how good a fit a linear trendline is to my semi-log plot. So, let's once again grab R squared. Grab R squared, and we'll compute off on the side here. So my linear correlation coefficient to this graph. So that's going to be the square root 0.9602. This should be a little better. 0.979, that is closer to 1. Remember how we did on the last one here. There we go. There is 0.94. So both are pretty good, but which one is better right now? The semi-log is a little better 0.97. We could round these if we want to maybe three decimals so we don't get lost in the numbers. But 0.949, 0.980. So this is saying that as this is a semi-log plot and exponential model is a little better way to do the original data than perhaps a linear model. But linear is still pretty good. Let's try our new way, our power function approach. So what does that mean? We do ln of x, and then we do ln of y. Same thing. I'm not going to sit here and do each one. I'm going to let Excel do all the work for me. So I take natural log of the x values. So I'll plug that in. And I already have a log of y value. So I'll just link to those from the prior graph. And I will drag all that over, and I get these values here. Okay, so I have all these decimals, these decimals I'm rounding to one decimal place, but of course they go on for a long time. Let's highlight and insert a new scatterplot. And now this is my, I'm running out of room here, so start everybody over, be able to slide this down, and see how it looks. This is my log-log plot. From visual inspection, these are starting to line up on a little better than all the other two graphs combined. But let's not use visual inspection, let's use linear correlation coefficients. So this is ln x, ln y scatterplot. And you have to add your own title so you don't get lost to what's going on here. So we have our three graphs here. We have our original data set. We have our semi-log plot, and we have our log-log plot. Semi-log plot test how good an exponential fit is, pretty good. The log-log plot test how good a power function fit is. And this looks pretty good. So let's see how good it is, we're going to add. So let's go to our chart. We're going to add a trendline. Let's add a linear trendline and let's add R squared. Where's that? Here it is. We have R square, so R squared is 0.9948. So that means that our linear correlation coefficient, I can see it, there it is, is going to be the square root of 0.9948. And as a number, this one is going to be the winner, 0.997. So you can tell that our linear correlation coefficient is getting a little better each time. Little better each time. 0.949 is still pretty good 0.980 and then 0.997. So this is saying the best model that fits the state of the best fit to this model would be in fact a power function. Now, how do you get the equation? Well, let's do a couple things here. So I'll do it two ways. One is that in my this log-log plot, you can insert the linear equation. You can do that for any one of these things. If you go to your Chart Tools > Add Chart Element > Trendline > More Trendline Options, a lot of clicks to get there, but it does work. You can always display the equation on the chart. And when you do that, we get y = 1.9718x + 2.0296. Now remember, the slope of your equation for your log-log plot is going to be the exponent of your power function. And the intercept, we exponentiate that it'll turn out to be the other piece of it. So we can go to our original graph. And watch this, we can go to our original graph, this was the original scatterplot with our line where we saw that it really doesn't have a good linear fit. Not the best model, although pretty good, but not the best. So let's add a chart element here. Let's do a trendline, let's go right to, let's see. We have to go to more trendline options in the basic menu, for what I have, we don't have that. So power is an option here on the second menu but not on the first one. And we can play around with the trendline, the colors and all that stuff in a second. But you can see, it's fitting the curve in sort of this parabolic shape, a little better than line. And I want to display the equation on the chart for that. So this is my equation. You have to be careful here, because I have a linear equation going as well. Can I get rid of the linear equation? Now we'll keep it. All right, so the equation is here, so y = 7.6113, x = 1.971 a lots of numbers. Lots of numbers here. But the key thing I want to show you is that 1.9718, notice it's the same as the slope 1.9718, as promised. So I knew that number was coming and I leave this as exercise, if you exponentiate 2.0 the intercept, you will get the coefficient 7.6113. That's where these numbers are coming from. So part of this exercise is to show you where the computer is getting these numbers from so you can have an understanding of what they do. Once you have this equation, and you have the statistics to show that like this is the best fit, now we want to use a power function to do this. Then you can go off and start making predictions and you can start modeling your data, doing interpolation or extrapolation with the equation. So whatever software you're using, we'll do a desmos example in a minute. But this is with Excel. The key is not to just pick a model at random based on what you think the curve is, try to go through the steps look at the R value, look at the R squared value. And try to find one that, if someone says, why did you use this model, you want to have a justification for it not because I randomly pick one. Not because the dots on the scatterplot go up. So look at your linear correlation coefficients, play around with this and sometimes none of them work. And sometimes the simple one is worse. Who knows? It just turns on the data set. All right, so this is using Excel. We'll do a desmos example in the next video. We'll see you then.