Programming Exercise
Programming Exercise
09 Numerical Methods 1
Programming exercise
Instructions to candidates
Answering questions
Each question consists of instructions for a piece of Python code which you are to write.
In each case, the question will specify both the algorithm to be employed and the interface
you are to write. Marks will be awarded for all of the following:
3. Quality of commenting. The comments should be such that another NM1 student
would understand the code without difficulty.
4. Logical structure of code: does the sequence of statements in the code must make
logical sense.
Time limit
You may work on the problems until 1700 if you wish, however the programming exercise
should take much less time than this.
You must submit your answer by uploading a .tar or .zip archive to ESESIS. This archive
must contain all of the files containing your answers. I suggest you create a new folder
in your home directory for this exercise. From your home directory, you can then use a
command like:
1
tar cfvz answers.tgz dir_name
This creates the archive answers.tgz for you to upload. Of course you should use the
name of your directory, not dir_name. To double check the archive before you upload it,
type:
This will list all the files in your archive for you to check.
Allowed materials
This is an open book exercise. You may use the course text, lecture notes, your own notes
and any other written material which you choose.
Network access
You may use the web to, for example, access Python documentation. However, you
may not use any communication protocol including, but not limited to, email, any chat
program, posting on internet fora, or social network sites. In essence you may use the web
as a reference but you may not use it to communicate with anyone during the exercise.
You must ensure that any communication programmes are shut down for the duration of
the exercise.
Violation of this rule is cheating and may constitute an examination offence under college
rules with very serious consequences.
2
1. Create a module function.py which contains a function sin_cos(x) which imple-
ments the following function:
2. The Taylor series for sinpxq evaluated near zero is given by:
8
ÿ x2k`1
sinpxq “ p´1qk
k“0
p2k ` 1q!