
- 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 - sinhm() Function
The scipy.linalg.sinhm() returns the matrix hyperbolic sine of a square matrix 'A'. This extends the hyperbolic sine function to matrices via the Taylor series expansion. The method is suitable for both real and complex matrices and yields an output of the same dimensions as A with elements being a transformation of the matrix structures in hyperbolic sine.
This method is widely used in physics, engineering, and numerical computations to model oscillatory systems, solve differential equations, and analyze system dynamics involving exponential or oscillatory growth.
The sinhm() method is very often combined with the matrix hyperbolic cosine coshm() or matrix exponential expm() to analyze and solve complex systems. For instance, while the combination of sinhm() and coshm() aids in modeling dynamic systems, its combination with expm() helps study continuous-time systems.
The coshm() method computes the hyperbolic cosine, preserving symmetry and reflecting stability, while the sinhm() method computes the hyperbolic sine, capturing oscillatory or growing behavior with skewness. They complement each other very well in modeling hyperbolic equations and system dynamics.
Syntax
Following is the syntax of the SciPy sinhm() method −
scipy.linalg.sinhm(A)
Parameters
Following are the parameters of sinhm() method
A (array_like) − The input matrix must be square (n x n), meaning it has the same number of rows and columns. Typically, this matrix can be either real or complex.
Return Value
sinhm_A (ndarray) − The matrix hyperbolic cosine of A will have the same dimensions as A.
Example 1: Hyperbolic Sine of a Matrix with Negative Values
In this code, we used a matrix with negative elements as input. The hyperbolic sine is applied to each diagonal element individually.
# Input: Matrix with negative values A = np.array([[-1, -2], [-3, -4]]) # Compute the matrix hyperbolic sine sinhm_A = sinhm(A) print(sinhm_A)
When we run above program, it produces following result
[[-4.04865381 -7.28703715] [-10.93055572 -14.97920953]]
Example 2: Hyperbolic Sine of a Block Diagonal Matrix
In this code, we created a block diagonal using block_diag as input. The sinhm() function computes the hyperbolic sine of each block independently, resulting in a block-diagonal output matrix.
import numpy as np from scipy.linalg import block_diag, sinhm # Input: Block diagonal matrix A_block1 = np.array([[1, 2], [3, 4]]) A_block2 = np.array([[5, 6], [7, 8]]) A = block_diag(A_block1, A_block2) sinhm_A = sinhm(A) print(sinhm_A)
Following is an output of the above code
[[ 27.2899172 36.38306443 0. 0. ] [ 54.57459664 81.86451384 0. 0. ] [ 0. 0. 484.83963845 674.48922344] [ 0. 0. 786.57074402 1133.18038247]]
Example 3: Symmetry Preservation in Matrices with sinhm
When sinhm() is used on a symmetric matrix, the computation of hyperbolic sine is performed preserving the symmetry of the input in the output.
In the below code, a 22 matrix is given to sinhm(). The function utilizes eigenvalues to calculate the hyperbolic sine, and the result is a symmetric output matrix.
import numpy as np from scipy.linalg import sinhm # Input: Symmetric matrix A = np.array([[1, 2], [2, 1]]) sinhm_A = sinhm(A) print(sinhm_A)
Following is an output of the above code
[[4.42133687 5.59653806] [5.59653806 4.42133687]]
Example 4: Hyperbolic Sine of Complex-Valued Matrices
The sinhm() function can evaluate the hyperbolic sine of matrices that are complex valued, and it returns an output matrix which will be complex valued.
In the below example we will create a 22 complex matrix. It uses its eigenvalues to compute the hyperbolic sine of each one and then it comes out as a matrix with complex values.
import numpy as np from scipy.linalg import sinhm # Input: Complex matrix A = np.array([[1 + 1j, 0], [0, 2 + 2j]]) sinhm_A = sinhm(A) print(sinhm_A)
Following is an output of the above code
[[ 0.63496391+1.29845758j 0. +0.j ] [ 0. +0.j -1.50930649+3.42095486j]]
Example 5: Error: Non-Square Matrix Input in sinhm
The sinhm() function accepts a square matrix as the input. Providing a non-square matrix results in a ValueError.
In the below code, we will create a 23, non-square input matrix as input. Since sinhm() only accepts the square matrices as input, sinhm() throws up an error identifying the invalid argument.
import numpy as np from scipy.linalg import expm # Input: Matrix with negative values A = np.array([[-1, -2], [-3, -4]]) # Compute the matrix hyperbolic sine using its definition sinhm_A = (expm(A) - expm(-A)) / 2 print(sinhm_A)
Following is an output of the above code
ValueError: expected square array_like input
Example 6: Hyperbolic Sine of an Identity Matrix
If an identity matrix were passed as argument to sinhm(), it produced another diagonal matrix with each member of the diagonals representing hyperbolic sine of 1.
In the below example, we have created a identity matrix using np.eye(n), and then the function takes the hyperbolic sine for the diagonal elements and returns a diagonal matrix of sinh(1)=1.17520.
import numpy as np from scipy.linalg import sinhm # Input: Identity matrix A = np.eye(3) sinhm_A = sinhm(A) print(sinhm_A)
Following is an output of the above code
[[1.17520119 0. 0. ] [0. 1.17520119 0. ] [0. 0. 1.17520119]]
Example 7: Modeling a Damped Pendulum Using sinhm and coshm
In a damped pendulum, sinhm() represents oscillatory motion, indicating how movement decreases with time due to damping, but coshm() represents stability, demonstrating how damping forces stabilize the system. Combining these matrices allows us to better comprehend the pendulum's overall dynamics.
A illustrates a damped pendulum, with values for angular displacement, velocity, and damping forces. sinhm() calculates oscillatory motion, with positive values indicating forward motion and negative values indicating energy loss. coshm() reflects stability, and big negative values indicate severe damping effects. Combining the two yields the whole state transition matrix.
This study integrates oscillation effects (damping and motion) with stability components, revealing how the pendulum changes over time, which is critical for building control systems.
import numpy as np from scipy.linalg import sinhm, coshm # Define a state matrix for a damped pendulum A = np.array([[0, 1], [-9.8, -0.5]]) # Compute oscillatory behavior oscillation_matrix = sinhm(A) # Compute stability behavior stability_matrix = coshm(A) # Combine results to model full state transition state_transition = stability_matrix + oscillation_matrix print("State Transition Matrix:\n", state_transition)
Following is an output of the above code
State Transition Matrix: [[-0.77731133 0.00526464] [-0.05159345 -0.77994365]]