Toggle navigation sidebar
Toggle in-page Table of Contents
M24568 and M20741 Intro to CompSMAP
Welcome to Computational Mathematics and Introduction to Computational Physics!
Lecture 1: Introduction
A quick look at the Colab/Jupyter interface
Getting started - Python objects, basic types, and variables
INTERACTIVE: Checking object types in Python
INTERACTIVE: Checking object types in Python - SOLVED
Python Main Operators
Arithmetic Operators - Interactive exercises
Arithmetic Operators - Interactive exercises - SOLVED
Operations with different types
Variables - an interactive introduction
Variables - an interactive introduction - SOLVED
Swapping Variables
Comparison operators - interactively introduced
The string type - interactive
The string type - interactive - SOLVED
Type Conversion - A quick interactive intro
Type Conversion - A quick interactive intro - SOLVED
Errors
Summary
Summary exercises
Summary exercises - SOLVED
Lecture 2: Functions, Logic and Conditionals
Functions - An overview
Using (or “calling”) a function - Interactive
Using (or “calling”) a function - Interactive - SOLVED
How to write your own function
Writing Functions - Exercises
Writing Functions - Exercises - SOLVED
Writing functions with multiple inputs and outputs
Writing functions with multiple inputs and outputs - SOLVED
Importing a function
The most common reasons people use functions wrong and don’t pass coursework questions
Logical operators
Logical Operators - Exercises
Logical Operators - Exercises - SOLVED
Conditional statements
Conditionals - Exercises
Conditionals - Exercises - SOLVED
Summary
End of class exercises
End of class exercises - SOLVED
Lecture 3: Loops and lists
Loops and lists: an overview
Using a for loop: interactive
Using a for loop: interactive - SOLVED
For loops: exercises
For loops: exercises - SOLVED
The while loop: interactive
The while loop: interactive - SOLVED
Writing sums as functions: INTERACTIVE
Writing sums as functions: INTERACTIVE - SOLVED
Lists (interactive)
Lists (interactive) - SOLVED
Lists: exercises
Lists: exercises - SOLVED
Indices and ordering: INTERACTIVE
Indices and ordering: INTERACTIVE - SOLVED
Lists: some other list operations
Lists: some other list operations - SOLVED
Summary exercises
Summary exercises - SOLVED
Lecture 4: Data types
The File object: A brief introduction
The File object: A brief introduction - SOLVED
Introducing tuples, sets and dictionaries
Introducing tuples, sets and dictionaries - SOLVED
Further exercises on sets, tuples and dictionaries
Further exercises on sets, tuples and dictionaries - SOLVED
Challenge exercises
Challenge exercises - SOLVED
Additional resources
Lecture 5: Numpy
Introduction
Introduction - SOLVED
How to create basic arrays
How to create basic arrays - SOLVED
Basic array operations
Basic array operations - SOLVED
Indexing and Slicing
Indexing and Slicing - SOLVED
Iterating over an numpy array
Iterating over an numpy array - SOLVED
Sorting, adding and removing elements from an array
Sorting, adding and removing elements from an array - SOLVED
Broadcasting
Broadcasting - SOLVED
Using a particular axis of an array
Using particular axis of an array - SOLVED
Summary Exercises
Summary Exercises - SOLVED
Lecture 6: Visualisation
Introduction to plotting in matplotlib
Introduction to plotting in matplotlib - SOLVED
Part 2: Making a nice-looking, well-labelled plot
Part 2: Making a nice-looking, well-labelled plot- SOLVED
Scatter plots
Scatter plots- SOLVED
Histograms
Histograms- Solved
Adding Interactive Elements: Sliders
Adding Interactive Elements: Sliders - SOLVED
Challenge exercises
Challenge exercises - SOLVED
Lecture 7: Understanding and fixing problems in python code
Introduction
Using PDB to debug code
Exercise 1: Syntax errors
Exercise 1: Syntax errors - SOLVED
Exercise 2 - Short failing examples
Exercise 2 - Short failing examples - SOLVED
Exercise 3 - Variable Scope
Exercise 3 - Variable Scope - SOLVED
Exercises 4 - 6
Exercises 4 - 6 - SOLVED
Exercises 7 to 9
Exercises 7 to 9 - SOLVED
Acknowledgements
Lecture 8: Data manipulation (with pandas)
Introduction
Introduction - SOLVED
Part 1: data frames (extra powerful dictionaries)
Part 1: data frames (extra powerful dictionaries) - SOLVED
Part 2: viewing data
Part 2: viewing data
Part 3: selecting elements from a data frame
Part 3: selecting elements from a data frame - SOLVED
Part 4: More operations on DataFrames
Part 4: More operations on DataFrames - SOLVED
Parts 5 and 6: grouping and visualising data
Parts 5 and 6: grouping and visualising data - SOLVED
Part 7: Importing and exporting files / spreadsheets
Part 7: Importing and exporting files / spreadsheets - SOLVED
Part 8: Summary exercises
Part 8: Summary exercises - SOLVED
Lecture 9: Root finding
What is root finding and why do it on a computer?
Continuous functions
Continuous functions - SOLUTIONS
Bolzano’s Theorem
Bolzano’s Theorem - SOLUTIONS
Writing a root finding algorithm using the bisection method
Writing a root finding algorithm using the bisection method - SOLUTIONS
Newton’s Method
Newton’s Method - SOLUTIONS
Lecture 10: Numerical Integration
Introduction
The rectangle rule
The rectangle rule - SOLVED
The Trapezium rule
Trapezium rule and Simpson’s rule - Solutions
Simpson’s rule
APPENDIX
repository
open issue
Index