MPS115/MPS116 PRESENTATION LAB 10
This week we will look at using spreadsheets to investigate mathematical problems, this will include tips for presenting the findings well.
You probably know Microsoft’s Excel software, which is widely used. If you are working on one of the University’s PCs, then I recommend using that for today’s lab. If not, and you don’t have a version of Excel to use, then Google Sheets (accessed through a web browser) works fine with all except the last part of this week’s sheet. In general, I use Google sheets as it works well with my university account and it is easy to share sheets. If neither of those are an option, I expect most other spreadsheet software will work OK for most of the sheet, e.g. Numbers (on a Mac) or Open Office.
The basics: a spreadsheet consists of cells, each of which is has an address, such as (first-column, second row). Inside each cell can either go a value – such as text or a number – or a formula. Formulas must start with an equals sign, ‘=’.
Go to the Week 11 material on the module web page and save the file called projectiles.xlsx. Open this in Excel or upload it to Google Sheets.
By looking at the contents of the cells, try to work out what it does. The presentation is poor, so this won’t be easy. We will improve that. The data actually represents the motion of a projectile, with the first column being time, and the next two columns being the and coordinates of the projectile.
You’ve probably noticed that some cell references have $-signs in, e.g. . These are what’s known as absolute references. Absolute references don’t change when using the fill handle (see later).
Hopefully the data is looking better now. You will notice that, on the right, there are parameters that are referenced in the formulas calculating the and values.
Let’s draw a graph of the flight of the projectile. Highlight the data in the table corresponding to the and coordinates, including the titles, then
Drag this graph to a suitable place on the page. Try changing the parameters (other than !) to vary the projectile’s path.
To make sure the projectile can’t disappear below ground level,
insert a new column to your main table called floor(y). In the
top cell, use the IF function in Excel to make that cell display the
value if it is
positive and
otherwise. Excel should help you as you start to type ‘=IF(...’, and in Google
Sheets a small ‘?’ should appear with help on how to use the IF function. Use the
fill handle to complete the rest of the column.
If you don’t know how to use the fill handle then search YouTube for ‘How to Use the Fill Handle’ and watch a short video.
Delete the graph, then re-plot the values against the adjusted values. Alternatively, edit the data range for the graph if you can find out how.
Finally, the spreadsheet needs a title. Insert two blank rows at the top, and in cell type ‘Projectile motion’. Make the title 18pt and bold.
You have covered Euclid’s algorithm for finding the highest common factor of a pair of integers earlier this semester. Let’s look at implementing it in a spreadsheet.
Start a new spreadsheet and save it. As a test run, we’ll use the numbers 1001 and 132.
(This column will keep track of the successive remainders that appear in Euclid’s algorithm.)
(The function INT will be useful here.)
Essentially, the algorithm is now complete. Change the numbers and to see the workings change. As usual, a bit of effort with the presentation here can make the spreadsheet much more user-friendly.
Start a column to the right of the ‘Quotients’ column called ‘Description’. We’ll use the CONCATENATE function to give a description of what the calculation has shown at each stage.
D2=E3*D3+D4’; that is,
giving the output ‘’.
(Hint: CONCATENATE joins together strings, like the + operator in
Python. Here, you need to join the value in ,
an ‘=’-sign, the value in ,
a ‘’-sign,
etc.)
Now to get rid of the unsightly error messages. The function IFERROR is good for this, which gives an alternative output for a formula if the formula returns an error.
=formula’ to ‘=IFERROR(formula,"")’.
Note: Unfortunately, Google Sheets and Excel don’t behave in quite the same
way in terms of error messages, and you may find spurious numbers
appearing in rows after the calculation is complete. If you want to tidy
things up, try using the =IF(... and =OR(... functions to check whether
the remainder at the previous stage is either zero or blank to blank the
output.2
Make sure everything is working at this stage by altering and and watching the content of your spreadsheet change.
A nice touch would be to display the sentence ‘The highest common factor of and is ’ at the top of the page. Try to find a valid approach. Have a look at my lab attempt on the course webpage if you get stuck.
All that’s left to do is to add two rows at the top, and put in the title ‘Euclid’s algorithm’ in 18pt bold.
(Excel only!) As a final task, let’s look at the Solver feature of Excel, which can maximise or minimise expressions subject to constraints.
On the course webpage, download and save the spreadsheet called solver.xlsx. The spreadsheet shows data for unknown function . Our task is to try to to fit an appropriate curve.
Notice that the plot of the data shows something that looks like a damped oscillation (that is, a sine curve that becomes increasingly less energetic). An appropriate function to try to fit here would be something of the form , since data is off-axis damps towards zero. Let’s see if this hunch is correct.
A quick way to change to an absolute reference when typing a formula is to press F4.
Here’s the clever bit! We’re going to get Excel to work out the best possible values for the parameters by minimising the sum of the squared differences you just calculated. To do that, we use Solver.
To enable Solver, go to File, then Options and select Add-ins. At the bottom, find the bit that says Manage: Excel Add-ins and click Go. Select Solver and click OK.
If you can’t get Solver to install properly, then I’m afraid you will have to leave this sheet here! Otherwise, continue...
Now, look in the Data menu at the top. You should see Solver on the right-hand side. Click to start it.
We want to minimize the cell containing the sum of the squares by changing the parameter values. Thus,
All being well, Solver will work out the best possible parameter values. Check the graph to see if it’s been successful. _____________________________________
There is no homework this week.