Next Article in Journal
Introducing a Parallel Genetic Algorithm for Global Optimization Problems
Previous Article in Journal
SIRS Epidemic Models with Delays, Partial and Temporary Immunity and Vaccination
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

An Efficient Algorithm for Basic Elementary Matrix Functions with Specified Accuracy and Application

1
The School of Mathematics and Statistics, Shandong University of Technology, Zibo 255049, China
2
Department of Mathematical and Digital Sciences, Bloomsburg University, Bloomsburg, PA 17815, USA
*
Author to whom correspondence should be addressed.
AppliedMath 2024, 4(2), 690-708; https://doi.org/10.3390/appliedmath4020037
Submission received: 26 January 2024 / Revised: 4 March 2024 / Accepted: 19 April 2024 / Published: 5 June 2024

Abstract

:
If the matrix function f ( A t ) posses the properties of f ( A t ) = g f ( t k A , then the recurrence formula f i 1 = g f i , i = N , N 1 , , 1 , f ( t A ) = f 0 , can be established. Here, f N = f ( A N ) = j = 0 m a j A N j , A N = t k N A . This provides an algorithm for computing the matrix function f ( A t ) . By specifying the calculation accuracy p, a method is presented to determine m and N in a way that minimizes the time of the above algorithm, thus providing a fast algorithm for f ( A t ) . It is important to note that m only depends on the calculation accuracy p and is independent of the matrix A and t. Therefore, f ( A N ) has a fixed calculation format that is easily computed. On the other hand, N depends not only on A, but also on t. This provides a means to select t such that N is equal to 0, a property of significance. In summary, the algorithm proposed in this article enables users to establish a desired level of accuracy and then utilize it to select the appropriate values for m and N to minimize computation time. This approach ensures that both accuracy and efficiency are addressed concurrently. We develop a general algorithm, then apply it to the exponential, trigonometric, and logarithmic matrix functions, and compare the performance with that of the internal system functions of Mathematica and Pade approximation. In the last section, an example is provided to illustrate the rapid computation of numerical solutions for linear differential equations.

1. Introduction

Matrix exponent functions plays a crucial role in various fields, including ordinary differential equations and control theory. In particular, they are instrumental in analyzing general structural dynamic systems, represented by the initial value problem:
M x + G x + K x = r ( t ) , x ( 0 ) = x 0 , x ( 0 ) = x 1 ,
where M , G , and K are n by n square matrices, and r ( t ) denotes the external force applied. The introduction of dual variables of a Hamiltonian system,
p = M x + G x / 2 ,
results in the following system:
U = H U + F ( t ) , U ( 0 ) = U 0 ,
where
U = q p , H = M 1 G / 2 M 1 G M 1 G / 4 K M 1 G / 2 , F ( t ) = 0 r ( t ) , q = x , U 0 = x 0 M x 1 + G x 0 / 2 .
The solution of (3) is provided as follows:
U ( t ) = e H t U 0 + 0 t e H ( t s ) F ( s ) d s .
When a problem is oscillatory, the formal solution often involves both the sine and cosine of a matrix. Famous examples include the Schr o dinger equation in quantum mechanics:
i d ψ d t = H ( t ) ψ , ψ ( t 0 ) = ψ 0 ,
where H ( t ) is a Hermitian operator and ψ is a complex wave function. If H ( t ) = A is a real and constant matrix, the solution of (6) is as follows:
ψ ( t ) = e i A t ψ 0 = cos ( t A ) i sin ( t A ) ψ 0 .
There are other examples where the computation of the sine and cosine of a matrix can be of interest. Wave equations provided by the generic second order system are written as follows:
x + K x = F ( t ) , x ( 0 ) = x 0 , x ( 0 ) = x 1 ,
where the solution is provided by the variation of the constant method:
x ( t ) = cos ( t A ) x 0 + sin 1 ( t A ) x 1 + 0 t sin 1 ( ( t s ) A ) F ( s ) d s ,
where A = K , sin 1 ( t A ) = 0 t cos ( s A ) d s . If A is invertible, then (9) can be written as follows:
x ( t ) = cos ( t A ) x 0 + sin ( t A ) A 1 x 1 + A 1 0 t sin ( ( t s ) A ) F ( s ) d s .
For (5), providing U ( k τ ) ( k = 1 , 2 , ) as accurately as possible is a concern for engineers and mathematicians, where τ is called the step. The specific method for this problem is as follows:
U k = T U k 1 + 0 τ e H s F ( k τ s ) d s , k = 1 , 2 , , T = e H τ .
Similarly, for (10), providing the algorithm x ( k τ ) ( k = 1 , 2 , ) as accurately as possible involves introducing vectors x = y and the following algorithm:
x k = cos ( τ A ) x k 1 + sin ( τ A ) A 1 y k 1 + A 1 0 τ sin ( s A ) F ( k τ s ) d s , y k = A sin ( τ A ) x k 1 + cos ( τ A ) y k 1 + 0 τ cos ( s A ) F ( k τ s ) d s , x 0 = x ( 0 ) , y 0 = x ( 0 ) = x 1 .
To improve the accuracy of U ( k τ ) and x ( k τ ) , it is essential to develop an algorithm with high accuracy for computing T = e H τ , cos ( τ A ) and sin ( τ A ) and the integral containing these matrix functions. This paper improves the algorithms developed for the computation of e A and cos A in the existing literature, see [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15], and also discusses the computation of other trigonometric, hyperbolic, logarithmic, and related inverse triangular and inverse hyperbolic matrices.

2. The General Theorem of the Fast Algorithm for Matrix Functions

In [16], we addressed the challenge of rapidly calculating elementary functions with specified precision. The implementation method involves an analytic function f ( x ) specifying property,
f ( x ) = g f x k , where k > 1 .
If C 0 is an approximation as close as possible to f x k N , with N as a positive integer, for example,
C 0 = j = 0 m f ( j ) 0 Δ x j j ! , Δ x = x k N , m = 1 , 2 ,
or C 0 being the Padé approximation of f x k N , then the following calculations are performed:
for ( i = 0 , i < N , i + + ) C i + 1 = g ( C i ) .
Completing (14) and (15), f ( x ) C N is obtained. This method is also applicable to the calculation of matrix functions, where the variable x is replaced by the n by n square matrix A . Now, we have the following:
C 0 = j = 0 m f ( j ) 0 Δ A j j ! , Δ A = 1 k N A , m = 1 , 2 ,
or C 0 is the Padé approximation of f Δ A . Our objective is to determine m and N to minimize the computation time under the condition that the truncation error and computational precision are 10 p . For the matrix function calculation, the coefficient calculation of (14) can be ignored, mainly focusing on the multiplication calculation of the matrix in (16) and (15). If the number of multiplications to complete g ( A ) is K, then the total number of times to complete (16) and (15) is roughly
q ( m , N ) = ( m + K N ) M n ,
where M n is the number of times to complete one multiplication of the n by n matrix. Based on the above discussion, we present a fast algorithm for the matrix function as follows.
Theorem  1.
Let m p be an integer close to the minimum point of h ( m ) , where
h ( m ) = m + p K ln 10 ( m + 1 ) ln k + K ( m + 1 ) ln k ln f ( m + 1 ) 0 ( m + 1 ) !
and
N = p ln 10 ( m + 1 ) ln k + 1 ( m + 1 ) ln k ln f ( m + 1 ) 0 ( m + 1 ) ! + ln A ln k + 1 .
(1) C 0 = j = 0 m p f ( j ) 0 Δ A j j ! , where Δ A = 1 k N A , or C 0 is a Padé approximation of f Δ A .
(2) for( i = 0 , i < N , i + + ) C i + 1 = g ( C i ) and A C N .
The above algorithm is a fast algorithm for the general matrix function.
Proof. 
With a truncation error of 10 p , for (16) to be satisfied,
f ( m + 1 ) 0 Δ A m + 1 ( m + 1 ) ! = f ( m + 1 ) 0 ( m + 1 ) ! k ( m + 1 ) N A m + 1 f ( m + 1 ) 0 ( m + 1 ) ! k ( m + 1 ) N A m + 1 < 10 p ,
where A is a norm of A . So,
N > p ln 10 ( m + 1 ) ln k + 1 ( m + 1 ) ln k ln f ( m + 1 ) 0 ( m + 1 ) ! + ln A ln k .
From (17), we obtain the following:
q ( m , N ) > g ( m ) = m + p K ln 10 ( m + 1 ) ln k + K ( m + 1 ) ln k ln f ( m + 1 ) 0 ( m + 1 ) ! + K ln A ln k M n .
Note that the minimum point of g ( m ) has nothing to do with K ln A ln k . By making q ( m , N ) as small as possible, the algorithm obtained by (1) and (2) is a fast algorithm, thus completing the proof of the theorem. □
Remark  1.
In the specific calculation, A can be replaced by the approximate eigenvalue with the maximum modulus in this paper.
f ( m + 1 ) 0 ( m + 1 ) ! k ( m + 1 ) N A m + 1 < 10 p .

3. Fast Algorithm for e A , cos A , sin A , sinh A , and cosh A

Suppose λ = A is a norm for A. If we let A = λ A 0 , then A 0 1 . From (19), we can obtain the following:
N p = p ln 10 ( m + 1 ) ln k + 1 ( m + 1 ) ln k ln f ( m + 1 ) 0 ( m + 1 ) ! + ln λ K ln k + 1 .
In order to reduce the length of the article, the algorithms for several matrix functions are compiled into a table.
Theorem  2.
For e A , cos A , sin A , cosh A , and sinh A , we devised the following fast algorithm using Theorem 1.
Remark  2.
It is worth noting that m p in Table 1 only depends on the calculation accuracy p and the matrix function, and is independent of matrix A.
Now, we utilize the general fast algorithm to specifically demonstrate the correctness of the algorithms in Table 1. The algorithms in Table 1 are straightforward; they involve placing the specific functions f and g into the general algorithm, and the tricky part lies in deriving the formulas of m p and N p . We calculate the formulas for m p and N p for the function e A for 12 p 36 here. In fact, the graphing of the function of h ( m ) supports our results for all values of p . The derivation of m p and N p for the other functions is very similar.
(1) For the function e A , we have g ( u ) = u 2 , k = 2 , K = 1 , and
h ( m ) = m + p ln 10 ( m + 1 ) ln 2 1 ( m + 1 ) ln 2 ln ( m + 1 ) ! .
Using Sterling’s approximation formula, we obtain the following:
ln ( ( m + 1 ) ! ) = 1 2 ln ( 2 π ) + 1 2 ln ( m + 1 ) + ( m + 1 ) ln ( m + 1 ) m 1 + O ( 1 m + 1 ) .
Now, implementing it into (25), we obtain the following:
h ( m ) m + p ln 10 ( m + 1 ) ln 2 ln ( 2 π ) 2 ( m + 1 ) ln 2 ln ( m + 1 ) 2 ( m + 1 ) ln 2 + 1 ln 2 .
Let
q ( x ) = x + p ln 10 ( x + 1 ) ln 2 ln ( 2 π ) 2 ( x + 1 ) ln 2 ln ( x + 1 ) 2 ( x + 1 ) ln 2 + 1 ln 2 .
Taking its derivative with respect to x , one obtains
q ( x ) = 1 p ln 10 ( x + 1 ) 2 ln 2 + ln ( 2 π ) 2 ( x + 1 ) 2 ln 2 + ln ( x + 1 ) 2 ( x + 1 ) 2 ln 2 1 2 ( x + 1 ) 2 ln 2 .
To determine extreme values, we set it to 0 and multiply both sides by ( m + 1 ) 2 :
( x + 1 ) 2 1 ln 2 ( x + 1 ) + ln ( x + 1 ) 2 ln 2 2 p ln 10 ln ( 2 π ) + 1 2 ln 2 = 0 .
Using simple algebra, we obtain the following:
( x + 1 ) 2 > ( m + 1 ) ln ( m + 1 ) + ( m + 1 ) ln ( 2 π ) 2 ln 2 + 2 p ln 10 + 1 2 ln 2 > 2 p ln 10 + 1 2 ln 2 .
Using p = 12 , we obtain a lower bound for x :
x > 2 p ln 10 + 1 2 ln 2 1 = 6.37 .
Thus, we have a lower bound for m: m 6 . We also can solve the quadratic equation to get
m + 1 = 1 ln 2 + 1 4 ln 2 2 + 8 p ln 10 4 ln ( 2 π ) + 4 8 ln 2 .
Now, using the smallest value for m obtained and p = 36 , we can obtain our first upper bound:
m < 1 + 1 ln 2 + 1 4 ln 2 2 ln 7 2 ln 2 + 276 ln 10 4 ln ( 2 π ) + 4 8 ln 2 11.31 .
We can again use the values of m and p = 12 to update the lower bound of m as follows:
m > 1 + 1 ln 2 + 1 4 ln 2 2 + ln 12 2 ln 2 + 96 ln 10 4 ln ( 2 π ) + 4 8 ln 2 6.61 .
Now, our new lower bound for m is 7. With this small range of values for m, by inspecting the formula for the values of m, we can see that the value of m is very close to p ln 10 ln 2 , and we can safely claim that m = 9 p ln 10 8 ln 2 . Our following numerical calculation supports this claim completely.
Case (a): p = 12 . Using the formula obtained by the quadratic formula and the upper bound m = 11 , we obtain a new lower bound: m 6.63 . Using the formula obtained by the quadratic formula and lower bound m = 7 , we can also obtain the upper bound: m 6.63 . Using our claim 9 p ln 10 8 ln 2 , we obtain m = 6.70 . This clearly matches the lower and upper bound quite well.
Case (b): p = 18 . Using the formula obtained by the quadratic formula and the upper bound m = 11 , we obtain a new lower bound: m 8.05 . Using the formula obtained by the quadratic formula and lower bound m = 7 , we can also obtain the upper bound: m 8.07 . Using our claim 9 p ln 10 8 ln 2 , we obtain m = 8.20 . These values match very well for taking the closest integer.
Case (c): p = 24 . Using the formula obtained by the quadratic formula and the upper bound m = 11 , we obtain a new lower bound: m 9.27 . Using the formula obtained by the quadratic formula and lower bound m = 7 , we can also obtain the upper bound: m 9.28 . Using our claim 9 p ln 10 8 ln 2 , we obtain m = 9.47 .
Case (d): p = 36 . Using the formula obtained by the quadratic formula and the upper bound m = 11 , we obtain a new lower bound: m 11.29 . Using the formula obtained by the quadratic formula and lower bound m = 7 , we can also obtain the upper bound: m 11.37 . Using our claim 9 p ln 10 8 ln 2 , we obtain m = 11.60 .
Using m p = 9 p ln 10 8 ln 2 , we can obtain
N p = p ln 10 ( m p + 1 ) ln 2 ln ( m p + 1 ) ! ( m p + 1 ) ln 2 + ln λ ln 2 + 1 .
(2) For sin A sinh A , we have g ( u ) = 3 u 4 u 3 , k = 3 , K = 2 and
h ( m ) = m + 2 p ln 10 ( 2 m + 2 ) ln 3 2 ln ( 2 m + 2 ) ! ( 2 m + 2 ) ln k .
In this case, for p = 12 , 16 , 24 , and 32, the corresponding integer points for h ( m ) to achieve its minimum value are 3 , 3 , 5 , and 6. Again, it can be estimated that
m p = 3 p ln 10 5 ln 3 , N p = p ln 10 ( 2 m p + 2 ) ln 3 ln ( 2 m p + 2 ) ! ( 2 m p + 2 ) ln 3 + ln λ ln 3 + 1 .
(3) For cos A cosh A , there are two cases:
Case (I): g ( u ) = 4 u 3 3 u , k = 3 , K = 2 , and (29) hold. Compared to I, the values in the second part of C = I + j = 1 m p ( B ) j ( 2 j ) ! are very small, so we may replace N with N 1 , and m p with m p + 1 .
Case (II): g ( u ) = u 2 1 , k = 2 , K = 1 and
h ( m ) = m + p ln 10 ( 2 m + 1 ) ln 2 1 ( 2 m + 1 ) ln 2 ln ( 2 m + 1 ) ! .
Similarly, for p = 12 , 16 , 24 , and 32, the corresponding integer points for h ( m ) to achieve its minimum value are 4 , 5 , 6 , and 7. Consequently, we can determine the following:
m p = 3 p ln 10 5 ln 2 , N p = p ln 10 ( 2 m p + 1 ) ln 2 ln ( 2 m p + 1 ) ! ( 2 m p + 1 ) ln 2 + ln λ ln 2 + 1 .
The effectiveness of the algorithms is displayed in Table 1 by implementing numerical computations in Mathematica. N p and m p are replaced with N p , μ = μ N p , m p , μ in Table 1, defined correspondingly by
m p , μ = min B j / j ! < 10 p j , B = A 2 N p , μ for e A , m p , μ = min B j + 1 / 2 / ( 2 j + 1 ) ! ) < 10 p j , B = A 2 3 2 N p , μ for sin A , ( I ) m p , μ = min B j / ( 2 j ) ! < 10 p j , B = A 2 3 2 N p , μ for cos A , ( II ) m p , μ = min B j / ( 2 j ) ! < 10 p j , B = A 2 2 2 N p , μ for cos A ,
where one has N p , 1 = N p and m p = m p , 1 .
For comparison, let A take the following form:
A = U D U 1 ,
where U is a randomly generated n by n matrix, D a = D i a l ( d 1 , d 2 , , d n ) is a randomly generated n by n diagonal matrix with d i ( a , b ) , i = 1 , 2 , , n , so f ( A ) = U f ( D ) U 1 ,   f ( D ) = D i a l ( f ( d 1 ) , f ( d 2 ) , , f ( d n ) ) . In all the examples in this paper, we agree on the relative error as follows:
e r r ( g ) ( A ) = f ( A ) U f ( D ) U 1 U f ( D ) U 1 .
Let A i ( i = 1 , 2 , , M ) be M matrices produced by (32). From Figure 1, it is evident that the calculation accuracy is essentially the same for μ = 1 , 2 3 , 4 3 , but μ = 1 provides the highest efficiency. The double-angle formula is notably more efficient and accurate than the triple-angle formula for cos A . Henceforth, we will exclude the case that utilizes the triple-angle formula for cos A .
Now let us juxtapose the algorithms presented in Table 1 with the internal functions and commonly used algorithms found in mathematical software. For ease of reference, let e r r ( g ) denote the calculation error of matrix function f ( A i ) ( i = 1 , 2 , , M ) , where a blank g implies the utilization of the algorithms in Table 1, Table 2 and Table 3 of this article. If g = S y m , P a d e , , it signifies calculation according to the internal function, Padé approximation, , respectively. When p = 16 ,   m p = 7 , 4 , 3 for e A , cos A ( cosh A ) , sin A ( sinh A ) , respectively. We denote the Padé approximation of sin x as r 66 ( x ) and the Padé approximation of e x and cos x as r 88 ( x ) . In Table 1, the Padé approximation of e A , cos A ( cosh A ) , sin A ( sinh A ) is as follows:
r 88 ( x ) = 1 + x 2 + x 2 60 + x 3 60 + x 4 624 + x 5 9360 + x 6 205920 + x 7 7207200 + x 8 518918400 1 x 2 + x 2 60 x 3 60 + x 4 624 x 5 9360 + x 6 205920 x 7 7207200 + x 8 518918400 for e x , r 88 ( x ) = 1 260735 x 2 545628 + 4375409 x 4 141863280 7696415 x 6 1310867072 + 80737373 x 8 23594700729600 1 ± 12079 x 2 545628 + 34709 x 4 141863280 ± 109247 x 6 65540835360 + 11321 x 8 1814976979200 for cos x cosh x , r 66 ( x ) = x 7 x 3 60 + x 5 600 1 ± x 2 20 + x 4 600 ± x 6 14400 for sin x sinh x .
For the algorithms in Table 1, the e r r ( g ) ( A ) of random matrix from order 1 to 800 is as follows.
It is evident from Figure 2 that, for e A , cos A , and sin A , the accuracy obtained by the three methods is essentially the same. However, when the matrix order is relatively high, the Taylor expansion method presented in Table 1 outperforms the others. In particular, for cos and sin A , the calculation time of the internal functions is approximately eight times longer than that of the algorithms in Table 1. Numerical calculations demonstrate that while the calculation speed of cos A and sin A using the internal functions R e ( e i A ) = cos A and I m ( e i A ) = sin A is faster than that of the internal functions cos A and sin A , their calculation accuracy is relatively poor.
For cosh A and sinh A , the internal functions can be calculated by utilizing the following equation:
cosh A = 1 2 ( e A + e A ) , sinh A = 1 2 ( e A e A ) .
Our experiment provides the following results for e r r ( g ) ( A ) of random matrices with orders from 1 to 800 .
It is evident from Figure 3 that using (35) not only doubles the calculation time but also makes the calculation error substantial. Furthermore, by observing Figure 2 and Figure 3, it becomes apparent that the algorithms in Table 1 outperform the Padé approximation algorithm.

4. Fast Algorithm for tan A , tanh A , sec A , and sechA

Now let us contemplate the swift computation of tan A , tanh A , sec A , and s e c h A . Although these matrix functions can be computed using the following approach, we aim to directly compute them, as demonstrated in the previous section.
tan A = sin A ( cos A ) 1 , sec A = ( cos A ) 1 , tanh A = sinh A ( cosh A ) 1 = e A e A e A + e A 1 , s e c h A = ( cosh A ) 1 = 2 e A + e A 1 .
While the Padé approximation significantly contributes to matrix function computation, the numerical results in the previous section indicate that, based on the algorithm presented in this paper, neither the calculation accuracy nor the calculation speed is predominant. Therefore, this section does not adopt it.
Theorem  3.
For tan A , sec A , tanh A , and s e c h A , we have the following fast algorithm based on Theorem 1.
In Table 2, for σ ( j ) and E ^ j , we have the following recursive formula [1]:
σ 2 n = 4 4 n + 1 l = 1 n 1 σ ( l ) σ ( 2 n l ) + 2 4 n + 1 σ 2 ( n ) , n = 1 , 2 , , σ 2 n 1 = 4 4 n 1 l = 1 n 1 σ ( l ) σ ( 2 n 1 l ) , n = 2 , 3 , E ^ n = k = 0 n 1 E ^ k ( 2 n 2 k ) ! , E ^ 0 = 1 , σ 1 = 1 6 .
Using the algorithms in Table 2, our experiments generated the following data for the e r r ( g ) ( A ) of random matrices from order 1 to 200.
Here, S y m indicates that matrix functions tan A , tanh A , sec A , and sech A , expressed by sin A cos A 1 , e A e A e A + e A 1 , cos A 1 and 2 e A + e A 1 , respectively, are computed using the internal functions. As observed in Figure 4, the algorithm’s computation speed in Table 2 surpasses that of the internal function, particularly for tan A and sec A , where the speed is increased by 8–11 times compared to the internal function, while maintaining consistent accuracy is consistent. When the order n of the matrix is relatively large, for tanh A and sec h A , the calculation speed is twice that of the internal function, yet the precision remains the same as the internal function.
Let us consider implementing our algorithms for calculating the functions cot A , cot A , csc A , and cschA. By
cot A t A 1 2 j = 0 m σ ( j + 1 ) A 2 j + 1 ; ( o < A < π , z 0 ) , coth A t A 1 + 2 j = 0 m ( 1 ) j σ ( j + 1 ) A 2 j + 1 ( 0 < A < π ) , csc A t A 1 + 2 j = 0 m σ ( j + 1 ) 1 2 4 j + 1 A 2 j + 1 ( 0 < A < π ) , csch A t A 1 2 j = 0 m ( 1 ) j σ ( j + 1 ) 1 2 4 j + 1 A 2 j + 1 ( 0 < A < π ) ,
we see that when A is small, the norm of the inverse of A will be large, so the calculation using (38) will produce large errors. Therefore, we must utilize the following method:
cot A = A 1 cot 1 A , coth A = A 1 coth 1 A , csc A = A 1 csc 1 A , csch A = A 1 csch 1 A ,
where
cot 1 A I 2 j = 1 m + 1 σ ( j ) A 2 j ; ( z < π , z 0 ) , coth 1 A I 2 j = 1 m + 1 ( 1 ) j σ ( j ) A 2 j ( z < π , z 0 ) , csc 1 A I + 2 j = 1 m + 1 σ ( j ) 1 2 4 j A 2 j ( z < π , z 0 ) , csch 1 A I + 2 j = 1 m + 1 ( 1 ) j σ ( j ) 1 2 4 j A 2 j ( z < π , z 0 ) .
Theorem  4.
Using Theorem 1, we have the following algorithm for cot A , coth A , csc A , and sec h A .
Implementation of the algorithms in Table 3 provides the following results for the matrix functions in (39).
Here, S y m signifies that matrix functions cot A , coth A , csc A , and sec h A are calculated using the internal functions with the regular formulas cos A sin A 1 , e A + e A e A e A 1 , sin A 1 , and 2 e A e A 1 , respectively. The results in Figure 5 are essentially consistent with the corresponding results in Figure 2.

5. Fast Algorithm for Logarithmic Matrix Function ln A and Some Related Functions

People consider various algorithms [17,18,19,20,21,22] for logarithmic matrix function ln A . One of the most effective methods we noticed was the following algorithm. The standard way of dealing with this problem is to use the square root operator repeatedly to bring A near the identity:
ln A = 2 k ln A k , A k = A 1 / 2 k .
As k increases, A 1 / 2 k I , so for sufficiently large k, we can apply a direct method to A 1 / 2 k . This procedure for the logarithm was introduced by Kenney and Laub [19]. The specific method is to choose k such that
A 1 / 2 k I < α < 1 ,
and usually, k is selected from 8. We slightly optimize the method as follows:
ln A = ln λ · I + 2 k ln A k , A k = A 0 1 / 2 k , A 0 = 1 A A ,
and
A 0 1 / 2 k I < α < 1 ,
where k is usually selected from 4.
For ln x , the algorithm that converges faster is
ln x = ln 1 y 1 + y 2 j = 1 m y 2 j + 1 2 j + 1 ,
where y = 1 x 1 + x . For ln A k , we have
ln A k = ln I B ln I + B 2 j = 1 m B 2 j 2 j + 1 ,
where B = ( I A k ) ( I + A k ) 1 . Applying the Euler–Abel transformation [21], we obtain the following accelerated series:
ln A k 1 3 B F 2 ( I 12 j = 1 m B 2 j ( 2 j + 3 ) ( 4 j 2 1 ) ) F ,
where F = 2 B ( I B 2 ) 2 . We can use the following Padé approximation of ln A k [20].
ln A k ( B + 2 B 2 + 47 36 B 3 + 11 36 B 4 + 137 7560 B 5 ) F , F = ( I + 5 2 B + 20 9 B 2 + 5 6 B 3 + 5 42 B 4 + 1 252 B 5 ) 1 ,
where B = A k I . We also provide some numerical results for the matrix function ln A .
Based on (41)–(44) we also provide some numerical results of ln A using (46)–(48). It can be seen from Figure 6 that through optimization (43), the calculation accuracy of (46)–(48) is significantly improved, and the calculation speed of (46)–(48) is more than twice as fast as the inner function. The calculation speed advantage of the Padé approximation is obvious.
We used the following identities to implement our general algorithm for the computations of the inverse trigonometric and hyperbolic functions. To control the length of the paper, we will not display the results here.
arcsin x = 2 arcsin x 2 ( 1 + 1 x 2 ) , arctan x = 2 arctan x 1 + 1 + x 2 , arcsin x = x + l = 1 ( 2 l 1 ) x 2 l + 1 ( 2 l ) ! ( 2 l + 1 ) , arctan x = l = 0 x 2 l + 1 ( 2 l + 1 ) ,
arcsinh x = 2 arcsinh x 2 ( 1 + 1 + x 2 ) , arctanh x = 2 arctanh x 1 + 1 x 2 , arcsinh x = x + l = 1 ( 1 ) l ( 2 l 1 ) x 2 l + 1 ( 2 l ) ! ( 2 l + 1 ) , a r c t a n h x = l = 0 ( 1 ) l x 2 l + 1 ( 2 l + 1 ) .
For arcsin A , arctan A , arcsinh A , and arctanh A , under certain conditions, we can use the following identity.
arcsin A = i ln I A 2 + i A , arcsinh A = ln I + A 2 + A , arctan A = i 2 ln i I + A i I A 1 , arctanh A = 1 2 ln ( I + A ) ( I A ) 1 .

6. Improved Calculation Formula for Initial Value Problems (3) and (8)

Now, let us consider the calculation of the integral in (11), i.e.,
F ^ k = 0 τ e H s F H ( k τ s ) d s .
If numerical integration is used to calculate this integral, it is quite time-consuming, and the calculation accuracy cannot be guaranteed. We adopt the following method here. For n n = 1 , 2 , , there is the following relationship:
F ^ k = j = 0 n n 1 j τ n n j τ n n e H s F H ( k τ s ) d s = j = 0 n n 1 T n n , j 0 τ n n e H s F H ( k τ j τ n n s ) d s j = 0 n n 1 T n n , j l = 0 m H l l ! 0 τ n n s l F H ( k τ j τ n n s ) d s ,
where
T n n , 0 = I , T n n = e H τ n n , T n n , j = e H j τ n n = T n n T n n , j 1 , j = 1 , 2 , , n n 1 .
T n n can be calculated by the following method:
T n n = I , z z = I ; for ( i = 1 , i m , i + + ) ( z z = τ n n i H × z z ; T n n = T n n + z z ) .
So, (53) can be written as follows:
F ^ k j = 0 n n 1 T n n , j H j , H j = l = 0 m H l l ! 0 τ n n s l F H ( k τ j τ n n s ) d s ,
so we can convert the integral of the product of matrix exponential function and vector function into the integral of pure vector function.
The improved calculation formula for (3) is as follows:
( 55 ) , ( 56 ) , U k = T U k 1 + j = 0 n n 1 T n n , j H j , k = 1 , 2 , ,
where T = e H τ is calculated by the algorithm in Table 1, and T n n , j a n d H j are calculated by (55) and (56).
For
0 τ n n s l F H ( k τ j τ n n s ) d s ,
the following two algorithms can be used.
(1) Integrable function method If F ( t ) = ( f 1 ( t ) , f 2 ( t ) , , f v ( t ) , , f n ( t ) ) T ,   f v ( t ) is the algebraic sum of functions of the following types:
t α , t l e ω t , t l sin ω t , t l cos ω t ,
then (58) can be expressed in analytical form, so H j can also be expressed in analytical form. In this way, the calculation of (57) can be completed.
(2) Gauss three-point integral formula
Note that, under 16-bit calculation accuracy,
τ n n < 1 2 n 16 λ H 0.0376434 λ H < 0.0376434 ,
and the algebraic accuracy of the Gauss three-point integral formula is 5. Using the Gauss three-point integral formula,
1 2 τ n n l + 1 i = 1 3 w i ( 1 + b i 2 ) l F H ( k τ ( j + 1 / 2 ) τ n n b i τ 2 n n ) ,
where w 1 = w 3 = 5 9 , w 2 = 8 9 , b 1 = 15 5 , b 2 = 0 , b 3 = 15 5 , to approximate (58) with high accuracy. So, (57) can be replaced by the following algorithm.
Algorithm  1.
Numerical solution algorithm of initial value problem (3): for  n n = 1 , 2 ,
U k = T U k 1 + τ 2 n n j = 0 n n 1 T n n , j i = 1 3 w i e H ( 1 + b i ) τ 2 n n F H k τ ( 2 j + 1 + b i ) τ 2 n n , k = 1 , 2 , ,
where
e H ( 1 + b i ) τ 2 n n w i τ 2 n n I + l = 1 m 1 l ! ( 1 + b i ) τ 2 n n l H l .
In particular, if we let
n n = 2 n p λ H τ + 1 2 n p λ H τ > 1 1 2 n p λ H τ 1 ,
then  N p = 0 , m = m p = 9 p ln 10 8 ln 2 ,
W i , H w i τ 2 n n I + l = 1 m p 1 l ! ( 1 + b i ) τ 2 n n l H l .
At this time, the theoretical calculation accuracy of (62) is  p .
Remark  3.
Note that, W i , H ( i = 1 , 2 , 3 ) in (63) and (65) only needs to be calculated once, and is independent of F ( t ) , which is not only efficient but also easy to program.
Now let us consider the numerical solution of the initial value problem (8). If it is converted to the initial value problem (3), then
x ( t ) x ( t ) = U , H = 0 I 3 × 3 K 0 , F H ( t ) = 0 F ( t ) , U 0 = x 0 x 1 .
By
W i , H = e τ H cos p τ A τ sin 1 , p τ A K τ sin 1 , p τ A cos p τ A , A = K ,
where
sin 1 A = j = 0 ( 1 ) j ( 2 j + 1 ) ! A 2 j = j = 0 ( 1 ) j ( 2 j + 1 ) ! K j ,
and (68), we obtain the following algorithm.
Algorithm  2.
 
Δ t = τ / 3 N ; T α = I ; z z = I ; A 2 = ( A Δ t ) × ( A Δ t ) ; for ( i = 1 , i m , i + + ) ( z z = A 2 ( 2 i ) ( 2 i + 1 ) × z z ; T α = T α + z z ) ,
and
for ( i = 0 , i < N , i + + ) ( z z = T α × T α , z z = z z × A 2 , A 2 = 9 A 2 , T α = T α 4 3 T α × z z ) ,
where  m p  and  N p  are determined using (31).
Algorithm  3.
Numerical solution algorithm of initial value problem (8):
x k = cos τ A x k 1 + τ sin 1 τ A y k 1 + τ 2 n n j = 0 n n 1 i = 1 3 w i ( 2 j + 1 + b i ) τ 2 n n sin 1 ( 2 j + 1 + b i ) τ 2 n n A F ( k τ ( 2 j + 1 + b i ) τ 2 n n ) y k = A sin τ A x k 1 + cos τ A y k 1 + τ 2 n n j = 0 n n 1 i = 1 3 w i cos ( 2 j + 1 + b i ) τ 2 n n A F ( k τ ( 2 j + 1 + b i ) τ 2 n n )
for  n n = 1 , 2 , ,  where  A = K .  In particular, if  n n  is determined using (64), the theoretical accuracy of this algorithm is p and
x k = cos ( τ A ) x k 1 + τ sin 1 ( τ A ) y k 1 + τ 2 n n j = 0 n n 1 i = 1 3 w i T W j , i sin F ( k τ ( 2 j + 1 + b i ) τ 2 n n ) , y k = cos ( τ A ) y k 1 A sin ( τ A ) x k 1 + τ 2 n n j = 0 n n 1 i = 1 3 w i T W j , i cos F ( k τ ( 2 j + 1 + b i ) τ 2 n n ) , x 0 = x ( 0 ) , y 0 = x ( 0 ) ,
where
T W j , i sin = ( 1 + b i ) τ 2 n n cos j τ n n A sin 1 , m p ( 1 + b i ) τ 2 n n A + j τ n n sin 1 j τ n n A cos m p ( 1 + b i ) τ 2 n n A , T W j , i cos = cos j τ n n A cos m p ( 1 + b i ) τ 2 n n A sin j τ n n A sin m p ( 1 + b i ) τ 2 n n A ,
and
sin m p ( s A ) = A l = 0 m p ( 1 ) l s 2 l + 1 K l ( 2 l + 1 ) ! , sin 1 , m p s A = l = 0 m p ( 1 ) l s 2 l K l ( 2 l + 1 ) ! , cos m p ( s A ) = I + l = 1 m p + 1 ( 1 ) l s 2 l K l ( 2 l ) ! .
If A is reversible, then
x k = cos τ A x k 1 + A 1 sin τ A y k 1 + τ 2 n n A 1 j = 0 n n 1 i = 1 3 w i sin ( 2 j + 1 + b i ) τ 2 n n A F ( k τ ( 2 j + 1 + b i ) τ 2 n n ) y k = A sin τ A x k 1 + cos τ A y k 1 + τ 2 n n j = 0 n n 1 i = 1 3 w i cos ( 2 j + 1 + b i ) τ 2 n n A F ( k τ ( 2 j + 1 + b i ) τ 2 n n ) .
Therefore, (75) can be written in the form of complex function as follows:
z k = e i τ A z k 1 + i τ 2 n n A 1 j = 0 n n 1 e j τ i n n A l = 1 3 w l e ( 1 + b l ) τ i 2 n n A F k τ ( 2 j + 1 + b l ) τ 2 n n ,
or
Z k = e i τ A Z k 1 + τ 2 n n j = 0 n n 1 e j τ i n n A l = 1 3 w l e ( 1 + b l ) τ i 2 n n A F k τ ( 2 j + 1 + b l ) τ 2 n n ,
where  i = 1 ,
z k = x k + i A 1 y k , x k = R e z k , y k = A I m z k , Z k = y k i A x k , y k = R e Z k , x k = A 1 I m Z k .
We first provide an examples to illustrate the effectiveness of Algorithms 1. Although we skip examples of Algorithm 2, we then include an example for the effectiveness of Algorithm 3.
Example  1.
In (8), let
K = 1 1 1 5 2 1 4 , F ( t ) = sin t 1 2 sin t cos 2 t 2 cos 3 t + sin t , x 0 = 5 2 0 2 T , x 1 = 1 1 2 T .
The analytic solution of the initial value problem (8) is
x ( t ) = 2 cos 2 t 2 + 1 2 cos 3 t + sin t cos 2 t 2 cos 3 t + sin t sin 2 t 2 cos 2 t .
Let e r r i , k = x ( k τ ) x i , k i = 1 , 2 , where x 1 , k , x 2 , k ( k = 0 , 1 , 2 , , N ) are the numerical solutions of the initial value problem (8) determined by Algorithm 1 and Algorithm 3, respectively. e r r s y m , k = x ( k τ ) x s y m ( k τ ) , where x s y m ( t ) is the numerical solution obtained by calling the function N D S o l v e in Mathematica. The numerical results of e r r 1 , k , e r r 2 , k , e r r s y m , k [ 0 , T ] ( k = 0 , 1 , 2 , , N τ = T ) are as follows.
It can be seen from Figure 7 that the calculation accuracy of Algorithm 1 is higher than that of Algorithm 3 but the calculation speed of Algorithm 3 is three times that of Algorithm 1. However, the error of numerical results of Mathematica internal functions is far greater than the error of Algorithms 1 and 3. In particular, the collapse is calculated at t = 667.787 . After this point, the error increases exponentially with time t. However, Algorithms 1 and 3 are quite stable. For example, the calculation error in [ 0 , 8000 ] is still very small.
In Algorithms 1 and 3, let n n = μ n n A , μ = 0.5 , 0.25 , 0.125 , where n n A is calculated according to (64). The numerical results are as follows.
Compared with Figure 7 and Figure 8, when μ = 0.5 , the calculation accuracy is not reduced by much, and the calculation speed is almost doubled. For μ = 0.125 Algorithms 1 and 3, the calculation accuracy is still high, and the calculation speed is 10 times higher than that in Figure 8.
Example  2.
In (8), let K = ( k i , j ) n × n be a tridiagonal matrix. F ( t ) = ( f 1 ( t ) , f 2 ( t ) , , f n ( t ) ) T , f i ( t ) = A i c o s ( ω i t + φ i ) ( i = 1 , 2 , , n ) , x 0 = x 0 , 1 , x 0 , 2 , , x 0 , n T , x 1 = x 1 , 1 , x 1 , 2 , , x 1 , n T , and they are randomly generated and satisfy the following conditions:
k i , i 9 1 , k i , i + 1 3 2 1 2 , k i + 1 , i 3 2 1 2 , A i 3 2 1 2 , ω i 5 2 1 2 , 0 φ i π 2 , x 0 , i 1 , x 1 , i 1 ( i = 1 , 2 , , n ) .
For n = 50 , 100 , 200 , and 400 , the following numerical results are provided by Algorithms 1 and 3.
In Figure 9, (1)–(4), the left is the first two components of the numerical solution, and the right is the difference between the numerical solutions obtained by the two algorithms. It is noted that sometimes ω i ( i = 1 , 2 , , n ) is close to the frequency of the solution, and flutter or resonance may occur. However, the values obtained by the two algorithms are still very close.

7. Conclusions

In this paper, we established algorithms for the computation of matrix exponential functions, matrix trigonometric functions, and matrix hyperbolic functions. Our numerical results show that these algorithms are faster with higher accuracy compared to existing algorithms and the system algorithms in Mathematica. In the series expansion of matrix function, the number of expanded items m p is only related to the requirement of calculation accuracy, and has nothing to do with the matrix itself. However, the number of times in the iterative process N p is not only related to the matrix itself but also closely related to t . When 3 n p λ A t 1 ( 2 n p λ A t 1 ), N p = 0 , the calculation of the matrix function becomes an algebraic operation, so the integral in (9)–(12) becomes an easy integral to compute. In brief, our algorithm allows users to set a required level of accuracy and then use it to choose appropriate values for parameters m and N to minimize computation time. In this manner, both accuracy and efficiency are addressed simultaneously.

Author Contributions

Conceptulation, H.Q. and Y.L.; mehtodology, H.Q. and Y.L.; software, H.Q.; validation, H.Q. and Y.L.; formal analysis, H.Q. and Y.L.; investigation, H.Q. and Y.L.; visualization, H.Q.; supervision, H.Q.; project administration, Y.L. All authors have read and agreed to the publication version of the manuscript.

Funding

This research received no external funding.

Institutional Review Board Statement

Not applicable.

Informed Consent Statement

Not applicable.

Data Availability Statement

Data are contained within the article.

Conflicts of Interest

The authors declare no conflict of interest.

References

  1. Ruiz, P.; Sastre, J.; Ibáñeza, J.; Defez, E. High performance computing of the matrix exponential. J. Comput. Applied Math. 2015, 291, 370–379. [Google Scholar] [CrossRef]
  2. Molert, C.; Loans, C.V. Nineteen dubious ways to compute the exponential of a matrix. SIAM Rev. Soc. Ind. Applied Math. 1978, 20, 801–836. [Google Scholar]
  3. Higham, N.J. Functions of Matrices: Theory and Computation; SIAM: Philadelphia, PA, USA, 2008. [Google Scholar]
  4. Al-Mohy, A.H.; Higham, N.J. Computing the Action of the Matrix Exponential, with an Application to Exponential Integrators. SIAM J. Sci. Comput. 2011, 33, 488–511. [Google Scholar] [CrossRef]
  5. Higham, N.J. The scaling and squaring method for the matrix exponential resisted. SIAM J. Matrix Anal. Appl. 2005, 26, 1179–1193. [Google Scholar] [CrossRef]
  6. Bader, P.; Blanes, S.; Casas, F. Computing the Matrix Exponential with an Optimized Taylor Polynomial approximation. Mathematics 2019, 7, 1174. [Google Scholar] [CrossRef]
  7. Seydaoglu, K.M.; Bader, P.; Blanes, S.; Casas, F. Computing the matrix sine and cosine simultaneously with a reduced number of products. arXiv 2020, arXiv:2010.00465v1. [Google Scholar] [CrossRef]
  8. Hargreaves, G.I.; Higham, N.J. Efficient algorithms for the matrix cosine and sine. Numer. Algorithms 2005, 40, 383–400. [Google Scholar] [CrossRef]
  9. Alonso, P.; Ibáñez, J.; Sastre, J.; Peinado, J.; Defez, E. Efficient and accurate algorithms for computing matrix trigonometric functions. J. Comput. Appl. Math. 2017, 309, 325–332. [Google Scholar] [CrossRef]
  10. Alonso, P.; Peinado, J.; Ibáñez, J.; Sastre, J.; Defez, E. Computing Matrix Trigonometric Functions with GPUs through Matlab. J. Supercomput. 2019, 75, 1227–1240. [Google Scholar] [CrossRef]
  11. Al-Mohy, A.H.; Higham, N.J.; Relton, S.D. New Algorithms for Computing the Matrix Sine and Cosine Separately or Simultaneously. SIAM J. Sci. Comput. 2015, 37, A456–A487. [Google Scholar] [CrossRef]
  12. Serbin, S.M.; Blalock, S.A. An algorithm for computing the matrix cosine. SIAM J. Sci. Statist. Comput. 1980, 1, 198–204. [Google Scholar] [CrossRef]
  13. Cooper, B.L.; Bingulac, S. Computational improvement in the calculation of the natural log of a square matrix. Electron. Lett. 1990, 26, 861–862. [Google Scholar] [CrossRef]
  14. Wu, F.; Zhu, L.; Shi, Q. Efficient Computational method for matrix function in dynamic problems. Acta Mech. Sin. 2023, 39, 522451. [Google Scholar] [CrossRef]
  15. Cardoso, J.R.; Sadeghi, A. A technique for improving the computation of functions of triangular matrices. Int. J. Comput. Math. 2022, 99, 2449–2465. [Google Scholar] [CrossRef]
  16. Jiang, Y.; He, C.; Qin, H. An accelerated algorithm for high precision and fast calculation of basic elementary functions. Math. Pract. Theory 2017, 47, 238–246. [Google Scholar]
  17. Fasi, M.; Higham, N.J. Multiprecision algorithm for Computing matrix logarithm. SIAM J. Matrixanal. Appl. 2018, 39, 472–491. [Google Scholar] [CrossRef]
  18. Ibáñez, J.; Sastre, J.; Ruiz, P.; Alonso, J.M.; Defez, E. An Improved Taylor Algorithm for Computing the Matrix Logarithm. Mathematics 2021, 9, 2018. [Google Scholar] [CrossRef]
  19. Cheng, S.H.; Higham, N.J.; Kenney, C.S.; Laub, A.J. Approximating the Logarithm of a Matrix to Specified Accuracy. SIAM J. Matrix Anal. Appl. 2001, 22, 1112–1125. [Google Scholar] [CrossRef]
  20. Kenney, C.; Laub, A.J. Condition estimates for matrix functions. SIAM J. Matrix Anal. Appl. 1989, 10, 191–209. [Google Scholar] [CrossRef]
  21. Kenney, C.; Laub, A.J. Padé error estimates for the logarithm of a matrix. Internat. J. Control. 1989, 50, 707–730. [Google Scholar] [CrossRef]
  22. Milovanović, G.V.; Rančić, S.L. Some improvements in calculation of the natural log of a square matrix. In Proceedings of the Third International Conference on Functional Analysis and Approximation Theory, Aquafredda di Maratea, Potenza, Italy, 23–28 September 1996; Issue 52. Volume II. [Google Scholar]
Figure 1. Error comparison of the algorithms in Table 1 for μ = 1 , 2 3 , 4 3 .
Figure 1. Error comparison of the algorithms in Table 1 for μ = 1 , 2 3 , 4 3 .
Appliedmath 04 00037 g001
Figure 2. Error of e A , cos A , and sin A for three algorithms.
Figure 2. Error of e A , cos A , and sin A for three algorithms.
Appliedmath 04 00037 g002
Figure 3. Error of sinh A   and   cosh A for three algorithms.
Figure 3. Error of sinh A   and   cosh A for three algorithms.
Appliedmath 04 00037 g003
Figure 4. Error of the tan A , sec A , tanh A , and s e c h A for two algorithms.
Figure 4. Error of the tan A , sec A , tanh A , and s e c h A for two algorithms.
Appliedmath 04 00037 g004
Figure 5. Error of cot A , cot A , csc A , and c s c h A f o r t w o a l g o r i t h m s .
Figure 5. Error of cot A , cot A , csc A , and c s c h A f o r t w o a l g o r i t h m s .
Appliedmath 04 00037 g005
Figure 6. Error of ln A for the several algorithms.
Figure 6. Error of ln A for the several algorithms.
Appliedmath 04 00037 g006
Figure 7. Error of numerical solution (8) for several algorithms ( n m is calculated according to (64)).
Figure 7. Error of numerical solution (8) for several algorithms ( n m is calculated according to (64)).
Appliedmath 04 00037 g007
Figure 8. Error of numerical solution (8) for several algorithms.
Figure 8. Error of numerical solution (8) for several algorithms.
Appliedmath 04 00037 g008
Figure 9. Numerical solutions and errors of two algorithms.
Figure 9. Numerical solutions and errors of two algorithms.
Appliedmath 04 00037 g009
Table 1. The fast algorithm for e A , cos A , sin A , cosh A , and sinh A .
Table 1. The fast algorithm for e A , cos A , sin A , cosh A , and sinh A .
m p , N p Algorithm
e A m p = 9 p ln 10 8 ln 2 , N p = N e + 1 ( 1 ) B = A 2 N p , C = I + j = 1 m p B j j !
( 2 ) f o r ( i = 0 , i < N , i + + ) C = C 2
( 3 ) e A = C
sin A sinh A m p = p ln 10 2 ln 3 , N p = N sin + 1 ( 1 ) B = A 2 3 2 N p , C = A 3 N + A 3 N j = 1 m p ( B ) j ( 2 j + 1 ) !
( 2 ) f o r ( i = 0 , i < N , i + + ) C = 3 C 4 C 3
( 3 ) sin A sinh A = C
( I ) cos A cosh A m p = p ln 10 2 ln 3 + 1 , N p = N sin ( 1 ) B = A 2 3 2 N p , C = I + j = 1 m p ( B ) j ( 2 j ) !
( 2 ) f o r ( i = 0 , i < N , i + + ) C = 4 C 3 3 C
( 3 ) cos A cosh A = C
( I I ) cos A cosh A m p = p ln 10 2 ln 3 + 1 , N p = N sin ( 1 ) B = A 2 3 2 N p , C = I + j = 1 m p ( B ) j ( 2 j ) !
( 2 ) f o r ( i = 0 , i < N , i + + ) C = C 2 I
( 3 ) cos A cosh A = C
N e = p ln 10 ( m p + 1 ) ln 2 + ln λ ln 2 ln ( m p + 1 ) ! ( m p + 1 ) ln 2 , N cos = p ln 10 ( 2 m p + 1 ) ln 2 + ln λ ln 2 ln ( 2 m p + 1 ) ! ( 2 m p + 1 ) ln 2 , N sin = p ln 10 ( 2 m p + 2 ) ln 3 + ln λ ln 3 ln ( 2 m p + 2 ) ! ( 2 m p + 2 ) ln 3 .
Table 2. The fast algorithms for tan A , sec A , tanh A , and s e c h A .
Table 2. The fast algorithms for tan A , sec A , tanh A , and s e c h A .
m p , N Algorithm
tan A tanh A m p = 2 p ln 10 ln 3 , N = N 1 + 1 B = A 2 3 2 N ,
C = 2 A 3 N j = 0 m ( ± 1 ) j σ ( j + 1 ) 4 j + 1 1 B j
f o r ( i = 0 , i < N , i + + )
C = C ( 3 I C 2 ) ( I 3 C 2 ) 1
tan A tanh A C
sec A sec h A m p = 2 p ln 10 ln 3 , N = N 2 + 1 B = A 2 3 2 N , I + j = 1 m ( 1 ) j E ^ j B j
f o r ( i = 0 , i < N , i + + )
C = C 3 ( 4 I 3 C 2 ) 1
sec A sec h A C
N 1 = p ln 10 + ln 2 σ ( m p + 2 ) ( 2 m p + 3 ) ln 3 + ln λ ln 3 , N 2 = p ln 10 + ln E ^ m p + 1 ( 2 m p + 3 ) ln 3 + ln λ ln 3 .
Table 3. The fast algorithms for cot A , coth A , csc A , and csch A .
Table 3. The fast algorithms for cot A , coth A , csc A , and csch A .
m p , N Algorithm
cot A coth A m p = 7 p ln 10 5 ln 3 , N = N 1 + 1 B = A 2 3 2 N , C = I 2 j = 1 m ( ± 1 ) j σ ( j ) B j
f o r ( i = 0 , i < N , i + + )
( C = 3 ( C ( 3 B C 2 ) ( B 3 C 2 ) 1 ; B = 9 B )
cot A coth A C
csc A csch A m p = 5 p ln 10 2 ln 3 , N = N 2 + 1 B = A 2 3 2 N , I + 2 j = 1 m + 1 ( ± 1 ) j σ ( j ) 1 2 4 j B j
f o r ( i = 0 , i < N , i + + )
( C = 3 C 3 ( 3 C 2 4 B ) 1 ; B = 9 B )
csc A csch A C
N 1 = p ln 10 + ln 2 σ ( m p + 2 ) ( 2 m p + 3 ) ln 3 + ln λ ln 3 , N 2 = p ln 10 + ln E ^ m p + 1 ( 2 m p + 3 ) ln 3 + ln λ ln 3
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Share and Cite

MDPI and ACS Style

Qin, H.; Lu, Y. An Efficient Algorithm for Basic Elementary Matrix Functions with Specified Accuracy and Application. AppliedMath 2024, 4, 690-708. https://doi.org/10.3390/appliedmath4020037

AMA Style

Qin H, Lu Y. An Efficient Algorithm for Basic Elementary Matrix Functions with Specified Accuracy and Application. AppliedMath. 2024; 4(2):690-708. https://doi.org/10.3390/appliedmath4020037

Chicago/Turabian Style

Qin, Huizeng, and Youmin Lu. 2024. "An Efficient Algorithm for Basic Elementary Matrix Functions with Specified Accuracy and Application" AppliedMath 4, no. 2: 690-708. https://doi.org/10.3390/appliedmath4020037

Article Metrics

Back to TopTop