Skip to content

Repository files navigation

Numerical Computing

Numerical Computing (CS-2008) · FAST-NUCES · BS Computer Science

My Numerical Computing course work – nine lectures with Jupyter notebooks, Python assignments, exams, quizzes, study notes and an HPCG optimisation project.

Course: Numerical Computing FAST-NUCES CS-2008 Python: NumPy, SciPy Jupyter: Notebooks Website


Live Links

What Link
Repository https://github.com/rohaan2802/Numerical_Repo
Website (GitHub Pages) https://rohaan2802.github.io/Numerical_Repo/
Releases page https://github.com/rohaan2802/Numerical_Repo/releases
Release v1.0 https://github.com/rohaan2802/Numerical_Repo/releases/tag/v1.0
Download: Computational Mathematics textbook (~130 MB) https://github.com/rohaan2802/Numerical_Repo/releases/download/v1.0/Computational.Mathematics.-.An.introduction.to.Numerical.Analysis.and.Scientific.Computing.with.Python.pdf
Download whole repository (ZIP) https://github.com/rohaan2802/Numerical_Repo/archive/refs/heads/main.zip

Table of Contents


Course Overview

Numerical Computing (CS-2008) at FAST-NUCES Islamabad. The repository has nine lecture sets with their Python notebooks, assignments and a home task in Python, sessional exams, quizzes, the HPCG final project, supporting material and my study notes.

Topics Covered

Unit Topics
Unit 1 – Errors Number representation, floating-point arithmetic, round-off, truncation and catastrophic cancellation.
Unit 2 – Roots & interpolation Bisection, fixed-point, Newton and secant methods; Lagrange, Newton, Hermite, splines and least squares.
Unit 3 – Calculus & ODEs Numerical differentiation and integration, Euler and Runge–Kutta methods for initial value problems.
Unit 4 – Linear algebra Gaussian elimination, LU, iterative solvers, Gram–Schmidt, QR and SVD; HPCG project.

Repository at a Glance

Item Count
Lectures 9
Jupyter notebooks 9
Python files 3
Study notes (Markdown) 3
PDF documents 36
Screenshots 30
Files in total 61

Lectures

Lecture Topic Covers
01 Computer arithmetic and sources of error Fixed and floating point, IEEE 754, machine epsilon, round-off and truncation error
02 Catastrophic cancellation Loss of significance when subtracting nearly equal numbers, and how to rewrite formulas
03 Roots of equations Bisection, fixed-point iteration, Newton–Raphson and secant methods, with a Python notebook
04 Interpolation and approximation Linear, quadratic, Lagrange and Newton interpolation, least squares, splines
05 Numerical integration Rectangle, midpoint, trapezoidal and Simpson rules, Newton–Cotes, Richardson extrapolation
06 Numerical differentiation and ODEs Finite differences, Euler, improved Euler and Runge–Kutta methods
07 Systems of linear equations Gaussian elimination, LU factorisation, pivoting, iterative methods
08 Approximations and QR decomposition Gram–Schmidt process, QR, SVD and low-rank approximation (slides, notebook, video)
09 Python basics Python, NumPy and Matplotlib refresher notebook

Assignments, Exams and Project

Item Folder Contents
A1 Assignment 1 Root-finding methods compared for accuracy and time (Jupyter notebook)
A2 Assignment 2 Interpolation – statement, my report and interpolation.py
A3 Assignment 3 Python solution (Visual Studio Python project)
HT Home task Python home task (Visual Studio Python project)
E Exams Sessional I and II papers, the S2 solution and sample answer sheets
Q Quizzes Quiz 0–6 papers and solutions
P Final project HPCG kernel optimisation project: brief, rubric and setup guide

Books and Notes

Folder Contents
Study notes Bit shifting, and maps in C++ and Python
Supporting material Interpolation notebook, integration notes, worked examples and a video
Textbooks Numerical Methods for Engineers and a Python programming link

Large Files

GitHub does not accept files over 100 MB, so this textbook is attached to Release v1.0 instead of the repository:

File Size
Computational Mathematics – An Introduction to Numerical Analysis and Scientific Computing with Python (PDF) 136 MB

Folder Structure

Numerical_Repo/
├── Assignments/
│   ├── Assignment_01/                    (2 files)
│   ├── Assignment_02/                    (5 files)
│   └── Assignment_03/                    (3 files)
├── Books/                                (2 files)
├── Exams/                                (6 files)
├── HomeTask/                             (3 files)
├── Lecture #01/                          (1 file)
├── Lecture #02/                          (1 file)
├── Lecture #03/                          (3 files)
├── Lecture #04/                          (4 files)
├── Lecture #05/                          (2 files)
├── Lecture #06/                          (3 files)
├── Lecture #07/                          (2 files)
├── Lecture #08/                          (4 files)
├── Lecture #09/                          (1 file)
├── NC_Final_Project/                     (3 files)
├── Notes/                                (2 files)
│   └── Supporting Material/              (7 files)
├── Quiz & Sessional/                     (7 files)
├── assets/
│   ├── screenshots/   30 images
│   ├── thumbs/        gallery previews
│   └── css/  js/      website
├── index.html
├── .gitattributes
├── .gitignore
├── .nojekyll
├── LICENSE
└── README.md

Screenshots

1. Repository Folder Structure

Repository Folder Structure

2. Lecture 1 – Fixed-Point vs Floating-Point Storage

Lecture 1 – Fixed-Point vs Floating-Point Storage

3. Lecture 2 – Catastrophic Cancellation: (1 − cos x)/x² vs 2 sin²(x/2)/x²

Lecture 2 – Catastrophic Cancellation: (1 − cos x)/x² vs 2 sin²(x/2)/x²

4. Lecture 3 – The Bisection Method

Lecture 3 – The Bisection Method

5. Lecture 3 – Bisection Root of ln(x) + x

Lecture 3 – Bisection Root of ln(x) + x

6. Lecture 3 – Fixed-Point Iteration with g(x) = √(x + 1)

Lecture 3 – Fixed-Point Iteration with g(x) = √(x + 1)

7. Lecture 3 – Fixed-Point Iteration with g(x) = 1 + 1/x

Lecture 3 – Fixed-Point Iteration with g(x) = 1 + 1/x

8. Assignment 1 – Accuracy vs Time of Root-Finding Methods

Assignment 1 – Accuracy vs Time of Root-Finding Methods

9. Lecture 4 – Quadratic Interpolation

Lecture 4 – Quadratic Interpolation

10. Lagrange Interpolating Polynomial

Lagrange Interpolating Polynomial

11. Interpolation of Runge's Function (Runge Phenomenon)

Interpolation of Runge's Function (Runge Phenomenon)

12. Newton Divided-Difference Interpolation

Newton Divided-Difference Interpolation

13. Hermite Interpolation of Runge's Function

Hermite Interpolation of Runge's Function

14. Clamped Cubic Spline

Clamped Cubic Spline

15. Lecture 4 – Least-Squares Line Fit

Lecture 4 – Least-Squares Line Fit

16. Lecture 4 – Least-Squares Quadratic Fit

Lecture 4 – Least-Squares Quadratic Fit

17. Lecture 4 – Interpolation with scipy.interpolate

Lecture 4 – Interpolation with scipy.interpolate

18. Lecture 4 – Spline vs Polynomial on Runge's Example

Lecture 4 – Spline vs Polynomial on Runge's Example

19. Lecture 4 – Two-Dimensional Interpolation Surface

Lecture 4 – Two-Dimensional Interpolation Surface

20. Lecture 5 – The Trapezoidal Rule

Lecture 5 – The Trapezoidal Rule

21. Lecture 6 – Euler Method

Lecture 6 – Euler Method

22. Lecture 6 – Euler Method vs Exact Solution

Lecture 6 – Euler Method vs Exact Solution

23. Lecture 6 – Improved Euler (Heun) Method

Lecture 6 – Improved Euler (Heun) Method

24. Lecture 6 – Instability of Euler's Method

Lecture 6 – Instability of Euler's Method

25. Lecture 6 – Solving an IVP with scipy solve_ivp

Lecture 6 – Solving an IVP with scipy solve_ivp

26. Lecture 6 – SIR Epidemic Model

Lecture 6 – SIR Epidemic Model

27. Lecture 6 – Fourth-Order Runge–Kutta

Lecture 6 – Fourth-Order Runge–Kutta

28. Lecture 7 – Graphical Solution of Two Linear Equations

Lecture 7 – Graphical Solution of Two Linear Equations

29. Lecture 7 – Structure of a Sparse Matrix

Lecture 7 – Structure of a Sparse Matrix

30. Lecture 8 – Low-Rank SVD Approximations of an Image

Lecture 8 – Low-Rank SVD Approximations of an Image

Running the Code

git clone https://github.com/rohaan2802/Numerical_Repo.git
cd Numerical_Repo
pip install numpy scipy matplotlib jupyter
  • Jupyter notebooks (.ipynb): run jupyter notebook (or open them in VS Code or Google Colab) and run the cells from the top. GitHub also shows them, with their plots, in the browser.
  • Python scripts: run them directly, for example python "Assignments/Assignment_02/interpolation.py" or python HomeTask/HomeTask.py.
  • Visual Studio: Assignment_03.sln and HomeTask.sln open the same scripts as Python projects in Visual Studio with the Python workload installed.
  • Final project: follow HPCG-Project-Setup-Guide.md to build and run the HPCG benchmark under WSL.

License

Lecture slides, assignment, quiz and exam papers and textbooks belong to their instructors at FAST-NUCES and to their authors and publishers. They are shared here only for learning and revision. My own solutions, notes, code and the way this repository is organised are free to use for study. See LICENSE.

Author

Mohammad Rohaan – BS Computer Science, FAST-NUCES

If this helped you with Numerical Computing, a ⭐ on the repository is appreciated.

Releases

Packages

Contributors

Languages