Python – scipy.linalg.tanm()


The tanm() function of scipy.linalg package is used to compute the tangent of an input matrix. This routine uses expm to compute the matrix exponentials.

Syntax

scipy.linalg.tanm(x)

where x is the input array or a square matrix. It returns the matrix tangent of x.

Example 1

Let us consider the following example −

# Import the required libraries
from scipy import linalg
import numpy as np

# Define the input array
x = np.array([[69 , 12] , [94 , 28]])
print("Input array: \n", x)

# Calculate the Tangent
a = linalg.tanm(x)

# Display the Tangent of matrix
print("Tangent of X: \n", a)

Output

It will generate the following output −

Input array:
 [[69 12]
 [94 28]]
Tangent of X:
 [[-0.15617321 0.02473695]
 [ 0.19377281 -0.24069113]]

Example 2

Let us consider the following example −

# Import the required libraries
from scipy import linalg
import numpy as np

# Define the input array
y = np.cbrt([[87 , 26] , [59 , 36]])
print("Input array:\n", y)

# Calculate the Tangent
b = linalg.tanm(y)

# Display the Tangent of matrix
print("Tangent of Y: \n", b)

Output

It will generate the following output −

Input array:
 [[4.43104762 2.96249607]
 [3.89299642 3.30192725]]
Tangent of Y:
 [[1.1489018 0.51580364]
 [0.67781414 0.95230934]]

Updated on: 24-Dec-2021

152 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements