CSE 1520 Computer Use: Fundamentals

CSE 1520 -- Computer Use: Fundamentals
Week 6:
•
Glade Manual Chapter 5
•
Gates and Circuits (Dale & Lewis Ch. 4)
1
CSE 1520 -- Computer Use: Fundamentals
Glade Manual
• Ch. 5 – Recurrence Calculations
• Recurrence Idea:
Suppose you have a row (or column) of numbers and you want to have another
row that displays the cumulative (running) total of the first, i.e
Row
8
3
12
9
11
Cumulative Sum
8
11
23
32
45
11 = 8 + 3
23 = 11 + 12
32 = 23 + 9
The idea here is that the cumulative sum is a function of the previous
number in “Row”
2
CSE 1520 -- Computer Use: Fundamentals
Glade Manual – Chapter 5
• Exercise 2: Bank Account Balance
The model contains a worksheet called “Account”, which contains a balance
brought forward (from a previous month perhaps) and lists of deposits and
withdrawals. The aim is to add another column that shows the balance after each
deposit or withdrawal transaction
Balance = previous balance + deposit - withdrawal
3
CSE 1520 -- Computer Use: Fundamentals
Glade Manual – Chapter 5
• Exercise 3: Investment Growth
This exercise calculates the growth of an investment which earns interest at a
given interest rate and where the interest is added to the investment, i.e. a
compound growth situation
The “CapitalGrowth” worksheet is intended to show the compound growth of an
investment as interest is added to the investment amount at the end of each
period of the investment. There is a column for counting the periods and another
for calculating the amount of the investment (i.e. calculate the new capital)
New capital = old capital + old capital*interest rate*interest period
4
CSE 1520 -- Computer Use: Fundamentals
Glade Manual – Chapter 5
• Exercise 3: Investment Growth
In the “CapitalGrowth” worksheet, the second cell of the “Period” column should
simply be the first cell + 1 – so enter this formula, and then fill it down the column
for about 50 cells. You will find that the values do not stop at 20 – the actual
number of periods - as you would like them to. The solution to this is to use an IF
function in the formula:
If the last value of Period is less than the number of periods specified in the
Parameters worksheet, increment the Period value by 1, otherwise blank the
cell (i.e. “”)
For “Capital”, the logic now should be:
If the corresponding period has a value, then we calculate the “Capital” for
that period, otherwise, we leave it as an empty cell.
5
CSE 1520 -- Computer Use: Fundamentals
Glade Manual – Chapter 5
• Exercise 4: Pepper Moth Population Simulation
This population simulation is intended to calculate the number of light and dark
pepper moths. The population starts out being all light coloured and then each
generation produces, by mutation, a few dark coloured moths.
For light coloured moths:
Next population = number of adult light survivors + number of light births –
number of light births that were actually dark by mutation +
number of dark births that were actually light by mutation –
number of deaths
light survivors = light population - light population * light predation rate
light births = light survivors * light birth rate
light mutations = light births * light mutation rate
light deaths = light survivors * light death rate
6
CSE 1520 -- Computer Use: Fundamentals
Glade Manual – Chapter 5
• Exercise 4: Pepper Moth Population Simulation
In the “Parameters" worksheet:
light survivors = light population - light population * light predation rate
light births = light survivors * light birth rate
light mutations = light births * light mutation rate
light deaths = light survivors * light death rate
In Excel, the next generation of light moth population will be:
= light survivors + light births – light mutations – deaths + dark mutations
Likewise, the next generation of dark moth population will be:
= dark survivors + dark births – dark mutations – deaths + light mutations
7
CSE 1520 -- Computer Use: Fundamentals
Glade Manual – Chapter 5
• Exercise 4: Pepper Moth Population Simulation
Creating the Graph
Select the three columns Light, Dark and Total, and click on the Insert tab and
select “Line” from the Charts group
8
CSE 1520 -- Computer Use: Fundamentals
Glade Manual – Chapter 5
• Exercise 4: Pepper Moth Population Simulation
Creating the Graph
The predation rates for light and
dark moths should not be the
same. The light predation rate
should be larger than the dark
predation rate, so you will have to
change this. Examine which
parameters affect the rapidity of
the changes in the population
9
CSE 1520 -- Computer Use: Fundamentals
Glade Manual – Chapter 5
• Exercise 5: Thyroxine Conversion in the Liver
The object of this exercise is to simulate the functioning of the human liver as it
cleans the blood of a chemical that has been injected. The chemical is called
thyroxine. The liver can convert this into iodine, and from the liver the iodine is
absorbed into the bile:
new amount of thyroxine = old amount of thyroxine - old amount of thyroxine* 0.03 * time
interval + old amount of iodine in liver * 0.07 * time interval
new amount of iodine in liver = old amount of iodine in liver + old amount of thyroxine * 0.03 *
time interval - old amount of iodine in liver * 0.07 * time interval - old amount of iodine in liver *
0.02 * time interval
new amount of iodine in bile = old amount of iodine in bile + old amount of iodine in liver *
0.02 * time interval
10