Maths with Python Documentation - Read the Docs
Maths with Python Documentation
Release 1.0 Mathematical Sciences, University of Southampton
Oct 13, 2016
Contents
1 First Steps
3
1.1 First steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.2 How to use these notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.3 Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.4 Spyder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.5 Reading list . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.6 Versions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2 Python Basics
9
2.1 Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.2 Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.3 Exercise: Variables and assignment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3 Programs
19
3.1 Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
3.2 Using programs and modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
3.3 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
3.4 Printing and strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
3.5 Putting it together . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
3.6 Exercise: basic functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
3.7 Exercise: Floating point numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
4 Loops - how to repeat yourself
33
4.1 Loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
4.2 Containers and Sequences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
4.3 Control flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
4.4 Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
4.5 Exercise: Prime numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
5 Basic Plotting
49
5.1 Plotting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
5.2 Exercise: Logistic map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
6 Classes and objects
55
6.1 Classes and Object Oriented Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
6.2 Exercise: Equivalence classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
7 Scientific Python
61
7.1 Scientific Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
i
7.2 numpy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 7.3 Plotting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 7.4 scipy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 7.5 Exercise: Lorenz attractor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 7.6 Exercise: Mandelbrot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83 7.7 Exercise: The shortest published Mathematical paper . . . . . . . . . . . . . . . . . . . . . . . . . . 84
8 Symbolic Python
87
8.1 Symbolic Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
8.2 sympy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
8.3 Further reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
8.4 Exercise : systematic ODE solving . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
9 Statistics
99
9.1 Statistics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
9.2 Getting data in . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
9.3 Basic statistical functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
9.4 Categorical data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
9.5 Regression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
9.6 Random numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
9.7 Exercise: Anscombe's quartet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
10 Exceptions and Testing
111
10.1 Exceptions and Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
10.2 Exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
10.3 Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
11 Iterators and Generators
127
11.1 Iterators and Generators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
11.2 Exercise : twin primes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
11.3 Exercise : a basis for the polynomials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
12 Classes and OOP
133
12.1 Classes and Object Oriented Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
12.2 Exercise: Equivalence classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
12.3 Exercise: Rational numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
13 Indices and tables
141
ii
Maths with Python Documentation, Release 1.0
This is material for an introductory Python course for first year undergraduate Mathematics students at the University of Southampton.
Contents
1
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- maths with python documentation read the docs
- chapter 10 introduction to numpy and scipy
- using and creating a new python 3 9 virtual environment under miniconda
- bluehive cheat sheet i connect to bluehive via terminal terminal
- introduction to anaconda yale university
- use python with r with reticulate cheat sheet github
- python control documentation eth zürich
- composable multi threading for python libraries scipy
- installing numpy scipy opencv theano for python in vs
- parallel computing in python using mpi4py yale university
Related searches
- opencv python documentation pdf
- python documentation in code
- python documentation for the len
- python documentation f string
- python documentation string
- python documentation string formatting
- python documentation for the len function
- python documentation best practice
- python documentation format
- python documentation style
- python documentation guidelines
- python documentation syntax