Python Libraries for Scientific Computing NumPy NumPy is a fundamental library that provides the core data structure for numerical computation: the array. - Vectorization : The ability to execute operations on entire NumPy arrays without using explicit Python for loops, which are generally slow. This is considered the "pythonic way of work" and can run on multi-dimensional structures Vectorized vs. Scalar Version: Examples illustrate the speed difference between operations on NumPy arrays (y=np.sin(a)*2) and equivalent scalar operations using loops Conditional Logic : Vectorization is not always possible for functions with conditional statements (if/else) applied element-wise. The use of np.where is the vectorized alternative to a slow scalar loop with conditional logic Array Slicing : Used for vectorizing operations, especially common in fields like finite differences equations and image processing. - Array copy: Copy by Reference (shallow copy): The default assignment (b = a) copies the memory area pointer, meaning changes to b affect a Copy by Value (deep copy): Creating a new memory area with the same values is done using the .copy() method (c = a.copy()) - I/O with NumPy Arrays: ASCII Format : Can be managed using repr() for writing and eval() for reading loadtxt and savetxt : Functions for reading and writing files, offering parameters like skiprows, usecols, and delimiter - Matrix operations: Element-by-Element Multiplication: Standard array multiplication (a * b) performs element-by-element product Matrix Multiplication: Achieved by converting arrays to np.matrix objects (ma * mb) or using the matrix multiplication operator/function with arrays. - random Sub-module: Used to generate random numbers. It is more efficient to use numpy.random than the standard numpy module for this purpose. Examples include generating uniform and normal distributions. Matplotlib is a Python 2D/3D plotting library for creating publication-quality figures - Capabilities: Can generate plots, histograms, power spectra, bar charts, errorcharts, and scatterplots. - pyplot Sub-module: Provides a MATLAB-like interface for simple plotting - Interface Control: Offers both an object-oriented interface for full control (line styles, font properties, etc.) and a function set familiar to MATLAB users. - Examples: Code examples show how to: - Create a simple plot of a function (like sine) with labels and a title. - Generate a figure with multiple subplots. - Plot multiple datasets (e.g., populations) on the same graph - Perform basic statistics (mean, standard deviation, max population) on array data.