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:
where
, and
K are n by n square matrices, and
denotes the external force applied. The introduction of dual variables of a Hamiltonian system,
results in the following system:
where
The solution of (3) is provided as follows:
When a problem is oscillatory, the formal solution often involves both the sine and cosine of a matrix. Famous examples include the Schr
dinger equation in quantum mechanics:
where
is a Hermitian operator and
is a complex wave function. If
is a real and constant matrix, the solution of (6) is as follows:
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:
where the solution is provided by the variation of the constant method:
where
If
A is invertible, then (9) can be written as follows:
For (5), providing
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:
Similarly, for (10), providing the algorithm
as accurately as possible involves introducing vectors
and the following algorithm:
To improve the accuracy of
and
, it is essential to develop an algorithm with high accuracy for computing
and
and the integral containing these matrix functions. This paper improves the algorithms developed for the computation of
and
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
specifying property,
If
is an approximation as close as possible to
with
N as a positive integer, for example,
or
being the Padé approximation of
then the following calculations are performed:
Completing (14) and (15),
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
Now, we have the following:
or
is the Padé approximation of
Our objective is to determine
m and
N to minimize the computation time under the condition that the truncation error and computational precision are
. 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
is
K, then the total number of times to complete (16) and (15) is roughly
where
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 be an integer close to the minimum point of , whereand (1) , where or is a Padé approximation of
(2) for() and
The above algorithm is a fast algorithm for the general matrix function.
Proof. With a truncation error of
, for (16) to be satisfied,
where
is a norm of
So,
From (17), we obtain the following:
Note that the minimum point of
has nothing to do with
. By making
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, can be replaced by the approximate eigenvalue with the maximum modulus in this paper. 3. Fast Algorithm for and
Suppose
is a norm for
A. If we let
then
. From (19), we can obtain the following:
In order to reduce the length of the article, the algorithms for several matrix functions are compiled into a table.
Theorem 2. For , and we devised the following fast algorithm using Theorem 1.
Remark 2. It is worth noting that 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
and
We calculate the formulas for
and
for the function
for
here. In fact, the graphing of the function of
supports our results for all values of
The derivation of
and
for the other functions is very similar.
(1) For the function
we have
and
Using Sterling’s approximation formula, we obtain the following:
Now, implementing it into (25), we obtain the following:
Taking its derivative with respect to
one obtains
To determine extreme values, we set it to 0 and multiply both sides by
Using simple algebra, we obtain the following:
Using
we obtain a lower bound for
Thus, we have a lower bound for
m:
We also can solve the quadratic equation to get
Now, using the smallest value for m obtained and
we can obtain our first upper bound:
We can again use the values of
m and
to update the lower bound of
m as follows:
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
, and we can safely claim that m
. Our following numerical calculation supports this claim completely.
Case (a): Using the formula obtained by the quadratic formula and the upper bound , we obtain a new lower bound: Using the formula obtained by the quadratic formula and lower bound we can also obtain the upper bound: Using our claim we obtain This clearly matches the lower and upper bound quite well.
Case (b): Using the formula obtained by the quadratic formula and the upper bound , we obtain a new lower bound: Using the formula obtained by the quadratic formula and lower bound we can also obtain the upper bound: Using our claim we obtain These values match very well for taking the closest integer.
Case (c): Using the formula obtained by the quadratic formula and the upper bound , we obtain a new lower bound: Using the formula obtained by the quadratic formula and lower bound we can also obtain the upper bound: Using our claim we obtain
Case (d): Using the formula obtained by the quadratic formula and the upper bound , we obtain a new lower bound: Using the formula obtained by the quadratic formula and lower bound we can also obtain the upper bound: Using our claim we obtain
Using
we can obtain
(2) For
we have
and
In this case, for
and 32, the corresponding integer points for
to achieve its minimum value are
and 6. Again, it can be estimated that
(3) For there are two cases:
Case (I): and (29) hold. Compared to I, the values in the second part of are very small, so we may replace N with , and with .
Case (II):
and
Similarly, for
and 32, the corresponding integer points for
to achieve its minimum value are
and 7. Consequently, we can determine the following:
The effectiveness of the algorithms is displayed in
Table 1 by implementing numerical computations in Mathematica.
and
are replaced with
in
Table 1, defined correspondingly by
where one has
and
For comparison, let
A take the following form:
where
U is a randomly generated n by n matrix,
is a randomly generated n by n diagonal matrix with
, so
In all the examples in this paper, we agree on the relative error as follows:
Let
be
M matrices produced by (32). From
Figure 1, it is evident that the calculation accuracy is essentially the same for
, but
provides the highest efficiency. The double-angle formula is notably more efficient and accurate than the triple-angle formula for
. Henceforth, we will exclude the case that utilizes the triple-angle formula for
.
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
denote the calculation error of matrix function
, where a blank
g implies the utilization of the algorithms in
Table 1,
Table 2 and
Table 3 of this article. If
,
,
it signifies calculation according to the internal function, Padé approximation,
respectively. When
for
respectively. We denote the Padé approximation of
as
and the Padé approximation of
and
as
In
Table 1, the Padé approximation of
is as follows:
For the algorithms in
Table 1, the
of random matrix from order 1 to 800 is as follows.
It is evident from
Figure 2 that, for
and
, 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
, 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
and
using the internal functions
and
is faster than that of the internal functions
and
, their calculation accuracy is relatively poor.
For
and
, the internal functions can be calculated by utilizing the following equation:
Our experiment provides the following results for
of random matrices with orders from 1 to
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 , and
Now let us contemplate the swift computation of
,
, and
. Although these matrix functions can be computed using the following approach, we aim to directly compute them, as demonstrated in the previous section.
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 , and we have the following fast algorithm based on Theorem 1.
In
Table 2, for
and
, we have the following recursive formula [
1]:
Using the algorithms in
Table 2, our experiments generated the following data for the
of random matrices from order 1 to 200.
Here,
indicates that matrix functions
,
,
, and sech
expressed by
,
,
and
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
and
, 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
and
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
,
, and csch
A. By
we see that when
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:
where
Theorem 4. Using Theorem 1, we have the following algorithm for and .
Implementation of the algorithms in
Table 3 provides the following results for the matrix functions in (39).
Here,
signifies that matrix functions
,
,
, and
are calculated using the internal functions with the regular formulas
,
,
, and
respectively. The results in
Figure 5 are essentially consistent with the corresponding results in
Figure 2.
6. Improved Calculation Formula for Initial Value Problems (3) and
(8)
Now, let us consider the calculation of the integral in (11), i.e.,
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
, there is the following relationship:
where
can be calculated by the following method:
So, (53) can be written as follows:
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:
where
is calculated by the algorithm in
Table 1, and
are calculated by (55) and (56).
For
the following two algorithms can be used.
(1) Integrable function method If
is the algebraic sum of functions of the following types:
then (58) can be expressed in analytical form, so
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,
and the algebraic accuracy of the Gauss three-point integral formula is 5. Using the Gauss three-point integral formula,
where
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
whereIn particular, if we letthen At this time, the theoretical calculation accuracy of (62) is Remark 3. Note that, in (63) and (65) only needs to be calculated once, and is independent of , 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
By
where
and (68), we obtain the following algorithm.
andwhere and are determined using (31).Algorithm 3. Numerical solution algorithm of initial value problem (8):
for where In particular, if is determined using (64), the theoretical accuracy of this algorithm is p andwhereand If A is reversible, thenTherefore, (75) can be written in the form of complex function as follows:orwhere 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.
The analytic solution of the initial value problem (8) is
Let
where
are the numerical solutions of the initial value problem (8) determined by Algorithm 1 and Algorithm 3, respectively.
where
is the numerical solution obtained by calling the function
in Mathematica. The numerical results of
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
. After this point, the error increases exponentially with time
t. However, Algorithms 1 and 3 are quite stable. For example, the calculation error in
is still very small.
In Algorithms 1 and 3, let , where is calculated according to (64). The numerical results are as follows.
Compared with
Figure 7 and
Figure 8, when
, the calculation accuracy is not reduced by much, and the calculation speed is almost doubled. For
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 be a tridiagonal matrix. , , , , and they are randomly generated and satisfy the following conditions:
For
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
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.