
- SciPy - Home
- SciPy - Introduction
- SciPy - Environment Setup
- SciPy - Basic Functionality
- SciPy - Relationship with NumPy
- SciPy Clusters
- SciPy - Clusters
- SciPy - Hierarchical Clustering
- SciPy - K-means Clustering
- SciPy - Distance Metrics
- SciPy Constants
- SciPy - Constants
- SciPy - Mathematical Constants
- SciPy - Physical Constants
- SciPy - Unit Conversion
- SciPy - Astronomical Constants
- SciPy - Fourier Transforms
- SciPy - FFTpack
- SciPy - Discrete Fourier Transform (DFT)
- SciPy - Fast Fourier Transform (FFT)
- SciPy Integration Equations
- SciPy - Integrate Module
- SciPy - Single Integration
- SciPy - Double Integration
- SciPy - Triple Integration
- SciPy - Multiple Integration
- SciPy Differential Equations
- SciPy - Differential Equations
- SciPy - Integration of Stochastic Differential Equations
- SciPy - Integration of Ordinary Differential Equations
- SciPy - Discontinuous Functions
- SciPy - Oscillatory Functions
- SciPy - Partial Differential Equations
- SciPy Interpolation
- SciPy - Interpolate
- SciPy - Linear 1-D Interpolation
- SciPy - Polynomial 1-D Interpolation
- SciPy - Spline 1-D Interpolation
- SciPy - Grid Data Multi-Dimensional Interpolation
- SciPy - RBF Multi-Dimensional Interpolation
- SciPy - Polynomial & Spline Interpolation
- SciPy Curve Fitting
- SciPy - Curve Fitting
- SciPy - Linear Curve Fitting
- SciPy - Non-Linear Curve Fitting
- SciPy - Input & Output
- SciPy - Input & Output
- SciPy - Reading & Writing Files
- SciPy - Working with Different File Formats
- SciPy - Efficient Data Storage with HDF5
- SciPy - Data Serialization
- SciPy Linear Algebra
- SciPy - Linalg
- SciPy - Matrix Creation & Basic Operations
- SciPy - Matrix LU Decomposition
- SciPy - Matrix QU Decomposition
- SciPy - Singular Value Decomposition
- SciPy - Cholesky Decomposition
- SciPy - Solving Linear Systems
- SciPy - Eigenvalues & Eigenvectors
- SciPy Image Processing
- SciPy - Ndimage
- SciPy - Reading & Writing Images
- SciPy - Image Transformation
- SciPy - Filtering & Edge Detection
- SciPy - Top Hat Filters
- SciPy - Morphological Filters
- SciPy - Low Pass Filters
- SciPy - High Pass Filters
- SciPy - Bilateral Filter
- SciPy - Median Filter
- SciPy - Non - Linear Filters in Image Processing
- SciPy - High Boost Filter
- SciPy - Laplacian Filter
- SciPy - Morphological Operations
- SciPy - Image Segmentation
- SciPy - Thresholding in Image Segmentation
- SciPy - Region-Based Segmentation
- SciPy - Connected Component Labeling
- SciPy Optimize
- SciPy - Optimize
- SciPy - Special Matrices & Functions
- SciPy - Unconstrained Optimization
- SciPy - Constrained Optimization
- SciPy - Matrix Norms
- SciPy - Sparse Matrix
- SciPy - Frobenius Norm
- SciPy - Spectral Norm
- SciPy Condition Numbers
- SciPy - Condition Numbers
- SciPy - Linear Least Squares
- SciPy - Non-Linear Least Squares
- SciPy - Finding Roots of Scalar Functions
- SciPy - Finding Roots of Multivariate Functions
- SciPy - Signal Processing
- SciPy - Signal Filtering & Smoothing
- SciPy - Short-Time Fourier Transform
- SciPy - Wavelet Transform
- SciPy - Continuous Wavelet Transform
- SciPy - Discrete Wavelet Transform
- SciPy - Wavelet Packet Transform
- SciPy - Multi-Resolution Analysis
- SciPy - Stationary Wavelet Transform
- SciPy - Statistical Functions
- SciPy - Stats
- SciPy - Descriptive Statistics
- SciPy - Continuous Probability Distributions
- SciPy - Discrete Probability Distributions
- SciPy - Statistical Tests & Inference
- SciPy - Generating Random Samples
- SciPy - Kaplan-Meier Estimator Survival Analysis
- SciPy - Cox Proportional Hazards Model Survival Analysis
- SciPy Spatial Data
- SciPy - Spatial
- SciPy - Special Functions
- SciPy - Special Package
- SciPy Advanced Topics
- SciPy - CSGraph
- SciPy - ODR
- SciPy Useful Resources
- SciPy - Reference
- SciPy - Quick Guide
- SciPy - Cheatsheet
- SciPy - Useful Resources
- SciPy - Discussion
SciPy - Frobenius Norm(fro)
The Frobenius Norm in SciPy is a specific type of matrix norm widely used in numerical linear algebra. It measures the size or magnitude of a matrix by summing the squared magnitudes of all its elements. It is especially useful in problems involving error estimation, optimization and linear algebra.
The Frobenius norm is equivalent to the Euclidean norm of the matrix when the matrix is treated as a vector by stacking its rows or columns.
When given matrix is A with dimensions m x n, then the Mathematical formula for the Frobenius Norm ||A||F is defined as follows −
‖A‖F = √(∑i=1m ∑j=1n |aij|2)
Where −
- aij represents the element in the i-th row and j-th column of A.
- The norm computes the sum of the squared absolute values of all matrix elements followed by taking the square root.
Key Properties of the Frobenius Norm
The Frobenius norm has several important properties that make it useful in mathematics, numerical linear algebra and applications involving matrix computations. Following are the key Properties of the Frobenius Norm −
Non-Negativity
The Frobenius norm is always non-negative and the equality holds if and only if A is a zero matrix (Aij = 0 for all i, j).
AF 0
Homogeneity (Scaling)
The Frobenius norm is homogeneous with respect to scalar multiplication.
cAF = |c| . AF
where c is a scalar and A is a matrix. This means that scaling a matrix by a factor c scales its Frobenius norm by c.
Subadditivity (Triangle Inequality)
The Frobenius norm satisfies the triangle inequality.
A + BF |A|F + BF
where A and B are matrices of the same size. This property ensures that the Frobenius norm behaves consistently with distance metrics.
Unitary/Orthogonal Invariance
The Frobenius norm is invariant under multiplication by orthogonal (real matrices) or unitary (complex matrices) matrices.
UAF = |A|F and AVF = |A|F
where U and V are orthogonal/unitary matrices. This property is crucial for numerical methods like Singular Value Decomposition (SVD) as it ensures the norm remains unchanged under certain transformations.
Relationship with Vector Norm
If a matrix A is reshaped into a vector vec(A) then the Frobenius norm of A equals the Euclidean (L2) norm of vec(A) −
AF = vec(A)2
This property highlights the connection between matrix norms and vector norms.
Example 1
Following is the example of the Frobenius Norm calculated with the help of the function scipy.linalg.norm() by passing the parameter ord = 'fro'. Here in this example we are calculating the Frobenius Norm for a small 2d matrix −
import numpy as np from scipy.linalg import norm # Define the matrix A = np.array([[1, 2], [3, 4]]) # Compute the Frobenius norm fro_norm = norm(A, ord='fro') print("Matrix A:") print(A) print("Frobenius Norm of A:", fro_norm)
Following is the output of the Frobenius Norm calculated for a 2D matrix −
Matrix A: [[1 2] [3 4]] Frobenius Norm of A: 5.477225575051661
Example 2
Here in this example we are going to calculate the Frobenius Norm for a complex matrix with the use of scipy.linalg.norm() function −
import numpy as np from scipy.linalg import norm # Define the complex matrix A = np.array([[1 + 1j, 2 - 1j], [-1j, 3 + 2j]]) # Compute the Frobenius norm fro_norm = norm(A, ord='fro') print("Complex Matrix A:") print(A) print("Frobenius Norm of A:", fro_norm)
Below is the output of the Frobenius Norm calculated for a complex matrix −
Complex Matrix A: [[ 1.+1.j 2.-1.j] [-0.-1.j 3.+2.j]] Frobenius Norm of A: 4.58257569495584
Example 3
Heres an example of calculating the Frobenius norm for a zero matrix −
import numpy as np from scipy.linalg import norm # Define the zero matrix A = np.zeros((2, 2)) # Compute the Frobenius norm fro_norm = norm(A, ord='fro') print("Zero Matrix A:") print(A) print("Frobenius Norm of A:", fro_norm)
Here is the output of the Frobenius Norm calculated for a Zero matrix −
Zero Matrix A: [[0. 0.] [0. 0.]] Frobenius Norm of A: 0.0