fib - Department of Computer Science

Download Report

Transcript fib - Department of Computer Science

Mathematical Sciences at
Oxford
Stephen Drape
Who am I?
Dr Stephen Drape
Access and Schools Liaison Officer for Computer Science
(Also a Departmental Lecturer)
9 years at Oxford (3 years Maths degree, 4 years
Computer Science graduate, 2 years lecturer)
5 years as Secondary School Teacher
Email: [email protected]
2
Four myths about Oxford




There’s little chance of getting in
It’s very expensive in Oxford
College choice is very important
You have to be very bright
3
Myth 1: Little chance of getting in

False!

Statistically: you have around 20% chance
Admissions data for 2009 entry:
Applications
Acceptances
%
Comp Sci
126
23
18.3%
Maths & CS
78
22
28.2%
Maths
917
180
19.6%
Maths & Stats
166
28
16.9%
Physics
765
183
23.9%
Chemistry
474
201
42.4%
4
Myth 2: It’s very expensive

False!
Most colleges provide cheap accommodation for
three years.
 College libraries and dining halls also help you save
money.
 Increasingly, bursaries help students from poorer
backgrounds.
 Most colleges and departments are very close to
the city centre – low transport costs!

5
Myth 3: College Choice Matters

False!
If the college you choose is unable to offer you a
place because of space constraints, they will pass
your application on to a second, computerallocated college.
 Application loads are intelligently redistributed in
this way.
 Lectures are given centrally by the department as
are many classes for courses in later years.

6
Myth 3: College Choice Matters

However…
Choose a college that you like as you have to live
and work there for 3 or 4 years
 Look at accommodation & facilities offered.
 Choose a college that has a tutor in your subject.

7
Myth 4: You have to be bright

True!
We find it takes special qualities to benefit from the
kind of teaching we provide.
 So we are looking for the very best in ability and
motivation.
 A typical offer is 3 A grades at A-Level

8
Mathematical Science Subjects




Mathematics
Mathematics and Statistics
Computer Science
Mathematics and Computer Science
All courses can be 3 or 4 years
9
Maths in other subjects
For admissions, A-Level Maths is mentioned as a
preparation for a number of courses:
 Essential: Computer Science, Engineering Science,
Engineering, Economics & Management (EEM),
Materials, Economics & Management (MEM),
Materials, Maths, Medicine, Physics
 Desirable/Helpful:
Biochemistry,
Biology,
Chemistry, Economics & Management, Experimental
Psychology, History and Economics, Law, Philosophy ,
Politics & Economics (PPE), Physiological Sciences,
Psychology, Philosophy & Physiology (PPP)
10
Entrance Requirements






Essential: A-Level Mathematics
Recommended: Further Maths or a Science
Note it is not a requirement to have Further
Maths for entry to Oxford
For Computer Science, Further Maths is
perhaps more suitable than Computing or IT
Usual offer is AAA
No offers based on A* as yet
11
First Year Maths Course






Algebra (Group Theory)
Linear Algebra (Vectors, Matrices)
Calculus
Analysis (Behaviour of functions)
Applied Maths (Dynamics, Probability)
Geometry
12
Subsequent Years




The first year consists of compulsory courses
which act as a foundation to build on
The second year starts off with more
compulsory courses
The reminder of the course consists of a
variety of options which become more
specialised
In the fourth year, students have to study 6
courses from a choice of 40
13
Mathematics and Statistics




The first year is the same as for the
Mathematics course
In the second year, there are some
compulsory units on probability and statistics
Options can be chosen from a wide range of
Mathematics courses as well as specialised
Statistics options
Requirement that around half the courses
must be from Statistics options
14
Computer Science

Computer Science


Mathematics and Computer Science


Computer Science firmly based on Mathematics
Closer to a half/half split between CS and Maths
Computer Science is part of the Mathematical
Science faculty because it has a strong
emphasis on theory
15
Some of the first year CS courses








Functional Programming
Design and Analysis of Algorithms
Imperative Programming
Digital Hardware
Calculus
Linear Algebra
Logic and Proof
Discrete Maths
16
Subsequent Years




The second year is a combination of
compulsory courses and options
Many courses have a practical component
Later years have a greater choice of courses
Third and Fourth year students have to
complete a project
17
Some Computer Science Options








Compilers
Programming Languages
Computer Graphics
Computer Architecture
Intelligent Systems
Machine Learning
Lambda Calculus
Computer Security








Category Theory
Computer Animation
Linguistics
Domain Theory
Program Analysis
Information Retrieval
Bioinformatics
Formal Verification
18
Useful Sources of Information

Admissions:


Mathematical Institute


http://www.maths.ox.ac.uk/
Computing Laboratory:


http://www.admissions.ox.ac.uk/
http://www.comlab.ox.ac.uk/
Colleges
19
What is Computer Science?




It’s not just about learning new programming
languages.
It is about understanding why programs work,
and how to design them.
If you know how programs work then you can
use a variety of languages.
It is the study of the Mathematics behind lots
of different computing concepts.
20
Simple Design Methodology





Try a simple version first
Produce some test cases
Prove it correct
Consider efficiency (time taken and space
needed)
Make improvements (called refinements)
21
Fibonacci Numbers
The first 10 Fibonacci numbers (from 1) are:
1,1,2,3,5,8,13,21,34,55
The Fibonacci numbers occurs in nature, for
example: plant structures, population numbers.
Named after Leonardo of Pisa
who was nicked named “Fibonacci”
22
The rule for Fibonacci
The next number in the sequence is worked out
by adding the previous two terms.
1,1,2,3,5,8,13,21,34,55
The next numbers are therefore
34 + 55 = 89
55 + 89 = 144
23
Using algebra
To work out the nth Fibonacci number, which
we’ll call fib(n), we have the rule:
fib(n) = fib(n – 1) + fib(n – 2)
We also need base cases:
fib(0) = 0
fib(1) = 1
This sequence is defined using previous terms
of the sequence – it is an example of a
recursive definition.
24
Properties
The sequence has a relationship with the
Golden Ratio
Fibonacci numbers have a variety of properties
such as
 fib(5n) is always a multiple of 5
 in fact, fib(a£b) is always a multiple of fib(a)
and fib(b)
25
Writing a computer program
Using a language called Haskell, we can write
the following function:
> fib(0) = 0
> fib(1) = 1
> fib(n) = fib(n-1) + fib(n-2)
which looks very similar to our algebraic
definition
26
Working out an example
Suppose we want to find fib(5)
27
Our program would do this…
28
What’s happening?
The program blindly follows the definition of fib,
not remembering any of the other values.
So, for
(fib(3) + fib(2)) + fib(3)
the calculation for fib(3) is worked out twice.
The number of steps needed to work out fib(n)
is proportional to n – it takes exponential time.
29
Refinements
Why this program is so inefficient is because at
each step we have two occurrences of fib
(termed recursive calls).
When working out the Fibonacci sequence, we
should keep track of previous values of fib and
make sure that we only have one occurrence of
the function at each stage.
30
Writing the new definition
We define
> fibtwo(0) = (0,1)
> fibtwo(n) = (b,a+b)
>
where (a,b) =
fibtwo(n-1)
> newfib(n) = fst(fibtwo(n))
The function fst means take the first number
31
Explanation
The function fibtwo actually works out:
fibtwo(n) = (fib(n), fib(n +1))
We have used a technique called tupling –
which allows us to keep extra results at each
stage of a calculation.
This version is much more efficient that the
previous one (it is linear time).
32
An example of the new function
33
Algorithm Design
When designing algorithms, we have to consider a
number of things:
 Our algorithm should be efficient – that is, where
possible, it should not take too long or use too
much memory.
 We should look at ways of improving existing
algorithms.
 We may have to try a number of different
approaches and techniques.
 We should make sure that our algorithms are
correct.
34
35