Nested formulas for cosine and inverse cosine functions based on Viète's formula for π
NNested formulas for cosine and inverse cosinefunctions based on Vi`ete’s formula for π Artur Kawalec
Abstract
In this article, we develop nested representations for cosine and inversecosine functions, which is a generalization of Vi`ete’s formula for π . Weexplore a natural inverse relationship between these representations anddevelop numerical algorithms to compute them. Throughout this article,we perform numerical computation for various test cases, and demonstratethat these nested formulas are valid for complex arguments and a k thbranch. We further extend the presented results to hyperbolic cosineand logarithm functions, and using additional trigonometric identities,we explore the sine and tangent functions and their inverses. In 1593s, Vi`ete developed an infinite nested radical product formula for π givenas 2 π = √ (cid:112) √ (cid:113) (cid:112) √ · · · , (1)which, historically, may have been the first infinite series for π . Vi`ete derived thisformula geometrically by means of approximating areas of an n -sided polygoninscribed in a circle, and obtaining a successive sequence of ratios of areas of2 n -sided polygon to an n -sided polygon that is converging to an area of a circle,from which 2 /π follows as a converging value as n → ∞ [2]. Subsequently, Euleralso developed a new proof of Vi`ete’s formula using trigonometric identities andinfinite products, namely, Euler found a product identitysin( x ) x = ∞ (cid:89) n =1 cos (cid:16) x n (cid:17) = cos (cid:16) x (cid:17) cos (cid:16) x (cid:17) cos (cid:16) x (cid:17) . . . , (2)where by a repeated application of the half-angle identity for cosinecos (cid:16) x (cid:17) = ± (cid:114) − cos( x )2 (3)the Vi`ete’s formula for π is obtained by substituting x = π/
2. Since then,there may have been perhaps dozens of variations of nested radical formulas1 a r X i v : . [ m a t h . G M ] J u l ublished in the literature, and the main theme behind these formulas is arepeated application of the half or double angle identity for cosine function,which is a starting point of this article.We will derive a nested formula for cosine function ascos( x ) = lim n →∞ (cid:40) − . . . + 2 . . . (cid:16) − (cid:16) − (cid:16) − x n +1 (cid:17) (cid:17) (cid:17) ... (cid:41) (4)which is an entire function, valid for complex x . In this notation, the dottedsymbol . . . implies an n th nested recursion of the type − x until the innerterm 1 − x / n +1 is reached. Secondly, we will derive a nested formula for aninverse cosine function ascos − ( y ) = lim n →∞ n (cid:118)(cid:117)(cid:117)(cid:117)(cid:117)(cid:117)(cid:116) − (cid:118)(cid:117)(cid:117)(cid:117)(cid:117)(cid:116) (cid:118)(cid:117)(cid:117)(cid:117)(cid:116) (cid:118)(cid:117)(cid:117)(cid:116) (cid:32) (cid:114)
12 (1 + . . . y ) (cid:33) , (5)that is also valid for a complex y . In this notation, the dotted symbol . . . impliesan n th nested recursion of the type (cid:113) (1 + y ) until the outer term 2 n (cid:112) − y )is reached. Hence, in this view, the Vi`ete’s formula is essentially a statement ofcos − (0) = π/
2, but is originally presented as a reciprocal (1) and the squareroots factored out. As it is seen, there is a natural inverse relationship betweenrepresentations (4) and (5), as one can transform one form to the other byunraveling the outer terms into inner terms of its inverse. There is also closelyrelated variation of (5) for an inverse cosine derived by Levin in [3] by means ofa nested application of a certain hypergeometric function.Throughout this article, we will also develop computer algorithms in Matlabsoftware package to compute the presented formulas numerically. The simplicityof the code can easily be ported to any programming language. We will furtherextend the nested inverse cosine function (5) to be valid for a k th branch bymeans of a Gray code alternating sign function, which will be explored in moredetails. Although the main focus of this article is the cosine function and itsinverse, we will further extend the main cosine formulas using basic trigono-metric identities to other functions, such as the sine and the tangent, and theirhyperbolic counterparts, as well as the nested logarithm function, and brieflymention the exponential function to complete the set of these nested formulas.Finally, we will summarize all the formulas in Appendix A. In this section, we will develop the nested formula for cosine (4). First, were-write the half-angle identity for cosine function (3) ascos( x ) = − (cid:16) x (cid:17) , (6)2hich can also be written ascos( x ) = T (cid:16) cos (cid:16) x (cid:17)(cid:17) (7)for n = 1 order, where the function T ( x ) can be identified as a second orderChebyshev polynomial of the first kind as T ( x ) = − x , (8)but we shall just refer to it as T ( x ), since in this paper, we only work with thehalf-angle identity for cosine (6). More details about Chebyshev polynomialscan be found in [1]. We then observe that if we recursively iterate T ( x ) again,then we can recover the cosine function ascos( x ) = T (cid:16) T (cid:16) cos (cid:16) x (cid:17)(cid:17)(cid:17) , (9)which yields an expansioncos( x ) = − (cid:16) − (cid:16) x (cid:17)(cid:17) (10)for n = 2 order. If we repeat this process again, then we obtaincos( x ) = T (cid:16) T (cid:16) T (cid:16) cos (cid:16) x (cid:17)(cid:17)(cid:17)(cid:17) , (11)which yields an expansioncos( x ) = − (cid:16) − (cid:16) − (cid:16) x (cid:17)(cid:17) (cid:17) (12)for n = 3 order. Hence, in general, we can write the cosine function as the n thorder iterate of T ( x ) as cos( x ) = T ◦ n (cid:16) cos (cid:16) x n (cid:17)(cid:17) , (13)where the n th iteration on T is defined as a recursive composition T ◦ k ( x ) = T ( x ) ◦ T ◦ k − ( x ) , k > T ◦ ( x ) = f ( x ) , k = 0 , (15)where f ( x ) is the inner most function which is cos( x n ), and it rapidly approaches1 as n → ∞ . We also know that the Maclaurin (Taylor) series for cos( x ) about x = 0 is cos( x ) = 1 − x
2! + x − x
6! + ..., (16)hence it suffices to use the first two terms as an approximation for the innerterm as cos (cid:16) x n (cid:17) ≈ − x n +1 . (17)3s a result, by substituting the inner term approximation (17) back to the infi-nite nested product (13) we obtain the main nested formula for cosine functioncos( x ) = lim n →∞ T ◦ n (cid:16) − x n +1 (cid:17) . (18)We further observe that when the nested product formula (18) is expanded, itapproaches the Maclaurin series for cosine (16). For example, for n = 0 we startwith inner approximation for cosine ascos( x ) ≈ − x . (19)For n = 1 we obtain an expansioncos( x ) ≈ − (cid:16) − x (cid:17) ≈ − x + 132 x . (20)For n = 2 we havecos( x ) ≈ − (cid:16) − (cid:16) − x (cid:17) (cid:17) ≈ − x + 5128 x − x + 1131072 x . (21)And, for n = 3 we havecos( x ) ≈ − (cid:16) − (cid:16) − (cid:16) − x (cid:17) (cid:17) (cid:17) ≈ − x + 21512 x − x + 1658388608 x − ..., (22)where higher order terms from 10 to 16 have been omitted. In fact, 2 n + 1 termsof approximated Maclaurin series are generated, which approach the Maclaurinseries as n → ∞ . One major advantage of this iterative process is that thefactorial for large n doesn’t have to be computed if one were to use the Maclaurinseries to compute the cosine function.In the next example, we numerically compute cos( π/
3) by application ofequation (18) for n = 4. First we begin to compute the inner term y , and thenrecursively apply the Chebyshev polynomial T ( x ) until we reach the outer termas y = 1 − ( π/ / = 0 . ,y = − y = 0 . ,y = − y = 0 . ,y = − y = 0 . ,y = − y = 0 . , (23)4ence we obtain the final result ascos( π/ ≈ . , (24)where we obtain accuracy to within three decimal places. Such accuracy couldbe reached with 4 terms of Maclaurin series. In next example, we repeat thecomputation for n = 10 case as y = 1 − ( π/ / = 0 . ,y = − y = 0 . ,y = − y = 0 . ,y = − y = 0 . ,y = − y = 0 . ,y = − y = 0 . ,y = − y = 0 . ,y = − y = 0 . ,y = − y = 0 . ,y = − y = 0 . ,y = − y = 0 . , (25)where we obtain accuracy to within 7 decimal places. The number of termof Maclaurin series to reach such accuracy is greater than 7, which requirescomputing factorial of 14 which is on the order of 10 , while 2 is on the orderof 10 .We can further improve convergence by approximating the inner cosine termswith more terms of Maclaurin series, for example, with 4 terms we have anapproximation to cosine ascos (cid:16) x n (cid:17) ≈ − x n
2! + x n − x n . (26)Hence, we again recompute the cosine as y = cos (( π/ / ) = 0 . ,y = − y = 0 . ,y = − y = 0 . ,y = − y = 0 . ,y = − y = 0 . , (27)where now we reached accuracy to within 12 decimal places. In essence, thismethod is similar to a convergence acceleration algorithm. Also, since it con-verges to Maclaurin series for the cosine function, it is therefore an entire func-tion valid in all complex plane. 5ext, we illustrate a practical algorithm developed in the Matlab softwarepackage, and the code can be easily implemented in any programming language.We define a function cos fx(x,k):
1: % This function evaluates cos(x)2: % x is the input argument (real or complex)3: % k=2^n (must be power of 2) where n is the order of nested product4: %5: function [y] = cos_fx(x,k)6:7: if k==18: y = 1-x^2/2; % Inner term approximation to cosine9: else10: y = -1+2*cos_fx(x/2,k/2)^2; % Recursively call Chebyshev polynomial of cos_fx11: end12:13: end
The code is similarly implemented as a factorial function recursively callingitself. We call this function for n = 4 as cos_fx(pi/3,2^4) = 0.499838043607131 where k = 2 n and must be a power of 2, and we thus repeat the result of (23).And similarly, we can improve the convergence by adding more terms of theinitial approximation to cosine as
1: % This function evaluates cos(x)2: % x is the input argument (real or complex)3: % k=2^n (must be power of 2) where n is the order of nested product4: %5: function [y] = cos_fx4(x,n)6:7: if n==18: y = 1-x^2/2+x^4/24-x^6/720; % Inner term approximation to cosine9: else10: y = -1+2*cos_fx4(x/2,n/2)^2; % Chebyshev polynomial of cos_fx411: end12:13: end which for n = 4 results in cos_fx4(pi/3,2^4)= 0.499999999998225 thus repeating the result of (27). 6 The nested inverse cosine
The nested product structure for the cosine function permits reversing the recur-sive process, resulting in a formula for an inverse cosine function. To illustratethis, we consider the inner cosine approximation (16) as y = cos( x ) ≈ − x , (28)then by solving for x , we obtain an initial approximation to inverse cosine func-tion x = cos − ( y ) as g ( y ) = (cid:112) − y ) , (29)which we consider for n = 0 order approximation. We also find an inverse ofthe Chebyshev polynomial T ( x ) as T − ( y ) = (cid:114) y . (30)If we consider the next higher order approximation (20) for n = 1, then we have y = cos( x ) ≈ − (cid:16) − x (cid:17) , (31)and by solving for x results in x = cos − ( y ) ≈ (cid:118)(cid:117)(cid:117)(cid:116) (cid:32) − (cid:114)
12 (1 + y ) (cid:33) . (32)If we consider the next higher order approximation (21) for n = 2, then we have y = cos( x ) ≈ − (cid:16) − (cid:16) − x (cid:17) (cid:17) (33)and by solving for x results in x = cos − ( y ) ≈ (cid:118)(cid:117)(cid:117)(cid:117)(cid:116) − (cid:118)(cid:117)(cid:117)(cid:116) (cid:32) (cid:114)
12 (1 + y ) (cid:33) . (34)If we consider the next higher order approximation (22) for n = 3, then we have y = cos( x ) ≈ − (cid:16) − (cid:16) − (cid:16) − x (cid:17) (cid:17) (cid:17) (35)and by solving for x results in x = cos − ( y ) ≈ (cid:118)(cid:117)(cid:117)(cid:117)(cid:117)(cid:116) − (cid:118)(cid:117)(cid:117)(cid:117)(cid:116) (cid:118)(cid:117)(cid:117)(cid:116) (cid:32) (cid:114)
12 (1 + y ) (cid:33) . (36)7ence, continuing on for an n th iteration, it is seen that by solving for x unravelsthe nested formula for cosine which directly results in a nested formula forinverse cosine function ascos − ( y ) = lim n →∞ n (cid:118)(cid:117)(cid:117)(cid:117)(cid:117)(cid:117)(cid:116) − (cid:118)(cid:117)(cid:117)(cid:117)(cid:117)(cid:116) (cid:118)(cid:117)(cid:117)(cid:117)(cid:116) (cid:118)(cid:117)(cid:117)(cid:116) (cid:32) (cid:114)
12 (1 + . . . y ) (cid:33) , (37)which also can be written ascos − ( y ) = lim n →∞ n g ( T − ◦ n ( y )) , (38)where g ( y ) = (cid:112) − y ) is the outer function evaluated only once at the end,and the inverse function T ( y ) − is recursively iterated an n number of times.Now it is clear that Vi`ete’s formula is essentially cos − (0) = π/
2, but wasoriginally presented as a reciprocal (1). Next, we numerically compute it for n = 4 as x = (cid:114)
12 = 0 . ,x = (cid:114) x . ,x = (cid:114) x . ,x = (cid:114) x . ,x = 2 (cid:112) − x ) = 1 . , (39)hence, the result is converging to π/
2. As another example, we compute cos − (0 . x = (cid:114) .
52 = 0 . ,x = (cid:114) x . ,x = (cid:114) x . ,x = (cid:114) x . ,x = 2 (cid:112) − x ) = 1 . , (40)hence, the result is converging to π/
3. As a result, we implement a simplefunction in Matlab acos fx(y,n) as 8 : % This function evaluates acos(y)2: % y is the input argument (real or complex)3: % n is the order of nested product4: %5: function [x] = acos_fx(y,n)6:7: for i = 1:n8:9: y = sqrt((y+1)/2) % Iterate inverse f(y) n number of times10:11: end12:13: x = 2^n*sqrt(2*(1-y)) % Outer term inverse cosine approximation g(y)14:15: end
We call this function for above values for n = 10 to obtain acos_fx(0,10) = 1.570796172805538 and acos_fx(0.5,10) = 1.047197505529385 where we obtain accuracy to 7 decimal places.Generally, the cosine function maps a real number interval ( −∞ , + ∞ ) onto aunit interval [ − , − ,
1] onto a real interval ( −∞ , + ∞ ) in smallsections, or branches, which are enumerated by an integer k . Hence, if y is ona unit interval [ − , k th branch, the mapping iscos − ( y ) = x + 2 πk. (41)For a principal branch k = 0, the mapping is [ − , → [ π, k = 1,the mapping is [ − , → [3 π, π ] and for k = 2 the mapping is [ − , → [5 π, π ], and so on. Also, the inverse cosine function is well-defined for a complexargument z as cos − ( z ) = π i log ( iz + (cid:112) − z ) (42)having a branch cut on real axis in an interval ( −∞ , −
1) and (1 , ∞ ). We findthat the formula for inverse cosine (37) converges to (42). For example, we takecos − (2) = 1 . i (43)while the formula (37) for n = 10 gives acos_fx(2,10) = 1.316956719106592i
9s another example, we takecos − (2 + 3 i ) = 1 . − . i (44)while the formula (37) for n = 10 gives acos_fx(2,10) = 1.000533856110922 - 1.982613299971578i We performed higher precision computation and it clearly converged to (37) forany value we tried.We further observe that since the square root function is multi-valued, gen-erating a ± sign, hence the infinite nested radical product actually generatesan infinite number of formulas with varying signs before the square root. Webegin by changing the inner most sign as indicated in red color, and observe theconvergence ofcos − ( y ) = lim n →∞ n (cid:118)(cid:117)(cid:117)(cid:117)(cid:117)(cid:117)(cid:116) − (cid:118)(cid:117)(cid:117)(cid:117)(cid:117)(cid:116) (cid:118)(cid:117)(cid:117)(cid:117)(cid:116) (cid:118)(cid:117)(cid:117)(cid:116) (cid:32) − (cid:114)
12 (1 + . . . y ) (cid:33) , (45)which results in for y = 0 x = cos − (0) ≈ . n = 10, where it is seen converging to 3 π/
2. And similarly if we change thesecond inner most sign ascos − ( y ) = lim n →∞ n (cid:118)(cid:117)(cid:117)(cid:117)(cid:117)(cid:117)(cid:116) − (cid:118)(cid:117)(cid:117)(cid:117)(cid:117)(cid:116) (cid:118)(cid:117)(cid:117)(cid:117)(cid:116) − (cid:118)(cid:117)(cid:117)(cid:116) (cid:32) (cid:114)
12 (1 + . . . y ) (cid:33) (47)for n = 10 result in x = cos − (0) ≈ . , (48)which is seen converging to 7 π/
2. And similarly if we change two inner mostsigns ascos − ( y ) = lim n →∞ n (cid:118)(cid:117)(cid:117)(cid:117)(cid:117)(cid:117)(cid:116) − (cid:118)(cid:117)(cid:117)(cid:117)(cid:117)(cid:116) (cid:118)(cid:117)(cid:117)(cid:117)(cid:116) − (cid:118)(cid:117)(cid:117)(cid:116) (cid:32) − (cid:114)
12 (1 + . . . y ) (cid:33) (49)10hich for n = 10 results in x = cos − (0) ≈ . , (50)which is seen approaching 5 π/
2, thus the signs of the square roots produces asort of binary weighted code. As a result, we map this combination in Table1 for a few more values by binary weighting the sign of the square root suchthat the LSB (Least Significant Bit) is a sign of the inner most square root andworking outwards to the next sign. For the first four inner most square roots of(37) would be represented as + + ++, for equation (45) it would be + + + − , forequation (47) it would be + + − +, and for equation (49) it would be + + −− .From Table 1, it is seen that the pattern of signs resembles that of a Gray codeif one takes + to be 0 and − to be 1. The Gray code has many applications indigital communication and computer science, such as error correction and datatransmission. The 4-bit Gray code for the previous sequence would be 0000,0001, 0011 and 0010 for equation (37,45,49,47) respectively. As a result, wedefine a Gray code alternating sign function G k asTable 1: Evaluation of Equation (37) for different square root signSquare root sign cos − (0) Eq(47) for n = 10 Converging value+ + ++ 1.570796172805538 π/
2+ + + − π/
2+ + −− π/
2+ + − + 10.995521462263701 7 π/ − − + 14.137054668250807 9 π/ − −− π/ − + − π/ − ++ 23.561425122147117 15 π/ G k ( m ) = (cid:40) , if m th binary digit of Gray code of k is zero − , if m th binary digit of Gray code of k is one . (51)to generate the ± m th nested radical. The main formula for a k thbranch becomes nowcos − ( y ) = ± n (cid:118)(cid:117)(cid:117)(cid:117)(cid:117)(cid:117)(cid:116) − G k ( n ) (cid:118)(cid:117)(cid:117)(cid:117)(cid:117)(cid:116) G k (3) (cid:118)(cid:117)(cid:117)(cid:117)(cid:116) G k (2) (cid:118)(cid:117)(cid:117)(cid:116) (cid:32) G k (1) (cid:114)
12 (1 + . . . y ) (cid:33) (52)and in terms of an n th recursive composition can be written T − ◦ ( n ) G k ( y ) = G k ( n − T − ◦ ( n − ( y ) (53)11o that cos − ( y ) = lim n →∞ ± n g ( T − ◦ nG k ( y )) (54)is a full representation of an inverse cosine function for a k th branch. Theprincipal branch k = 0 has all square roots with positive sign except the outerfunction g(y). The plus and minus sign is due to the outer square root, wherethe positive sign is for branches for positive values of k , and the negative signis for branches for negative values of k . We next will modify the algorithm forthe inverse cosine valid for a k branch as
1: % This function evaluates acos(y)2: % y is the input argument (real or complex)3: % k is the kth branch k>=04: % n is the order of nested product5: %6: function [x] = acos_fx_k(y,k,n)7:8: Gk = Gk_vec(k,n); % Load Gray code sequence9:10: for i = 1:n11:12: y = Gk(i)*sqrt((y+1)/2); % Iterate Gk * inverse T(y)13:14: end15:16: x = 2^n*sqrt(2*(1-y)); % Apply outer inverse cosine approximation17:18: end
And the Gray code alternating sign function is G k ( m ) is given as:
1: % This function generates Gray code alternating sign vector2: % m is the index of Gray code sequence and must be positive integer3: % n is the order of nested product and length of Gray code vector4: %5: function [Gk] = Gk_vec(m,n)6:7: bin = dec2bin(m,n); % Convert integer value m to binary string of length n8: gcode = ones(1,n); % Initialize vector with ’1’ to store Gk values9: gcode_refl = ones(1,n); % Initialize vector with ’1’ to store reflected Gk values10:11: for i = 2:n12:13: bit1 = str2double(bin(i-1)); % i-1 binary bit1 string converted to double14: bit2 = str2double(bin(i)); % i binary bit2 string converted to double15:16: % Apply xor operation on bit1 and bit2
7: c = xor(bit1,bit2);18:19: % Alternating sign value assignment20: if c == 021: gcode(i) = 1;22: elseif c ==123: gcode(i) = -1;24: end25:26: end27:28: % Reflect alternating sign values so that MSB corresponds to LSB29: for i = 1:n30: gcode_refl(n-i+1) = gcode(i);31: end32:33: % Return Gk33: Gk = gcode_refl;34:35: end where we utilized some unique functions in Matlab, such as ‘dec2bin’ function toconvert a decimal value into a vector filled with corresponding binary elements,and the ‘ones’ function allocates a vector filled with values of 1. The Gray codesequence is generated by a XOR operation on two successive bits.When we test this function, we quickly reproduce all the values in Table 1,and next, we try computing the inverse cosine for the 100th branch for n = 25.The Gray code alternating sign function results in a sequence G = { , , , , , , , , , , , , , , , , , , − , , − , , − , − , } (55)where we use this relation to extract the k th branch k = cos − (0) π −
12 (56)by dividing by π and subtracting to obtain acos_fx_k(0,100,25)/pi-0.5 = 100.000014188946 accurate to four decimal places. And similarly, for the millionth branch k = 10 for n = 25 we have G = { , , , , , − , , , , − , − , − , , , , − , − , , − , − , , , , , } (57)and we obtain 13 cos_fx_k(0,10^6,25)/pi-0.5 = 999634.790737135 while for n = 30 we obtain acos_fx_k(0,10^6,30)/pi-0.5 = 999999.643311845, an accuracy to almost 1 decimal place with just 30 nested radicals for a millionthbranch. We also performed a sweep of the branch k from 0 to 10 in 1 step andplotted the extracted branches in Fig. 1 to verify the validity of the Gray codesequence G k . Indeed, we see a perfect reproduction up to a millionth branch,only with n = 25 nested radicals. Also, the kth branch works well for a complexargument, we compute the millionth branch again for cos − (2 + 3 i ) with n = 30and obtain real(acos_fx_k(2+3*i,10^6,30)/pi) = 999999.961666679 where we roughly obtain the millionth extracted branch, since we don’t knowthe exact multiple of π to subtract as in (55) case.Figure 1: Extracted k th branch of cos − (0) by equation (52) from k = 0 to k = 10 in unit stepsThere is also one special case for ± − (1) and aneven branch k , there is also the same k − − ( − k − k = cos − ( ± /π and note how the double branch arise for evenand odd branches. From equation (37) it cancels or maximizes the inner mostradical term and the effect propagates up the radical chain, since the LSB bitof the Gray code doesn’t change for one increment of k .14able 2: The k th branch of cos − ( −
1) and cos − (1) by equation (52)kth branch cos − (1) /π cos − ( − /π The hyperbolic cosine function is defined ascosh( x ) = cos( ix ) (58)and since the nested product formula (4) approaches the Maclaurin series forcosine function, it is therefore an entire function valid in all complex plane, asa result, we then have cosh( x ) = lim n →∞ T ◦ n (cid:16) x n +1 (cid:17) , (59)which yields an expansion ofcosh( x ) = lim n →∞ (cid:40) − . . . + 2 . . . (cid:16) − (cid:16) − (cid:16) x n +1 (cid:17) (cid:17) (cid:17) ... (cid:41) . (60)And similarly as before, by solving for x we obtain an inverse function ascosh − ( y ) = lim n →∞ n (cid:118)(cid:117)(cid:117)(cid:117)(cid:117)(cid:117)(cid:116) − (cid:118)(cid:117)(cid:117)(cid:117)(cid:117)(cid:116) (cid:118)(cid:117)(cid:117)(cid:117)(cid:116) (cid:118)(cid:117)(cid:117)(cid:116) (cid:32) (cid:114)
12 (1 + . . . y (cid:33) , (61)where only the outer function approximation to inverse cosine g ( y ) changed toan approximation to an inverse hyperbolic cosine as h ( y ) = (cid:112) − y ). Also,in terms of the branches, we havecosh − ( y ) = lim n →∞ ± n h ( T − ◦ nG k ( y )) (62)15here G k is the same Gray code ordering of the square root signs establishesthe branches, such that in G all square root signs are positive, in G only thefirst inner most sign is negative, in G only the first two inner most signs arenegative and in G only the second inner most sign is negative and so on. Also,the inverse hyperbolic cosine function is defined for complex argument z ascosh − ( z ) = log( z + (cid:112) z −
1) (63)having a branch cut on real axis in an interval ( −∞ , − (2) = 1 . n = 10 gives acosh_fx(2,10) = 1.31695798760619 As another example, if we takecosh − ( − i ) = 1 . − . i (65)while the computer function for n = 10 gives acosh_fx(-2+3i,10) = 1.98338625571006 - 2.14144972510396i Finally, we give a slightly modified version of the code to compute the hy-perbolic cosine function, where we use 4 terms to approximate the inner cosh( x )approximation
1: % This function evaluates cosh(x)2: % x is the input argument (real or complex)3: % k=2^n (must be power of 2) where n is the order of nested product4: %5: function [y] = cosh_fx4(x,n)6:7: if n==18: y = 1+x^2/2+x^4/24+x^6/720; % Inner term approximation to hyperbolic cosine9: else10: y = -1+2*cosh_fx(x/2,n/2)^2; % Chebyshev polynomial of cosh_fx11: end12:13: end and the inverse function as
1: % This function evaluates acosh(y)2: % y is the input argument (real or complex)3: % n is the order of nested product4: %5: function [x] = acosh_fx(y,n) :7: for i = 1:n8:9: y = sqrt((y+1)/2) % Iterate inverse f(y) n number of times10:11: end12:13: x = 2^n*sqrt(2*(-1+y)) % Outer term inverse acosh approximation h(y)14:15: end. But, if one wishes to add the branches, then the G k must be included simiarlyas for the inverse cosine function in the previous section. By observing the definition of inverse hyperbolic cosine (63) ascosh − ( x ) = log( x + (cid:112) x −
1) (66)we write the inner log term as y = x + (cid:112) x − x yields x = y + 12 y . (68)This now gives a formula for log in terms of inverse hyperbolic cosine aslog( y ) = cosh − (cid:18) y + y − (cid:19) , (69)and by using the nested radical representation for inverse hyperbolic cosine (61),the logarithm formula becomeslog( y ) = lim n →∞ n (cid:118)(cid:117)(cid:117)(cid:117)(cid:117)(cid:117)(cid:117)(cid:116) − (cid:118)(cid:117)(cid:117)(cid:117)(cid:117)(cid:117)(cid:116) (cid:118)(cid:117)(cid:117)(cid:117)(cid:117)(cid:116) (cid:118)(cid:117)(cid:117)(cid:116) (cid:32) (cid:115) (cid:18) . . . y + y − (cid:19)(cid:33) , (70)where, again as before, the inner inverse Chebyshev function T − ( x ) is iterated n number of times aslog( y ) = lim n →∞ n h (cid:16) T − (cid:16) T − (cid:16) T − (cid:16) T − (cid:16) . . . y + y − (cid:17)(cid:17)(cid:17)(cid:17)(cid:17) = lim n →∞ n h (cid:16) T − ◦ n (cid:16) y + y − (cid:17)(cid:17) , (71)17nd h ( y ) is the outer function evaluated only once in the end. If one employs theGray code alternating sign sequence, then one could recover all the branches ofthe logarithm. Next, we investigate this formula for log(2) and find that innerterm becomeslog(2) = lim n →∞ n (cid:118)(cid:117)(cid:117)(cid:117)(cid:117)(cid:117)(cid:117)(cid:116) − (cid:118)(cid:117)(cid:117)(cid:117)(cid:117)(cid:117)(cid:116) (cid:118)(cid:117)(cid:117)(cid:117)(cid:117)(cid:116) (cid:118)(cid:117)(cid:117)(cid:116) (cid:32) (cid:115) (cid:18) . . . (cid:19)(cid:33) . (72)A computation for n = 10 nested radicals yields log_fx(2,10) = 0.693147193652913 with an accuracy to 6 decimal places. We coded the function log fx which is justa simple modification of acosh fx shown in the previous section. For log( − − ( −
1) = πi , and when we reach the outer radical termin which there is a square root of − log_fx(-1,10) = 3.14159142150464i for n = 10 with an accuracy to 5 decimal places. Next, we demonstrate howlog(1) = 0, where it is seen the inner most term becomes (cid:115) (cid:18) (cid:19) = 1 (73)the next outer radical term is (cid:115) (cid:18) (cid:19) = 1 (74)and this process is propagated up the radical chain like a domino effect, untilwe reach the outer most radical term where it is terminated with − ) = 230 . n = 10, andobtain log_fx(1e100,10) = 230.743921174299. Although, in practice, one would use the rule log( a x ) = x log( a ) to simplifycomputation of logarithms for large argument, however it is seen that this nestedradical formula can cut through large input argument very effectively.18 The sine, tangent and exponential functions
The the half-angle identify for sinesin( x ) = 2 sin (cid:16) x (cid:17) cos (cid:16) x (cid:17) (75)relates the sine function to the product of sine with cosine functions, thus pre-venting to recursively iterate the sine function similarly as in (4). However,what one might could do is to writesin( x ) = cos (cid:16) x − π (cid:17) (76)and use the nested cosine formula. Another possibility is apply the identitycos ( x ) + sin ( x ) = 1 so thatsin( x ) = (cid:112) − cos ( x ) , (77)which results in a slight modificationsin( x ) = (cid:118)(cid:117)(cid:117)(cid:116) − lim n →∞ (cid:40) − . . . + 2 . . . (cid:16) − (cid:16) − (cid:16) − x n +1 (cid:17) (cid:17) (cid:17) ... (cid:41) , (78)where the square root term is the outer most term. And for the inverse sine, weuse the following identity sin − ( y ) = cos − ( (cid:112) − y ) , (79)and by substituting to the nested inverse cosine function we obtainsin − ( y ) = lim n →∞ n (cid:118)(cid:117)(cid:117)(cid:117)(cid:117)(cid:117)(cid:116) − (cid:118)(cid:117)(cid:117)(cid:117)(cid:117)(cid:116) (cid:118)(cid:117)(cid:117)(cid:117)(cid:116) (cid:118)(cid:117)(cid:117)(cid:116) (cid:32) (cid:114) (cid:16) . . . (cid:112) − y (cid:17)(cid:33) , (80)where the inner most term has the square root. In terms of the recursive com-position is represented assin − ( y ) = lim n →∞ n g ( T − ◦ n ( (cid:112) − y )) . (81)The sine functions are basically coupled to the cosine function by equation (77).A similar situation occurs for the tangent functiontan( x ) = 2 tan( x )1 − tan ( x ) = 2tan( x ) − x ) (82)19here the iterated half-angle identity generates a nested tree that would growsimilarly as a nested continued fraction. So at this point we just refer back tothe tangent function as a combination of sine and cosine astan( x ) = sin( x )cos( x ) = (cid:112) − cos ( x )cos( x ) = (cid:115) ( x ) − , (83)although care must be taken as the square root can generate a different branch.This leads to the nested tangent representationtan( x ) = (cid:118)(cid:117)(cid:117)(cid:116) − n →∞ (cid:40) − . . . + 2 . . . (cid:16) − (cid:16) − (cid:16) − x n +1 (cid:17) (cid:17) (cid:17) ... (cid:41) − , (84)and we can keep track of the branch due the sine function being positive ornegative. Furthermore, the inverse is written astan − ( y ) = cos − (cid:32) (cid:112) y (cid:33) , (85)which is represented by the inverse cosine function astan − ( y ) = lim n →∞ n (cid:118)(cid:117)(cid:117)(cid:117)(cid:117)(cid:117)(cid:117)(cid:117)(cid:116) − (cid:118)(cid:117)(cid:117)(cid:117)(cid:117)(cid:117)(cid:116) (cid:118)(cid:117)(cid:117)(cid:117)(cid:117)(cid:116) (cid:118)(cid:117)(cid:117)(cid:117)(cid:116) (cid:118)(cid:117)(cid:117)(cid:116) (cid:32) . . . (cid:112) y (cid:33) . (86)Finally, we remark on the exponential function. By inverting the nestedlogarithm function (70), we eventually obtain e x = cosh( x ) + sinh( x ) = cosh( x ) + (cid:113) − ( x ) , (87)hence basically, the nested cosine functions are fundamental in the sense ofbeing able to invert them algebraically. It is not clear if the other trigonometricfunctions have an independent nested representation that can be inverted. Wederived different variations which are coupled to the cosine function throughdifferent identities. Also, the exponential and logarithms function have differentlimit representations. The most basic definition for the exponential is e x = lim n →∞ (cid:16) xn (cid:17) n , (88)which can be inverted to find the logarithm aslog( y ) = lim n →∞ n (cid:16) y n − (cid:17) (89)are the natural inverse limits. 20 eferences [1] M. Abramowitz and I. A. Stegun. Handbook of Mathematical Functionswith Formulas, Graphs, and Mathematical Tables . Dover Publications, ninthprinting, New York, 1964.[2] P. Beckmann.
A History of π . St. Martin’s Press, New York, 1971.[3] A. Levin. A New Class of Infinite Products Generalizing Vi`ete’s ProductFormula for π . The Ramanujan Journal, 10, 305–324, 2005. Email: [email protected] Appendix A
Cosine function: cos( x ) = lim n →∞ (cid:40) − . . . + 2 . . . (cid:16) − (cid:16) − (cid:16) − x n +1 (cid:17) (cid:17) (cid:17) ... (cid:41) . Inverse cosine function: cos − ( y ) = lim n →∞ n (cid:118)(cid:117)(cid:117)(cid:117)(cid:117)(cid:117)(cid:116) − (cid:118)(cid:117)(cid:117)(cid:117)(cid:117)(cid:116) (cid:118)(cid:117)(cid:117)(cid:117)(cid:116) (cid:118)(cid:117)(cid:117)(cid:116) (cid:32) (cid:114)
12 (1 + . . . y ) (cid:33) . Sine function: sin( x ) = (cid:118)(cid:117)(cid:117)(cid:116) − lim n →∞ (cid:40) − . . . + 2 . . . (cid:16) − (cid:16) − (cid:16) − x n +1 (cid:17) (cid:17) (cid:17) ... (cid:41) . Inverse sine function: sin − ( y ) = lim n →∞ n (cid:118)(cid:117)(cid:117)(cid:117)(cid:117)(cid:117)(cid:116) − (cid:118)(cid:117)(cid:117)(cid:117)(cid:117)(cid:116) (cid:118)(cid:117)(cid:117)(cid:117)(cid:116) (cid:118)(cid:117)(cid:117)(cid:116) (cid:32) (cid:114) (cid:16) . . . (cid:112) − y (cid:17)(cid:33) . Tangent function: tan( x ) = (cid:118)(cid:117)(cid:117)(cid:116) − n →∞ (cid:40) − . . . + 2 . . . (cid:16) − (cid:16) − (cid:16) − x n +1 (cid:17) (cid:17) (cid:17) ... (cid:41) − . Inverse Tangent function: tan − ( y ) = lim n →∞ n (cid:118)(cid:117)(cid:117)(cid:117)(cid:117)(cid:117)(cid:117)(cid:117)(cid:116) − (cid:118)(cid:117)(cid:117)(cid:117)(cid:117)(cid:117)(cid:116) (cid:118)(cid:117)(cid:117)(cid:117)(cid:117)(cid:116) (cid:118)(cid:117)(cid:117)(cid:117)(cid:116) (cid:118)(cid:117)(cid:117)(cid:116) (cid:32) . . . (cid:112) y (cid:33) . Hyperbolic cosine function: cosh( x ) = lim n →∞ (cid:40) − . . . + 2 . . . (cid:16) − (cid:16) − (cid:16) x n +1 (cid:17) (cid:17) (cid:17) ... (cid:41) . nverse hyperbolic cosine function: cosh − ( y ) = lim n →∞ n (cid:118)(cid:117)(cid:117)(cid:117)(cid:117)(cid:117)(cid:116) − (cid:118)(cid:117)(cid:117)(cid:117)(cid:117)(cid:116) (cid:118)(cid:117)(cid:117)(cid:117)(cid:116) (cid:118)(cid:117)(cid:117)(cid:116) (cid:32) (cid:114)
12 (1 + . . . y ) (cid:33) . Hyperbolic sine function: sinh( x ) = (cid:118)(cid:117)(cid:117)(cid:116) − n →∞ (cid:40) − . . . + 2 . . . (cid:16) − (cid:16) − (cid:16) x n +1 (cid:17) (cid:17) (cid:17) ... (cid:41) . Inverse hyperbolic sine function: sinh − ( y ) = lim n →∞ n (cid:118)(cid:117)(cid:117)(cid:117)(cid:117)(cid:117)(cid:116) − (cid:118)(cid:117)(cid:117)(cid:117)(cid:117)(cid:116) (cid:118)(cid:117)(cid:117)(cid:117)(cid:116) (cid:118)(cid:117)(cid:117)(cid:116) (cid:32) (cid:114) (cid:16) . . . (cid:112) y (cid:17)(cid:33) . Hyperbolic tangent function: tanh( x ) = (cid:118)(cid:117)(cid:117)(cid:116) − lim n →∞ (cid:40) − . . . + 2 . . . (cid:16) − (cid:16) − (cid:16) x n +1 (cid:17) (cid:17) (cid:17) ... (cid:41) − . Inverse hyperbolic tangent function: tanh − ( y ) = lim n →∞ n (cid:118)(cid:117)(cid:117)(cid:117)(cid:117)(cid:117)(cid:117)(cid:117)(cid:116) − (cid:118)(cid:117)(cid:117)(cid:117)(cid:117)(cid:117)(cid:116) (cid:118)(cid:117)(cid:117)(cid:117)(cid:117)(cid:116) (cid:118)(cid:117)(cid:117)(cid:117)(cid:116) (cid:118)(cid:117)(cid:117)(cid:116) (cid:32) . . . (cid:112) − y (cid:33) . Exponential function: e x = cosh( x ) + sinh( x ) = cosh( x ) + (cid:113) − ( x ) e x = lim n →∞ (cid:16) xn (cid:17) n . Logarithm function: log( y ) = lim n →∞ n (cid:118)(cid:117)(cid:117)(cid:117)(cid:117)(cid:117)(cid:117)(cid:116) − (cid:118)(cid:117)(cid:117)(cid:117)(cid:117)(cid:117)(cid:116) (cid:118)(cid:117)(cid:117)(cid:117)(cid:117)(cid:116) (cid:118)(cid:117)(cid:117)(cid:116) (cid:32) (cid:115) (cid:18) . . . y + y − (cid:19)(cid:33) log( y ) = lim n →∞ n (cid:16) y n − (cid:17) ..