CSE 4250: Project #1, Spread of Epidemics

Due: Friday, 22 September 2017

The Task

Suppose everyone in a population of n people is in close contact with α others, chosen at random. If one person is infected with a disease like Ebola and if the disease spreads to all those who are in close contact with an infected person, the total number of infected people will be approximately γ n for large n where γ = 1 - eαγ .

Since αeα = α1γeαγ1 we have γ= 1+ W( α eα ) /α where W( z ) is defined by the equation z = W( z ) e W( z )

[For MathML impaired browsers:]

The function W( z ) is called the Lambert W function. See the Citizendium page on the Lambert W function and there is even a Lambert W poster.

The plot on the left is the Lambert W function, the plot on the right is the the proportion of the population ultimately affected by an epidemic for different values of α .

Input/Output

Read from the standard input stream and write to the standard output stream. (There is no need to open any files.)

The input will consist of several (maybe thousands of) testcases each on a line. Each testcase consists of a pair of numbers n and α separated by at least one space. The integer n is greater than one and less than or equal to a billion. It is the number of people in the population. The real number α is greater than or equal to one and less than n - 1 . It is the expected number of other people a person is in close contact with.

The output is the total number of people (rounded to the nearest whole number) in the population expected to become infected. Output each answer on a line by itself.

For the input:

2345 1.45678
4283  3.2347
the output would be:
  1298
  4088
Read to the end of the standard input stream and have no output other than the numbers. Do not prompt for input. There should be one line (one number) input pair of input numbers.

Test your program. You can use Wolfram alpha (cf. Lambert W Function) to get high precision answers. Like many numeric problems, it is not easy to get accurate answers in all cases.

Fortran

Differences in implementations and in dialects of Fortran are usually non-existant in simple programs like this one. But the program must compile and run with the implementation used in grading:
$ gfortran --version
GNU Fortran (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
The GNU Fortran compiler implements ISO/IEC 1539:1997 (Fortran 95). It also supports the ISO/IEC TR-15581 enhancements to allocatable arrays. GNU Fortran also has partial support for ISO/IEC 1539-1:2004 (Fortran 2003), ISO/IEC 1539-1:2010 (Fortran 2008)

Info about Fortran

Books

Chapman Stephen J. Chapman.
Fortran 90/95 for Scientists and Engineers.
McGraw-Hill, New York, New York, 1997
ISBN 0-07-011938-4.
Gehrke Wilhelm Gehrke.
Fortran 95 Language Guide.
Springer-Verlag, Berlin, Germany, 1996
ISBN 0-387-76062-8.
Metcalf Michael Metcalf and John Ker Reid.
Fortran 90/95 Explained.
Oxford University Press, Oxford, United Kingdom, 1996
ISBN 0-19-851888-9.

Turning it in

You may work in groups of no more than two people. You may not work with the same person on any of the remaining projects. If in a group of two, make sure both names are in the program and turn in the assignment from just one account. By the due date, turn in your source program. At the beginning of your source file include the following header information in comments:

! Author: name1, e-mail address
! Author: name2, e-mail address
! Course: CSE 4250, Fall 2017
! Project: Proj1, Spread of Epidemics
If working in a group, just submit the assignment once; it does not matter who submits.

Turn in the Fortran source code for the program using the submission server. You will need a control code from the submit server in order to submit. After registering the submit server will e-mail the control code to you. Be sure to check your spam folder! The file name to submit must be epidemics.f95 and the project is proj1. Be sure your name is in comments at the beginning of your program as required in the standard header for this class. For your convenience, here is a submission form for this assignment.

submit server
File 1
Control code:
file 1=epidemics.f95
Course=cse4250
Project=proj1