computer science
Assignment #1: Graph of Tangent function
Your task is to produce a graph of the tan(x) function over the interval of 360 degrees to +360
degrees. When complete it must exactly like this figure:
Save your spreadsheet as an .xlsx file and submit it through moodle. No Comments worksheet is
required.
Step-by-step instructions:
This assignment is similar to Exercise 3 in Chapter 1 of the Glade Manual, but with a different
function and over a different interval. The following instructions follow the version of Excel
found in the version of Microsoft Office 365 available for free to York students. If you are using
a different version you may have to adapt these instructions.
Launch Excel and select a Blank Workbook.
Enter the label angle in cell A2. Enter the value -360 in cell A3. Highlight cells A3 to 147. Click
on the icon , found near the right end of the ribbon, and select Series… . Change the Step value to 5 and click on OK.
Enter the label tan in cell B2.
Construct the formula =TAN(RADIANS(A3)) or, equivalently, =TAN(A3*PI()/180)
Rather than just typing in one of these formulas, try constructing it using the Formula Builder.
Selecting and nesting functions is a complicated process and an important skill to develop. As
formulas get more complicated it will be more efficient and accurate to build formulas rather
than just typing them.
Move the cursor to the little black square at the bottom right corner of the current cell, and when
it turns into + drag down to cell 147. Examine some of the cells in column B. Notice how the reference to cells in column A change. They remain in lock-step. This is known as a relative cell
reference and is an extremely important feature of a spreadsheet. Spreadsheets tend to have
repeating patterns and when formulas are copied and pasted, relative cell references cause these
formulas to be automatically adjusted without the need for us to edit them, most of the time.
Examine the numbers in column B. Some end with E16 or E+15. This computer notation for
powers of ten: 10-16 and 10+15. Google “tan function” and become familiar with the behaviour of
the function. Tan of 0 degrees should be zero. The computer can only compute an approximation
and so produces a value close to zero. Tan of 90 degrees should be infinity. Again, the computer
produces a large value due to approximation and rounding error.
Create a Chart
Click on any blank cell in your spreadsheet. Click on the Insert tab and then click on and select a pure line graph, the first choice on the first line of icons. You will get a blank canvas on
which you will construct your graph (the Chart). Notice the squares on the corners and in the
middle of the edges. These allow you to resize the rectangle. You can also move it around. Move
the canvas so that the top edge lines up with the grid line between row 2 and 3 of the spreadsheet
and resize, if necessary. Finally, as an experiment, violate the first instruction, namely select a
cell with a number in it and insert a line graph and see what happens.
Click on the Select Data icon in the Ribbon. The Select Data Source dialog box appears. Click on the + under the empty box on the left under the heading Legend Entries (Series). Series1 appears in the white box. Series is Excel speak for the line. Ignore Name, as we are not going to name our line. Y values define our curve. Erase ={1} and highlight cells B3 to B147. In Horizontal (Category) axis labels, highlight cells A3 to A147. Click on OK. You can select a range of cells by starting at A3 and dragging down to A147, or start at A147 and drag up to A3. You can start
from whatever is currently visible on the screen or maneuver to a desired starting point.
To fine-tune the x-axis, point the cursor at any number along the x-axis and double-click. The
Format Axis dialog box appears on the right. There are lots of components to explore. Click on
each icon and start scratching your head! . Explore these until the x-axis in
your Chart matches the one in the figure above. Click on the x at the top right corner to make it go away.
To fine-tune the y-axis, point the cursor at any number along the y-axis and double-click. The
Format Axis dialog box appears on the right. Notice that it has a (slightly) different structure than the one for the x-axis.
To insert the titles for the overall chart and the x-axis and y-axis, click on the Quick Layout icon (in the Chart Design tab). A dozen choices are presented. None are a perfect match for our needs. So, we’ll pick one that has everything we need and then we’ll remove the unwanted part(s). To
get rid of an unwanted part, click on the Add Chart Element icon (in the Chart Design tab). In our case, we want to get rid of the Legend. Click on Legend in the menu and select None. As an alternative, you could have built everything from scratch in Add Chart Element.
To manipulate grid lines, select Gridlines in Add Chart Element and turn on or off the major horizontal or vertical lines.
To enter the titles, select the text box containing the place holder, highlight the text and type your
new title.
At this point there are still ugly (almost) vertical lines where tan should be infinity. Select those
cells in column B that have values ending in E+15, i.e. poor approximations to infinity, and
“clear” them. Click on the icon that looks like a brush near the right end of the “Home” ribbon.
Requirements – what we will look for during grading:
a) Angle values in cells A3 to A147, centred. (Optional: column width set to 7) b) Function values, produced by the formula, in cells B3 to B147, formatted to 4 decimal
places. (Optional: column width set to 9)
c) Chart, x-axis, y-axis titles exactly as in the figure above. Use the default font and point size
d) No legend e) x-axis as in the figure, labels 90 apart, ranging from -360 to 360 f) x-axis and y-axis: tick marks, crossing at the labels g) y-axis as shown in figure, ranging from -12 to 12, 4 apart h) y-axis crossing x-axis at 0 i) horizontal and vertical grid lines as shown on the major tick marks j) Chart positioned with the top edge on the grid line between rows 2 and 3 of the
spreadsheet, to the right of the two columns of values.