# Python Programming and Numerical Methods

### A Guide for Engineers and Scientists

### Resources

## Description

## Key Features

- Includes tips, warnings and "try this" features within each chapter to help the reader develop good programming practice
- Summaries at the end of each chapter allow for quick access to important information
- Includes code in Jupyter notebook format that can be directly run online

## Readership

Senior undergraduates or graduate students in engineering and science who are taking a numerical methods course using Python

## Table of Contents

PART 1 INTRODUCTION TO PYTHON PROGRAMMING

CHAPTER 1 Python Basics

1.1 Getting Started With Python

**1.2**Python as a Calculator**1.3**Managing Packages**1.4**Introduction to Jupyter Notebook**1.5**Logical Expressions and Operators**1.6**Summary and ProblemsCHAPTER 2 Variables and Basic Data Structures

**2.1**Variables and Assignment**2.2**Data Structure – String**2.3**Data Structure – List**2.4**Data Structure – Tuple**2.5**Data Structure – Set**2.6**Data Structure – Dictionary**2.7**Introducing Numpy Arrays**2.8**Summary and ProblemsCHAPTER 3 Functions

**3.1**Function Basics**3.2**Local Variables and Global Variables**3.3**Nested Functions**3.4**Lambda Functions**3.5**Functions as Arguments to Functions**3.6**Summary and ProblemsCHAPTER 4 Branching Statements

**4.1**If-Else Statements**4.2**Ternary Operators**4.3**Summary and ProblemsCHAPTER 5 Iteration

**5.1**For-Loops**5.2**While Loops**5.3**Comprehensions**5.4**Summary and ProblemsCHAPTER 6 Recursion

**6.1**Recursive Functions**6.2**Divide-and-Conquer**6.3**Summary and ProblemsCHAPTER 7 Object-Oriented Programming

**7.1**Introduction to OOP**7.2**Class and Object**7.3**Inheritance, Encapsulation, and Polymorphism**7.4**Summary and Problems**CHAPTER 8 Complexity**Complexity and Big-ONotation

8.1**8.2**Complexity Matters**8.3**The Profiler**8.4**Summary and ProblemsCHAPTER 9 Representation of Numbers

**9.1**Base-N and Binary**9.2**Floating Point Numbers**9.3**Round-Off Errors**9.4**Summary and ProblemsCHAPTER 10 Errors, Good Programming Practices, and Debugging

**10.1**Error Types**10.2**Avoiding Errors**10.3**Try/Except**10.4**Type Checking**10.5**Debugging**10.6**Summary and ProblemsCHAPTER 11 Reading and Writing Data

**11.1**TXT Files**11.2**CSVFiles**11.3**Pickle Files**11.4**JSONFiles**11.5**HDF5 Files**11.6**Summary and ProblemsCHAPTER 12 Visualization and Plotting

**12.1**2D Plotting**12.2**3D Plotting**12.3**Working With Maps**12.4**Animations and Movies**12.5**Summary and ProblemsCHAPTER 13 Parallelize Your Python

**13.1**Parallel Computing Basics**13.2**Multiprocessing**13.3**Using Joblib**13.4**Summary and ProblemsPART 2 INTRODUCTION TO NUMERICAL METHODS

CHAPTER 14 Linear Algebra and Systems of Linear Equations

**14.1**Basics of Linear Algebra**14.2**Linear Transformations**14.3**Systems of Linear Equations**14.4**Solutions to Systems of Linear Equations**14.5**Solving Systems of Linear Equations in Python**14.6**Matrix Inversion**14.7**Summary and ProblemsCHAPTER 15 Eigenvalues and Eigenvectors

**15.1**Eigenvalues and Eigenvectors Problem Statement**15.2**The Power Method**15.3**The QR Method**15.4**Eigenvalues and Eigenvectors in Python**15.5**Summary and ProblemsCHAPTER 16 Least Squares Regression

**16.1**Least Squares Regression Problem Statement**16.2**Least Squares Regression Derivation (Linear Algebra)**16.3**Least Squares Regression Derivation (Multivariate Calculus)**16.4**Least Squares Regression in Python**16.5**Least Squares Regression for Nonlinear Functions**16.6**Summary and ProblemsCHAPTER 17 Interpolation

**17.1**Interpolation Problem Statement**17.2**Linear Interpolation**17.3**Cubic Spline Interpolation**17.4**Lagrange Polynomial Interpolation**17.5**Newton’s Polynomial Interpolation**17.6**Summary and Problems**CHAPTER 18 Taylor Series**Expressing Functions Using a Taylor Series

18.1**18.2**Approximations Using Taylor Series**18.3**Discussion About Errors**18.4**Summary and Problems**CHAPTER 19 Root Finding**Root Finding Problem Statement

19.1**19.2**Tolerance**19.3**Bisection Method**19.4**Newton–Raphson Method**19.5**Root Finding in Python**19.6**Summary and ProblemsCHAPTER 20 Numerical Differentiation

**20.1**Numerical Differentiation Problem Statement**20.2**Using Finite Difference to Approximate Derivatives**20.3**Approximating of Higher Order Derivatives**20.4**Numerical Differentiation With Noise**20.5**Summary and Problems**CHAPTER 21 Numerical Integration**Numerical Integration Problem Statement

21.1**21.2**Riemann Integral**21.3**Trapezoid Rule**21.4**Simpson’s Rule**21.5**Computing Integrals in Python**21.6**Summary and ProblemsCHAPTER 22 Ordinary Differential Equations (ODEs) Initial-Value Problems

**22.1**ODE Initial Value Problem Statement**22.2**Reduction of Order**22.3**The Euler Method**22.4**Numerical Error and Instability**22.5**Predictor–Corrector and Runge–Kutta Methods**22.6**Python ODE Solvers**22.7**Advanced Topics**22.8**Summary and ProblemsCHAPTER 23 Boundary-Value Problems for Ordinary Differential Equations (ODEs)

**23.1**ODE Boundary Value Problem Statement**23.2**The Shooting Method**23.3**The Finite Difference Method**23.4**Numerical Error and Instability**23.5**Summary and Problems**CHAPTER 24 Fourier Transform**The Basics of Waves

24.1**24.2**Discrete Fourier Transform (DFT)**24.3**Fast Fourier Transform (FFT)**24.4**FFT in Python**24.5**Summary and ProblemsAppendix A Getting Started With Python in Windows

Index

## Product details

- No. of pages: 480
- Language: English
- Copyright: © Academic Press 2020
- Published: November 27, 2020
- Imprint: Academic Press
- Paperback ISBN: 9780128195499
- eBook ISBN: 9780128195505

## About the Authors

### Qingkai Kong

#### Affiliations and Expertise

### Timmy Siauw

#### Affiliations and Expertise

### Alexandre Bayen

#### Affiliations and Expertise

## Ratings and Reviews

### Latest reviews

(Total rating for all reviews)

**Russell S.**Sun Sep 04 2022**Engineer**I an half way though the book just finished chapter 15. Having worked all the problems I found that some of them are not well developed. Doing them was like putting to gather a puzzle without a picture. You have to visualize what you think the answer should be and if that doesn't work do it again. No big deal but one of the examples inn ch14 section 14.4.4.1 had a typo (-5) when it should have been 10. So far a great book could use a little more descriptions and examples in the linear algebra section, you have to have a linear algebra book.

**Reuben M.**Wed Oct 20 2021**Easy To Follow!**A clear, and concise textbook.

**Dr. B.**Fri Aug 13 2021**Python Programming and Numerical Methods**Since this book is available in Jupyter notebook, it's easier for one to quickly understand and adopt the code for modification.