This section of these pages is intended mainly for the modules 2NP and 2NP3 taken in the School of Mathematics, University of Birmingham, by second year students. It is available here for other students and anyone else that might be interested to look at at their own risk. There is no waranty or guarantee of fitness for any purpose. These notes have been developed rather intensively over a period since 2015. Please keep returning here for more up-to-date versions. In particular answers to various exercises may not be provided here (especially if they are assessed exercises for current students). Current students following these modules will also have a set of pages for assessments and feedback delivered via Canvas. These (non-Canvas) pages are intended to take the place of a "course textbook" to support the learning.
It is assumed here that you have some experience with using a computer and in particular some programming experience, though not necessarily in C or C++. (First years in Mathematics at Birmingham learn the basics of the language Lua. See http://web.mat.bham.ac.uk/R.W.Kaye/year1prog/.) However, if you are careful and methodical you should be able to follow these pages from scratch without prior programming experience.
The syllabus for the module (and objectives for these notes) is as follows.
With the possible exception of some of the algorithms in the last bullet point. this is all material that I would expect any mathematician using a computer will be expected to know. (Some topics here are not even typically taught to computer science students!) The official syllabus for the 2NP module is very full, and (I think) unreasonably so. So the focus of the module will be on the first three bullet points and as many of the "useful algorithms" that we can cover in the time available.
These pages are intended to get you started using C++ for traditional numerical work. For various reasons (speed of execution, available packages, standardised syntax) C++ is a superior language for tranditional mathematical number-crunching to some of the obvious alternatives such as FORTRAN and C. But this kind of traditional work does not require detailed knowledge of some of C++'s best features such as classes and templates and these aspects of C++ are not covered here. A number of other important C++ topics, such as pointers, structs, namespaces and exceptions are also omitted for the same reason. On the other hand we do try to push the reader into good C++ style in preparation for all this other good stuff, and we do not encourage those "dirty shortcuts" from C, as is (sadly) all too common.
Background: admin and other stuff
From register machines to C++
This section is intended to get you started with C++ via a small (and very interesting) machine model for the computer called a register machine. By the end of this section you will have a much clearer idea of what a computer program does, how the computer follows the instructions in the program, how to analyse the time taken by a program, and how numbers are stored in the computer. You will also have a very useful start in how to write C++ code.
Programming in C++
This section provides much more detail on C++ and is intended to get you proficient with those parts of C++ that you will need for numerical and related work in mathematics. If you have been following the previous section closely, most of the first few pages here should be mostly revision, and the first important new material starts with functions.
C++ reference and further comments
This section provides much more detail on C++ and is intended to provide some reference for specific aspects of the language.
Introduction to numerical work in C++
This section provides much more detail on C++ and is intended to get you proficient with those parts of C++ that you will need for numerical and related work in mathematics.
Some miniprojects
This section provides information on some longer examples and interesting C++ miniprojects
All code and content here may be copied as often as you like under the terms of the GNU General Public Licence and/or the GNU Free Documentation Licence. (In reading these texts, the words "licence" and "license" are to be taken to be synonymous.) This means that any derivative work, if distributed further and not for your own private use, MUST be issued with a similar licence.
All content is copyright by Richard Kaye, http://web.mat.bham.ac.uk/R.W.Kaye/ 2018.