Mathematical Models
From ComputingForScientists
Contents 
1. Mathematical Models
1.1. Objectives
 To understand how a mathematical representation (mathematical model) of a science model is created
 To learn how to interpret the science meaning of a mathematical model
 To understand that science models and their mathematical representation have limitations
 To understand that some mathematical models do not have analytic solutions
1.2. Motivation
 Nearly every mathematical model of a system requires computation to determine the model's predictions of the future state of the system.
 You must understand how to interpret mathematical models in order to be able to determine if the results of a computation make sense.
1.3. Introduction
A common way that science gets done (see Modeling_Introduction):
 "Domain Specialists" (e.g., biologists) come up with a statement about how a system works
 That is, they develop a conceptual representation of the system or a science model
 Example: Change in population from this year to the next is proportional to population this year
 The domain specialists collaborate with mathematicians to translate the statement into an equation that will give exact numbers
 That is, they develop a mathematical representation, or mathematical model that corresponds to the science model
 Example:
P(next year)  P(this year) = aP(this year)
 The domain specialists and mathematicians work with computational scientists to implement the equations and explore the results using a computer
 That is, they develop a computational representation or computational model of the mathematical model
 These mathematical equations are written in a computer language (like Octave)
 Is the computer doing the calculation the right way? (Not all models are as simple as this example.)
 What if the proportionality constant
a
changes?  What if we change it to use "next day" and "this day" instead of "next year" and "this year"?
1.4. Overview of examples
You have previously dealt with translating statements like this into equations: "The area of a square is 10."
The answer is A = 10
.
In the following examples, we indicate change with a statement in parenthesis. For example, the area of a square doubles every minute translates to
A(next minute) = 2*A(this minute)
Without more information, we can't do anything else. In all of the following examples, we'll write equations like this that you could solve if you had more information. Later on, we'll use these equations along with additional information to compute.
Note 

As an example of a computation, if we knew that at minute 1, the area was 4, we could write A(minute 2) = 2*A(minute 1) = 2*4 = 8. Now that we know the area in minute 2, we can reuse the equation A(next minute) = 2*A(this minute) by writing A(minute 3) = 2*A(minute 2) = 2*8 = 16. This process can be repeated. 
1.5. Examples
 The following are many examples that illustrate
 Translating a science model into a mathematical model
 Interpreting the meaning of a mathematical model
 Once we understand this, we can go ahead and start translating the mathematical models into computer models and then using the computer models to compute something.
1.6. Example 1
 Model
Every year you gain 1 pound
 Mathematical representation:
W(next year) = W(this year) + 1
or
W(next year)  W(this year) = 1
 Do you know how to use iteration to compute your weight over many years?
 We will come back to this later, but this is what we are working towards.
1.7. Example 2
 Model
Every year you lose 1 pound
 Mathematical representation:
W(next year) = W(this year) 1
or
W(next year)  W(this year) = 1
1.8. Example 3
 Model
Every day you lose 1 pound
 Mathematical representation:
W(next day) = W(today)  1
or
W(next day)  W(today) = 1
1.9. Example 4
 Model
Every year your weight increases by 10%
 Mathematical representation:
W(next year) = W(this year) + (0.1)*W(this year)
or
W(next year)  W(this year) = (0.1)*W(this year)
1.10. Example 5
 Model
Every year your weight increases by 10% plus 1 pound
 Mathematical representation:
W(next year)  W(this year) = (0.1)*W(this year) + 1
1.11. Example 6
 Model
Every year your weight decreases by 10% plus 1 pound
 Mathematical representation:
W(next year)  W(this year) = (0.1)*W(this year) + 1
1.12. Example 7
 Model
Every year your bank account balance increases by 20%
 Mathematical representation:
B(next year) = B(this year) + (0.2)*B(this year)
or
B(next year)  B(this year) = (0.2)*B(this year)
1.13. Example 8
 Model
Every year your bank account balance increases by 20%. Every year you pay a fee of $100 to the bank.
 Mathematical representation:
B(next year)  B(this year) = (0.2)*B(this year)  100
1.14. Example 9
 Model
Every year your bank account balance doubles
 Mathematical representation:
B(next year) = 2*B(this year)
or
B(next year) = B(this year) + B(this year)
or
B(next year)  B(this year) = B(this year)
1.15. Example 10
 Model
Every year the population doubles
 Mathematical representation:
P(next year) = 2*P(this year)
or
P(next year) = P(this year) + P(this year)
or
P(next year)  P(this year) = P(this year)
1.16. Example 11
 Model
The birth rate is 2% per year and nobody dies.
 Mathematical representation:
P(next year) = P(this year) + 0.02*P(this year)
or
P(next year)  P(this year) = 0.02*P(this year)
1.17. Example 12
 Model
The death rate is 1% per year and no babies are born.
 Mathematical representation:
P(next year) = P(this year)  0.01*P(this year)
or
P(next year)  P(this year) = 0.01*P(this year)
1.18. Example 13
 Model
The birth rate per year is 2% and the death rate is 1% per year
 Mathematical representation:
P(next year)  P(this year) = 0.02*P(this year)  0.01*P(this year)
1.19. Example 14
 Model
The birth rate of rabbits is 10%. The death rate or rabbits is 0.02 times the number of rabbits multiplied by the number of foxes.
 Mathematical representation:
R(next year)  R(this year) = 0.10*R(this year)  0.02*R(this year)*F(this year)
1.20. Example 15
 Model
The death rate of foxes is 10%. The birth rate of foxes is 2% of the number of rabbits multiplied by the number of foxes.
 Mathematical representation:
F(next year)  F(this year) = 0.10*F(this year) + 0.02*R(this year)*F(this year)
1.21. Example 16
 Model
The change in the number of people infected with a virus is 0.10 times the number of people infected times the number of people uninfected.
 Mathematical representation:
I(tomorrow)  I(today) = 0.10*I(today)*U(today)
1.22. Analytic Solutions
 Most of the mathematical representations above have Analytic Solutions.
 Roughly, this means that you don't really need iteration to find the answer.
 For example, you could use iteration to figure out your weight 2 years from now given the model
Every year I gain one pound
 Mathematical representation:
W(next year)  W(this year) = 1
or
W(next year) = W(this year) + 1
1.23. Analytic Solutions cont.
Running this program, which is a computational representation of the mathematical model, W(1) = 181; for i = [1,2] W(i+1) = W(i) + 1; end 
gives W(1) = 181 W(2) = 182 W(3) = 183 or W = [181,182,183]; 
 You probably noticed that you did not need iteration to solve this equation.
 You could just say "If I am
181
pounds now, I'll be183
pounds two years from now". In this case you are using the analytic formulaW = 181+N
, whereN
is the number of years from now.  Therefore, the stated mathematical model has an analytic solution and we can plug numbers into a single formula to get an answer.
 Most science models do not have an analytic solution and iteration is required to get an answer.
2. Problems
2.1. Mathematical Representation
Write a mathematical representation of the following. Use the symbol T
to represent temperature.
The temperature of an object doubles every minute.
2.2. Mathematical Representation
Write a mathematical representation of the following. Use the symbol T
to represent temperature.
The temperature of an object decreases by a factor of two every minute.
2.3. Mathematical Representation
Write a mathematical representation of the following. Use the symbol I
to indicate the number of infected people and U
for uninfected.
The change in the number of people infected with a virus is 0.10 times the number of people infected times the number of people uninfected.
2.4. Interest
Suppose that you deposit $1000 in your account at the end of each year and that you started with $100 at the start of the first year.
Would you rather use a bank that offered 5% interest per year computed using:
B(next year) = B(this year) + 0.05*B(this year) + 1000
or a bank that offered (5/12) percent interest per month computed using:
B(next month) = B(this month) + (0.05/12)*B(this month) + 1000/12
where next month/year
is read as "at the start of next month/year" and this
is read as "at the end of this month/year".
Answer the following using only a pencil, paper, and a calculator.
 For the first equation, write down the balance at the start of years one, two, and three.
 For the second equation, write down the balance at the start of the the start of each month up to an including month 25.
Write a computer program the does the above calculations. For both questions, a for
loop must be used. Copy your code into your wiki page.
Answer  

Handwritten part. year 1 B(year 1) = 100 year 2 B(year 2) = 100 + 0.05*B(year 1) + 1000 = 100 + 0.05*100 + 1000 = 1105 year 3 B(year 3) = 1105 + 0.05*B(year 2) + 1000 = 1105 + 0.05*1105 + 1000 = 2160.25 Computer program part.
Handwritten part. month 1 B = 100 month 2 B = 100 + (0.05/12)*100 + 1000/12 = 183.3375 (Note  it is ''not'' correct to take 183.3375 and multiply it by 12! You must work out every iteration.) month 3 B = 183.3375 + (0.05/12)*183.3375 + 1000/12 = 267.4347 ... month 25 B = 2117.1659 + 2117.1659*(2117.16598644552) + 1000/12 = 2209.32 Computer program part. B(1) = 100 for i = 1:24 B(i+1) = B(i) + (0.05/12)*B(i) + 1000/12 end % Show all values B % Show last value B(25) Note  the for loop approach should give the same answer as your hand calculation. Also note that the start of year 3 corresponds to month 25 which you computed. This option gives a larger value ($2209.32) than the first option ($2160.25). Therefore, the second equation will result in more money in the account. 
2.5. Population Eqn.
Consider the equations
P(next year) = P(this year) + 0.01*P(this year)
P(next month) = P(this month) + (1/12)*0.01*P(this month)
Assume the initial population is 100.
 Write a program that uses the first equation to compute the population in year 10 and prints out its value.
 Write a program that uses the second equation to compute the population in the first month of year 10 and prints out its value.
 Write a program that uses the second equation to compute the population in the last month of year 10 and prints out its value.
When your solutions for each of the above are copied onto the command line, only the requested value must be printed. As an example, the following program prints out only the last value of an array created using a for
loop:
for i = [1:5] A(i) = i; end A(5)
Answer 

Note  only need to go till i = 9 to compute value in year 10. if you changed for i = [1:9] to for i = [1:10] and left everything else the same, you would get the correct answer, but you would have done an extra calculation that was not needed. clear; P(1) = 100; for i = [1:9] P(i+1) = P(i) + 0.01*P(i); end P(10) = 109.36 % 9 years x 12 months = 108. clear; P(1) = 100; for i = [1:108] P(i+1) = P(i) + (0.01/12)*P(i); end % Month 109 is first month of year 10 P(109) = 109.41 % 108 + 11 = 119 clear; P(1) = 100; for i = [1:118] P(i+1) = P(i) + (0.01/12)*P(i); end % Month 119 is last month of year 10 P(119) = 110.33 
2.6. Population Growth
Consider the following model of population
Every year, population increases a value of 10% of the population in the previous year. However, if the predicted population is over 100, a disease outbreak instantly kills 80% of this predicted population value. For example, if the predicted population is 110, then the next year the population is 0.2*110.
 Write a program that computes the population over a 40year time span. Assume that the initial population is 20. (Hint: you can do this using an
if
statement.)
Answer 

clear; P(1) = 20; for i = [1:39] P(i+1) = P(i) + 0.01*P(i); if (P(i+1) > 100) P(i+1) = 0.2*P(i+1); end end plot(P) xlabel('Year') ylabel('Population')

3. Activities
3.1. Interest
Suppose that you deposit $1000 in your account end of each year and that you started with $100 at the start of the first year.
Would you rather have a bank that offered 5% interest per year like this:
B(next year) = B(this year) + 0.05*B(this year) + 1000
or a bank that offered (5/12) percent interest per month like this:
B(next month) = B(this month) + (0.05/12)*B(this month) + 1000/12
Answer the following without using a computer program (work it out using pencil, paper, and a calculator). Turn in your work on a sheet of paper at the start of class (or post an image of your work take with a digital camera or scanner).
 For the first equation, write down the balance at the start of year one and year two.
 For the second equation, write down the balance at the start of the the start of each month up to an including month 25.
3.2. Population Growth
Consider a science model of the population of dogs on an island:
The change in dog population (number of new puppies) from this year to the next is equal to the number of dogs that exist this year.
 Plot population versus time for 6 years on a piece of paper (draw grid lines). Make one square width = one year. Assume that the initial population is 10 dogs.
 The leader of the dog island declares that if the population is greater than 100 at the start of a year, then no more births are allowed during that year and 1/10th of the dogs must be "put down" at the end of that year. Plot (draw grid lines) the population for 10 years assuming the initial population was 10.
4. References
 An article on mathematical models [1]: "A mathematical model is an abstract model that uses mathematical language to describe the behaviour of a system."
 Some places define a computational model to be the same thing as a mathematical model: "A computational model is a mathematical model in computational science that requires extensive computational resources to study the behavior of a complex system by computer simulation." [2]. The distinction that I make is that a science model must be translated to a mathematical representation (equations) which then needs to be translated into a computer representation (a program). Computer programs can only approximate the solution to a mathematical representation. A mathematical representation is often an approximation to the science representation.
 On the importance of being able to translate a statement into equations [3]