Describing Linear Functions on a Spreadsheet

Suppose we have a linear function, say, \(f(x) = 5x + 3\).
We now address the following questions:

1. How can we evaluate this function at an arbitrary argument, \(x\), on a spreadsheet?
2. How can we evaluate it at a whole lot of arguments?
3. How can we plot it?

Will see that once the first of these questions is addressed, the rest are quite easy to do. They were harder in the old days.

One nice feature of what you can do is that if you set this up once, you can change the linear function at will and watch how the plot changes instantly, as in the mathlet.

Just in case you want to keep what you are doing you will be wise to give it labels so at some future time you will know what you have.

So as a preliminary, you might enter in box A1 the title: Linear Functions.

Some more preliminaries: in A2 write the word slope, and in B2 enter the number 5 (later on you can change this to anything else you want)
In A3 enter the words: y intercept, and in B3 enter the number 3.
In A4 enter: starting argument and in B4 enter -1
In A5 enter: spacing and in B5 enter .01.

(When you want to plot your function, you can only do it over a finite interval, and these last lines are useful for creating an interval.)

Now you are ready to start.

In A9 enter the symbol x and in B9 enter f(x). These are labels for the columns below them.
In A10 enter =B4
In B10 enter =B$2*A10 +B$3

You now have the answer to the first question. The number that appears in box B10 will be the value of your function at the argument given in B4 (at this point that argument is -1, and with function 5x + 3 the value in B10 should be -2.)

You can evaluate this function anywhere else you please, by changing the entry in B4 to whatever you please.

Suppose I want to change the slope or the y intercept of my function?

You can do that by changing the entries in B2 or B3. The value of the changed function at the argument in A10 will appear in B10.

What are these funny dollar signs that I have put in A10 and B10?

To answer the second and third questions above we are going to copy the instruction in B10 into other boxes as well. When we do that, the references which do NOT have dollar signs in front of them will change. Those with dollar signs will stay the same.

How do the references change? What do you mean?

Suppose we copy B10 to B11. Then what will appear in B11 will not be exactly what is in B10, but instead it will be =B$2*A11 +B$3. Because the A10 had no dollar sign in it, when we copied it down one row the 10 turned into an 11. The other terms did not change because we put dollar signs in front of them.

What happens if you copy to a different column?

The same kind of thing will happen. That is, if you copy what is in B10 to C11, you will get =C$2*B11 +C$3. All the column indices that do not have dollar signs in front of them will shift over one column, because you shifted over one column. The same goes for shifting any number of rows or columns.

This property is what allows us to look at a function over a range and plot it by copying. Our plan is: have the argument increase by d from row to row, which can be accomplished by putting one entry in A11 and copying it down the A column Then copying B10 down the B column. That is all there is to answer the second question.

OK, what goes into A11?

We can enter =A10+B$5. This will increase the entry in column A in each row we copy it to by the amount in B5 over what it was in the previous row. If we do this in Column A, say down to row 500, and copy B10 also down to row 500, you will have a set of pairs for your function all ready to plot.

OK, how do I copy?

This varies somewhat from spreadsheet to spreadsheet. For many or most you do the following:
1. Highlight the box you want to copy.
2. Press [Ctrl] and c at the same time.
3. Highlight the boxes you want to copy to.
4. Press [Ctrl] and v at the same time.

There is another way that is easier if you are copying several columns down from the same row at once; it is called fill or fill down on the edit menu. Try it. You can also fill sidewise. (Here you could copy B10 into B11 and then fill A11 and B11 both together down to A500 and B500.) Experiment with these things until you get them to work. If you can't get them to work on your spreadsheet, ask someone how.

OK, how do I get a graph of my function?

Highlight columns A and B from row 10 or 11 to row 500 (or to wherever you copied to) and click on "chart" in the insert menu. You will get to another menu with lots of options. Click on "x-y scatter", and you will get to your plot. You will be asked about inserting labels on it and asked where you want it. You can put it anywhere, but if you put it on the same sheet as your calculation, you can change the function or domain by changing what is in B2,...,B5 and see the results immediately. There are ways to adjust the size of the graph and where it is, that you have to figure out for yourself. I generally screw them up.

You can enter and plot lots of functions using the mathlet below, and you can plot curves defined parametrically as well.

What is that? Play with this mathlet and figure that out yourself!