Numerical Methods
Lecture 3
Scientific Computing with Python
Professor Youngwoon Cha
Computer Science and Engineering
Metaverse Convergence, Graduate School
Contents
• Introduction to Python
• Scientific Computing with Python
2
Introduction to Python
3
Programming Environments
• Install Python
• https://www.python.org/downloads/
• Ver. 3.13.x
• Package Manager
– Use ‘PIP’
– Please do not use ‘conda’
Programming Environments
• Install Python
• https://www.python.org/downloads/
• ver. 3.13.x
• IDE
– JupyterLab (or Jupyter Notebook)
– https://jupyter.org/install
Programming Environments
• jupyter lab
• *.ipynb file
• Your code (.ipynb) will be evaluated on
Windows 11
• Introduction to Python
• Refer to [chapter 1] for basics.
• Math operators, Strings, Dictionaries, Lists,
Functions, and Classes
Scientific Computing
with Python
7
Mathematical Objects
• scalar: a single number
• vector : array of scalar (an ordered array of numbers)
• matrix: array of vector (a 2D array of numbers)
• 3d-tensor: array of matrix (n-dimensional arrays)
scalar vector matrix tensor
size: 4 size: 3 x 4 size: 5 x 3 x 4
1 1 2 3 4 1234 1234
111222333444
3456 1 23334445566
3456
1234 8431 3348485454636311
8431
88443311
1234
3456
8431
Matrices
• n X m matrix
• square matrix
• column vector, row vector T
• Matrix equality
• Addition, Scalar multiplication, Matrix multiplication
• Zero, Identity matrix
9
Special Matrices
• Sparce matrices
• Diagonal matrices
• Banded matrices
(tridiagonal matrices)
• Triangular matrices
(lower triangular, upper triangular matrix)
• Transpose matrix
• Symmetric matrices
10
Python Libraries for Scientific Computing
• Math Libraries for Scientific Computing
math, numpy, scipy modules
Data structures and functions specialized for scientific computing
• Drawing Graphs
matplotlib module
11
Numpy Module
• Matrices
12
Numpy Module
• Slicing
13
Numpy Module
• Shapes
14
Numpy Module
• The zero matrix
• The identity matrix
• Matrix transpose
15
Numpy Module
• Matrix addition
• Scalar multiplication
16
Numpy Module
• Matrix multiplication
• Matrix power
17
Numpy Module
• Matrix Inverse
• Determinant
18
Numpy Module
• Linear systems
19
Numpy Module
• Eigenvalues and Eigenvectors
20
Singular Value Decomposition
• A matrix factorization method
21
Singular Value Decomposition
• A matrix factorization method
22
Positive Definite Matrix
• A matrix A is considered positive definite if:
23
MatPlotLib
• Drawing Graphs
24
MatPlotLib
25
MatPlotLib
26
Summary
• Introduction to Python
• Scientific Computing with Python
27
End of Class
E-mail: [email protected]
28