
- 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 - tanm() Function
The scipy.linalg.tanm function computes the matrix tangent of a square matrix A. It defines, the tangent of a matrix is the product of the hyperbolic sine function (sinh(A)) and the inverse hyperbolic cosine function (cosh(A)). Thus, it applies the tangent function to matrices.
The tanm() method is commonly used to solve sophisticated mathematical problems such as differential equations, oscillatory system modeling, and scientific computations with matrix exponential functions.
It is frequently used in conjunction with matrix exponential (expm) or logarithm (logm) to analyze oscillatory behavior, stability, and complex matrix operations in linear algebra.
The tanm approach is based on the matrix definitions for hyperbolic sine (sinh) and cosine (cosh). The input matrix A should be square and numerical.
Syntax
Following is the syntax of the SciPy tanm() method −
.tanm(A)
Parameters
Following are the parameters of tanm() 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
tanm (ndarray) − The matrix tangent of the input matrix A, of the same shape as A.
Example 1
The tangent of a diagonal matrix to an identity matrix is a diagonal matrix. The diagonal entries in the identity matrix are the tangents of scalar values.
This example uses a 22 identity matrix as input. The tanm() function calculates the tangent transformation element by element for the diagonal entries, and thus results in a diagonal matrix with each entry representing the tangent of one.
import numpy as np import scipy.linalg from scipy.linalg import tanm # Input: 2x2 Identity matrix A = np.eye(2) # Compute the matrix tangent tanm_A = scipy.linalg.tanm(A) print(tanm_A)
When we run above program, it produces following result
[[1.55740772 0. ] [0. 1.55740772]]
Example 2
The matrix tangent transformation for a symmetric matrix is calculated by using the eigenvalues of the matrix, and it retains the property of symmetry in the output.
A 22 symmetric matrix is used as input. The tanm() function takes the eigenvalues and applies the tangent transformation to get the result, where the result retains the symmetry of the input matrix.
import numpy as np from scipy.linalg import tanm # Input: Symmetric matrix A = np.array([[0, 2], [2, 0]]) # Compute the matrix tangent tanm_A = tanm(A) print(tanm_A)
Following is an output of the above code
[[-0. -2.18503986] [-2.18503986 -0. ]]
Example 3
The tangent matrix transformation deals with complex matrices. It will take the tangent operation to the input matrix's eigenvalues. The result is a very complex matrix.
The function used is a 22 complex-valued matrix. This function will calculate the tanm function for each of the eigenvalues in the matrix. Then it will return the resulting complex-valued matrix.
import numpy as np from scipy.linalg import tanm # Input: Complex matrix A = np.array([[1 + 2j, 0], [0, 2 + 1j]]) # Compute the matrix tangent tanm_A = tanm(A) print(tanm_A)
Following is an output of the above code
[[ 0.03381283+1.01479362j 0. +0.j ] [-0. +0.j -0.2434582 +1.16673626j]]