Approximation of Directional Step Derivative of Complex-Valued Functions Using a Generalized Quaternion System

The step derivative of a complex function can be defined with various methods. The step direction defines a basis that is distinct from that of a complex number; the derivative can then be treated by using Taylor series expansion in this direction. In this study, we define step derivatives based on complex numbers and quaternions that are orthogonal to the complex basis while simultaneously being distinct from it. Considering previous studies, the step derivative defined using quaternions was insufficient for applying the properties of quaternions by setting a quaternion basis distinct from the complex basis or setting the step direction to which only a part of the quaternion basis was applied. Therefore, in this study, we examine the definition of quaternions and define the step derivative in the direction of a generalized quaternion basis including a complex basis. We find that the step derivative based on the definition of a quaternion has a relative error in some domains; however, it can be used as a substitute derivative in specific domains.


Introduction
It is difficult to directly identify targets in the complex domain. Thus, there is significant reluctance in using complex numbers when performing practical calculations. However, to obtain a better solution to the problem of real-valued finite difference approximation, the use of complex numbers for computational purposes plays an important role. Several studies have used the complex domain to explain various physical phenomena, and it can be confirmed that the expression of a phenomena using complex numbers is more efficient than the expression of it by using real numbers (see [1][2][3][4][5]). The use of complex variables to develop estimates of derivatives through complex step approximation started with the study by Lyness and Moler [6] and Lyness [7], wherein they introduced several methods using complex variables, including the calculation of the nth derivative of an analytic function. Consequently, based on the methods introduced by [6,7], Squire and Trapp [8] derived a simple expression for estimating the first derivative of complex variables. They found that the estimates were suitable for use in modern numerical calculations. Subsequently, various recent studies have used a complex step approach in engineering fields. Anderson et al. [9] and Newman et al. [10] used sensitivity analysis in a multidisciplinary environment of computational fluid dynamics. Martins et al. [11,12] examined the results by studying the derivation of the step derivative and the complex direction for a real function by using the Taylor series expansion concurrently. A complex step differential approximation and its application to a numerical algorithm were presented (see [13][14][15][16]). The first derivative can be determined through a complex step-differential approximation, and the analysis accuracy can be verified. In order to improve the analysis accuracy, the difference in the step derivative in the complex direction, considering the real function in the numerical algorithm ( [17,18]), was treated based on the Taylor series of expansion. The complex step approximation approach offers four primary advantages over the standard finite difference method [19,20].
The complex step derivative for real functions is suitable for representing the numerical derivative of real functions because the imaginary unit is distinguished from the real line. Therefore, in this study, we propose a step derivative for a complex function as an extension of the step derivative of a real function. In particular, a limitation exists in setting the direction of the step when deriving the complex step derivative of the complex function because the step direction is not independent of the complex function. Therefore, in previous studies, the step derivative was derived by defining an imaginary number that is distinct from the imaginary number constituting a complex number (see [19,20]). These studies proposed a multicomplex number expressed as C n = {z 1 + z 2 i n | z 1 , z 2 ∈ C n−1 }. By defining i 2 n = −1, each i n is treated as an imaginary number of different dimensions in order to form a step derivative. Based on this, the step derivative was extended by using a unit that was distinguished from i, constituting a complex number. In 1894, the quaternion was proposed by Hamilton as an extension of the complex number systems, and various algebraic and analytic research results had subsequently been derived. The application of complex variables to develop estimates of the derivatives used by the Taylor series expansion has also been extensively studied. Kim et al. [21][22][23] investigated the composition and properties of the regularity of quaternion functions based on the algebraic features of quaternions. They suggested that the function limit and derivative of the quaternionic functions can be defined on various forms of quaternions. For example, the non-commutativity of a product in quaternions is a typical characteristic of quaternionic functions. Therefore, they applied differentiation calculations and the results of various types of differential operators to theorems in order to replace the definition of differential properties .
In 2020, Roelfs et al. [24] proposed a quaternion-step derivative by defining the geometric algebra G(R 3 ). Orthogonal basis vectors e i (i = 1, 2, 3) satisfying e 2 i = 1 and e i e j = −e j e i for i = j were suggested. By using the non-commutativity of orthogonal basis vectors e i , the bivectors e i can be associated with the quaternion q = a + ib + jc + kd such that the following is the case.
The imaginary unit i of the complex numbers is denoted by i := e 1 e 2 e 3 , known as the pseudoscalar of G(R 3 ). In [24], the complex basis i is treated separately based on the quaternion, that is, the complex basis i is treated as a scalar considering the quaternion. This indicates that the complex basis i and quaternion base i, j, k are treated as individual bases that are commutative and independent of the product. However, in this study, we consider quaternions as extensions of complex numbers, indicating that the imaginary number i defined in the complex function is the basis for constituting the quaternion and is treated as a basis with non-commutativity for the product of j and k. The set H of the quaternions is defined as follows: Considering the structure of the quaternion, i, j, and k are independent of each other and are the basis of the orthogonal unit of the quaternion. Thus, the base i of the complex number and bases j and k of the quaternions are mutually transformed. Previously defined step derivatives for complex functions use a setup in which the quaternion and the complex bases are commutative. Consequently, it is difficult to apply the properties of the quaternion function because it is difficult to use a quaternionic elementary function that utilizes the definition of the actual quaternion by applying its non-commutativity. Furthermore, motivated by Roelfs' results, Kim [25] have focused on the underlying properties of quaternions by considering the basis of the definition of the quaternions. Thus, we defined the step derivative in the quaternion direction and evaluated its accuracy by considering the complex function using various examples. In [25], a step derivative limited to j was studied. Considering the characteristics of the quaternion structure, more diverse quaternion directions can be configured. Kim defines the step derivative using only a part of the quaternion basis; therefore, the quaternion function used as an example is not defined in the whole quaternion system. Compared to the step derivative used in the previous study, it can be confirmed that the region where the relative error exists is wide, and the magnitude of the relative error in that region is large.
In this study, we aim to determine the quaternion step derivative for a complex function using a generalized setting of the step size in the quaternion direction and to examine the relative error by using the derivative defined in complex analysis. In Section 2, the step derivative is first presented by the generalized quaternion (j, k)-direction, which is defined by bj + ck, where b, c ∈ R and r := b 2 + c 2 are the squares of the norm of bj + ck. Since the derivative of the complex function is defined in the complex system, as presented in [26], the generalized quaternionic step derivative is expressed by using the properties referring to the orthogonality and non-commutativity of i, j, k and specifying the terms included in the Taylor series expansion in the complex system. Moreover, using the definition of the generalized quaternionic step derivative, we examine the generalized quaternionic step derivatives of elementary functions such as e z , sin z, and cos z as defined in the complex analysis. In Section 3, we calculated the value of the derivative at any point to examine the use of generalized quaternionic step derivatives. In addition, we investigated the relative error between the derivative value calculated from the derivative based on the limit definition in the complex analysis and the generalized quaternionic step derivative value. Furthermore, in order to visually estimate the range of occurrence of relative error and its size, a picture using Maple programming was implemented. Additionally, Section 3 considers f (z) = e z / cos 3 z + sin 3 z as an example; this is a common example used in many studies on step derivatives of complex functions. We determined the step derivative by considering f (z) = e z / cos 3 z + sin 3 z as the step derivative proposed in this study. The relative error with the derivative in the complex analysis is calculated from the result, and the use and effectiveness of the generalized quaternionic step derivative are confirmed by using the visualization. In Section 4, the generalized quaternionic step derivative proposed in the previous sections is considered, and the characteristics of the derivative, depending on the direction and magnitude of the step direction of the Taylor series expansion, are summarized. Based on this, we will be able to define the step differential in the basic directions of various Clifford algebras in the future and reveal a plan to investigate the accuracy and utility of these derivatives.

Generalized Quaternionic Step Derivative in the (j, k)-Direction
We derive the derivative set in the step direction by using a linear combination of the bases j and k of the quaternions that are distinguished from the base of the complex number. The Taylor series expansion for a holomorphic function on C is written as follows.
For z ∈ C, h ∈ R and any b, c ∈ R, we have the following: where any real numbers b, c, and r > 0 satisfy b 2 + c 2 = r. Therefore, we obtain the following Let [ ] C : H → C referenced in [25] be a function known as the complex part of · that outputs a complex element among the input quaternions.
For example, [a + bi + cj + dk] C = a + bi. Thus, we consider the complex part of both sides of the Taylor series Expansion (1). Dividing it by h and r yields the following definition.
Proposition 1. Let f : C → C be a complex function. For z ∈ C and any b, c ∈ R, f (z) is expressed by the following: which is known as the generalized quaternionic step derivative in the (j, k)-direction for a complexvalued function of a complex variable.
It is referred to as the generalized (j, k)-step derivative. The term O(h 2 )r approaches zero when each of h and r are sufficiently small to approximately obtain the correction O. The generalized quaternion (j, k)-step derivative can be used to infer the approximation of the derivative of a complex function without considering the limit of the difference. However, a deviation from the actual value occurs owing to the error term O(h 2 )r. The term O(h 2 )r with order h 2 or higher can be ignored because the interval h and r can be chosen to approximately machine precision. Hence, the approximation is an O(h 2 )r estimate of the derivative of f . The second-order errors in the function derivative (2) can be eliminated when using finite precision arithmetic by ensuring that h and r are sufficiently small. However, if ε is the relative working precision of a given algorithm, in order to make the truncation error of the derivative estimate vanish, we require the following.
Although steps h and r can be set to extremely small values, it is not always possible to satisfy these conditions, especially when f (z) approaches zero. Therefore, using several examples, we examined whether the generalized quaternion (j, k)-step derivative is different from the typical definition of the derivative of a complex function in complex analysis. In addition, the region that minimizes O(h 2 )r is examined according to the range wherein h and r are defined.
Using the definition of the generalized (j, k)-step derivative, we present the step derivatives of the following elementary functions. Example 1. For z = x + yi ∈ C, we find that the generalized (j, k)-step derivative for the exponential function f (z) = e z is denoted by the following.
We refer to the definition of the elementary functions of a quaternion variable summarized in [27]. Considering quaternion q = x + yi + bhj + chk and b 2 + c 2 = r, the function e q is defined as follows. e q = e x cos y 2 + rh 2 + yi + bhj + chk y 2 + rh 2 sin y 2 + rh 2 .
Using the definition of the generalized (j, k)-step derivative, we obtain the following: −e x cos y 2 + rh 2 (bj + ck) where σ = y 2 + rh 2 .

Example 2.
Thereafter, using the definition of the cosine function of a quaternion variable, we obtain the following: where σ = y 2 + rh 2 . Furthermore, in order to obtain the generalized (j, k)-step derivative of the cosine function for a complex variable, we calculate the following.
Therefore, considering z = x + yi ∈ C, the generalized (j, k)-step derivative of f (z) = cos z is obtained as follows.
Therefore, the generalized (j, k)-step derivative of sin z is expressed as follows.
The aforementioned examples induce the generalized (j, k)-step derivative of the elementary functions e z , cos z, and sin z. In order to verify the value of each step derivative at any point, we find the value of each generalized (j, k)-step derivative at z 0 = π/4 + iπ/3, which has been often used in previous studies on the step derivative of a complex function.

Relative Error Examples for the Generalized (j, k)-Step Derivative
In this section, considering Examples 1-3, we determine each generalized (j, k)-step derivative value at z 0 , the relative error between the value of the derivative at z 0 derived by the step derivative according to h and r, and the value of the derivative in the typical definition of the complex derivative in complex analysis. Let f exac (z) be the exact value of the derivative based on the definition of differentiation in complex analysis. Thereafter, the relative error, denoted by Err( f , z 0 ), is expressed as follows.
Regarding z 0 = π 4 + π 3 i, the generalized (j, k)-step derivative of e z is the following: Considering the function f (z) = e z , the relative error Err(e z , z 0 ) is written as follows.
Err(e z , z 0 ) = e − π 4 e π 2 sin σ 0 Figures 1 and 2 present the relative error between f exac (z 0 ) and the generalized (j, k)step derivative f (z 0 ) of e z at z 0 = π 4 + i π 3 , considering h and r, respectively, by using the Maple program.
Considering Figures 1 and 2, according to h and r, Err(e z , z 0 ) cannot be completely approximated as 0; nevertheless, considering an arbitrary r > 0, when h lies in the range of − 3π 2 ≤ h ≤ − π 2 and π 2 ≤ h ≤ 3π 2 , the relative error Err(e z , z 0 ) has values close to 0. Considering z 0 = π 4 + i π 3 , the generalized quaternionic step derivative in the (j, k)direction for cos z is the following: where σ 0 = ( π 3 ) 2 + rh 2 . The relative error Err(cos z, z 0 ) of cos z at z 0 is expressed as follows.
. Figures 3 and 4 show the relative error Err(cos z, z 0 ) between f exac (z 0 ) and the generalized (j, k)-step derivative of cos z at z 0 considering h and r, respectively, by using the Maple program. As shown in Figures 3 and 4, it is possible to observe how the value of Err(cos z, z 0 ) changes considering h and r, which are independent of each other. In particular, Figure 4a shows that considering r > 0, Err(cos z, z 0 ) vanishes when the step size h is in the range of (−9π/8, 9π/8). As shown in Figure 4b, regarding h(h ∈ R and −2π < h < 2π), when the step direction magnitude r is less than π/2, Err(cos z, z 0 ) becomes 0.
The generalized quaternionic step derivative in the (j, k)-direction for sin z at z 0 = π 4 + i π 3 is as follows: The relative error Err(sin z, z 0 ) for the generalized (j, k)-step derivative of sin z is obtained as the following.
. Figures 5 and 6 present the relative error Err(sin z, z 0 ) of the generalized (j, k)-step derivative of sin z for z 0 , considering h and r, respectively, by using the Maple program.   Figure 6 shows the values of the relative error Err(sin z, z 0 ) between the generalized (j, k)-step derivative of sin z and f exac for each h and r. Considering r > 0, Err(sin z, z 0 ) vanishes when the step size h is in (−11π/8, 11π/8). Moreover, regarding h(−2π < h < 2π), when the step direction magnitude r is less than 7π/8, Err(sin z, z 0 ) becomes 0.
The step differentiation proposed in this study is applied to the representative examples considered in the previous studies on step differentiation. In order to induce the generalized quaternionic step derivative of f in the (j, k)-step direction for z 0 = π/4 + iπ/3, we proceed with the following. f (z + (bj + ck)h) = e z+(bj+ck)h cos 3 (z + (bj + ck)h) + sin 3 (z + (bj + ck)h) .
Thereafter, the generalized (j, k)-step derivative of f is expressed as follows: where v = iy + jbh + kch and the following is the case.
In this example, we derived the relative error Err( f (z), z 0 ) between the definition of the derivative at z 0 and generalized (j, k)-step derivative for a particular function. The results of the relative error according to h and r in z 0 are shown in Figure 7 and Figure 8, respectively, using the Maple program. Considering Figures 7 and 8, the derivative value of f resulting from the generalized (j, k)-step derivative has an error with the derivative value calculated using the definition of the actual derivative. However, it is evident that the range of the relative error Err( f (z), z 0 ) independently decreases similarly to the range of h and r. Regarding h = 0, the value of the relative error Err( f (z), z 0 ) is symmetric, and when h is approximated to 0, it has a relative error of Err( f (z), z 0 ), which is close to 0 regardless of r. In addition, as r decreases, it has a relative error of Err( f (z), z 0 ) close to 0 over a wider range of h.

Conclusions
We attempted to calculate the derivative of a complex function based on a numerical algorithm. A formula for deriving the first derivative of a complex function was defined using the characteristics of the Taylor series expansion. The quaternion defined by extending the complex number is an algebra that includes the basis i of the complex number and other bases j and k, the product of which is non-commutable. A complex function is related to i; nonetheless, considering each of j and k, the complex function is interpreted in different dimensions such that we can define a step derivative in the quaternionic direction for the complex function. Therefore, the step derivative of the complex function was expressed by applying the basis direction of the quaternions distinguished from the basis i of the complex function.
Furthermore, we defined the generalized quaternionic step derivative of complexvalued elementary functions. By determining the value of the generalized quaternionic step derivative at a point, we verified the applicability of the step derivative and calculated it for various elementary functions. Consequently, because of the independent roles of h and r, the quaternionic step derivative of the complex functions was compared to the typical definition of the derivative of the complex functions while considering the error. It was possible to consider the independent ranges for h and r, resulting in similar derivative values at the same point. By applying the definition of the generalized quaternionic direction step derivative to an example ( f (z) = e z / cos 3 z + sin 3 z) that had often been used in previous studies, the value of the derivative of a complex function at a point was compared to previous studies. We obtained and visualized the relative error between the derivative value based on the derivative definition in complex analysis and the step derivative value in the direction defined in the present study. Moreover, we concluded in this study that the generalized quaternionic direction step derivative can be used within the relative error range, replacing the determination of the derivative with the typical definition of complex functions. Contrary to the step derivative asserted in previous studies, the step derivative herein uses the quaternion, which is an expansion algebra of a complex number, indicating a step direction clearly distinct from the complex number. This can clarify the existing complex number; moreover, it suggests another application of the quaternion system by applying the characteristics of quaternions to the step derivative.
The step derivative was defined by setting the step direction to the generalized direction of the quaternion basis. However, relative errors still exist in some areas. It is necessary to compare the bases of various modified quaternions derived from the quaternions, such as the split quaternion, dual quaternion, and generalized quaternion, and to secure a base that can reduce the relative error among these bases. Additionally, because the Taylor series for quaternionic functions are being studied in various ways, it is possible to derive the step derivative of quaternionic functions. Based on the present results, in the future, we intend to define step derivatives for complex functions by proposing various types of quaternionic directions, such as matrix, polar, and Cullen forms, based on quaternions. In addition, we aim to define the step derivative for the quaternion-valued function in the Clifford algebraic direction by defining the Taylor series expansion for the quaternionic function and to derive the step derivative to replace its differential operator. This ensures the versatility and applicability of the step derivative and its variations. This can also provide a tool that can replace the calculation and derivation of the derivative value for the quaternionic function. This has been a challenge because of the characteristics of the quaternion system. In addition, because substitutable derivatives can be derived for the quaternion system, it is expected that the step derivative proposed in this study can be used in the detection of certain errors in discrete orthogonal conjugate nets and isothermal immersions, etc., where derivatives are utilized.