https://mizugadro.mydns.jp/t/index.php?title=SuZex_approximation&feed=atom&action=history SuZex approximation - Revision history 2019-11-12T21:34:45Z Revision history for this page on the wiki MediaWiki 1.31.4 https://mizugadro.mydns.jp/t/index.php?title=SuZex_approximation&diff=27965&oldid=prev T: Text replacement - "\$([^\$]+)\$" to "\$$\1\$$" 2019-07-30T09:25:40Z <p>Text replacement - &quot;\$([^\$]+)\$&quot; to &quot;\$$\1\$$&quot;</p> <a href="https://mizugadro.mydns.jp/t/index.php?title=SuZex_approximation&amp;diff=27965&amp;oldid=939">Show changes</a> T https://mizugadro.mydns.jp/t/index.php?title=SuZex_approximation&diff=939&oldid=prev Maintenance script at 06:01, 20 June 2013 2013-06-20T06:01:43Z <p></p> <p><b>New page</b></p><div>[[File:SuZexPlot511T.jpg|140px|left|thumb| Fig.1. $y\!=\!\mathrm{SuSex}(x)~$, thick blue line, and $y\!=\!\mathrm{zex}(x)\!=\!x\mathrm e^x$, thin line]]<br /> [[File:SuZexMapT.jpg|600px|thumb|Fig.2.[[Complex map]] of function [[SuZex]]: $~u\!+\!\mathrm i v= \mathrm{SuZex}(x_1+x\!+\!\mathrm i y)$]]<br /> This article collects approximations of function [[SuZex]], which is [[superfunction]] of [[zex]]$\,(z)=z\exp(z)~$. The [[complex map]] of [[SuZex]] is shown in figure at right. Below, it is compared to similar maps for various approximations of [[SuZex]] with elementary functions. All the maps are supposed to be displayed in the same scale.<br /> ==Background==<br /> [[SuZex]] is [[superfuncton]] for the [[transfer function]] $T=\,\,$[[zex]]; <br /> <br /> (1) $~ ~ ~ T(z)=\mathrm{zex}(z) = z\,\exp(z)~$<br /> <br /> The superfunction $F=\mathrm{SuZex}$ satisfies the [[transfer equation]]<br /> <br /> (2) $~ ~ ~ T(F(z))=F(z\!+\!1)$<br /> <br /> and the additional condition<br /> <br /> (3) $~ ~ ~ F(0)=1$<br /> <br /> Also, it is assumed that the solution $F=\mathrm{SuZex}$ decays to the stationary point 0 of the transfer function $T$ by (1) at infinity, except some strip along the positive part of the real axis. The superfunction $F=\mathrm{SuZex}$ is real–holomorphic; $F(z^*)=F(z)^*$,<br /> <br /> For real values of the argument, the [[explicit plot]] $y=\mathrm{SuZex}(x)$ is shown in figure 2. The function is positive and increasing along the whole real axis; all its derivatives are also positive. The function slowly raises since zero at minus infinity, passes through point (0,1) and then shows the fast growth, similar to that of the [[SuperFactorial]] and that o the [[tetration]] (to base $b\!&gt;\! \exp^2(-1)$).<br /> <br /> Sorry, the figure 2 is not yet loaded.<br /> <br /> For the efficient (id est, fast and precise) evaluation of [[SuZex]], various approximations are described below. They are used in the [[C++]] implementation of function [[SuZex]], called by generators of figures, and, in particular, figures 1 and 2.<br /> <br /> ==Taylor expansion at zero==<br /> &lt;div class=&quot;thumb tleft&quot;&gt;&lt;div style=&quot;width:13em;&quot;&gt;$\begin{array}{rl}<br /> n&amp;c_n\\<br /> 0&amp;1.\\<br /> 1&amp; 0.7136859972397819\\<br /> 2&amp; 0.4476015977075872\\<br /> 3&amp; 0.2601727742107340\\<br /> 4&amp; 0.1435143556173126\\<br /> 5&amp; 0.0761226590985602\\<br /> 6&amp; 0.0391492705396854\\<br /> 7&amp; 0.0196328627708593\\<br /> 8&amp; 0.0096397364554956\\<br /> 9&amp; 0.0046483274109356\\<br /> 10&amp;0.0022065106994065\\<br /> 11&amp;0.0010330188519910\\<br /> 12&amp;0.0004777086233718\\<br /> 13&amp;0.0002184810190843\\<br /> 14&amp;0.0000989267835284\\<br /> 15&amp;0.0000443861459533\\<br /> 16&amp;0.0000197488866685<br /> \end{array}$<br /> &lt;/div&gt;&lt;/div&gt;<br /> &lt;div class=&quot;thumb tright&quot;&gt;&lt;!--<br /> &lt;div style=&quot;width:34em;&quot;&gt; !--&gt;<br /> &lt;div style=&quot;width:500px&quot;&gt;<br /> [[File:SuZex0map48small.png|160px]]<br /> [[File:SuZexMapSmall48c.png|160px]]<br /> [[File:SuZexTay0testT.png|160px]]<br /> <br /> Fig.3. [[Taylor approximation]] (4) with 48 terms; $!u\!+\!\mathrm i v= P_{48}(x\!+\!\mathrm i y)$, left; the same and map of $u\!+\!\mathrm i v= \mathrm{SuZex}(x\!+\!\mathrm i y)$, center; and the agreement $A_{48}(x\!+\!\mathrm i y)$, right. <br /> &lt;/div&gt;&lt;/div&gt;<br /> <br /> [[File:SuZexoMapJPG.jpg|600px|thumb|Fig.4. Map od the Asymptotic approximation $Q_{20}~$ by equation ($~$); $~u\!+\!\mathrm i v= Q_{20}(x_1+x\!+\!\mathrm i y)$]]<br /> The simple approximation of any function is, perhaps, the truncated Taylor series, which is, actually, a polynomial. The [[complex map]] of such a polynomial of power $N\!=\!42$ is shown in the figure 3,<br /> <br /> (4) $~ ~ ~ ~\displaystyle \mathrm{SuZex}(z) \approx P_{N}(z)=\sum_{n=0}^{N} \,c_n\, z^n$<br /> <br /> Approximations for the first 17 coefficients $c$ or the expansion are shown in table at left.<br /> More coefficients are available at [[SuZexTay0co.cin]] .<br /> <br /> The series converges, and the increase of the number of terms taken into account extends the range of approximation. However, due to the fast growth of the function at real values of the argument, practically the application of the approximation is limited by a circle $|z|\!&lt;\!2$; for larger values, the enormous amount of coefficients should be taken into account, and the rounding errors destroy the precision of the approximation.<br /> <br /> For evaluation of [[SuZex]] of real argument, the polynomial approximation is sufficient, the values of function can be reconstructed applying iteratively the Transfer equation<br /> <br /> (5) $~ ~ ~ ~ \mathrm{SuZex}(z\!+\!1)=\mathrm{zex}\Big(\mathrm{SuZex}(z)\Big)$<br /> <br /> or its modification<br /> <br /> (6) $~ ~ ~ ~ \mathrm{SuZex}(z\!-\!1)=\mathrm{LambertW}\Big(\mathrm{SuZex}(z)\Big)$<br /> <br /> For function [[zex]]$(z)=z \exp(z)$ and its inverse [[LambertW]]$=\mathrm{zex}^{-1}$, the efficient compex(double) numerical implementations are available.<br /> <br /> Figures at right show the [[complex map]] of the approximation $P_{48}$, its overlap with the map of [[SuZex]] and the agreement $A_{48}$ with [[SuZex]] defined with<br /> <br /> (7) $~ ~ ~ ~\displaystyle A_{48}(z)= -\lg \left( \frac<br /> {|P_{48}(z) - \mathrm{SuZex}(z)|}<br /> {|P_{48}(z)| + |\mathrm{SuZex}(z)|}<br /> \right)$<br /> <br /> This agreement indicates, how many decimal digits does the approximation for certain $z=x\!+\!\mathrm i y$; levels $A=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15$ are drawn. In the central part, the approximation provides of order of 15 decimal digits. Outside the outher loop, the agreement is smaller than unity, id est, even first digit of the estimate of [[SuZex]] by the approximation $P_{48}$ is doubtful. This loop has light excess at the real part of the real axis bevause of huge denominator in the definition of $A_{48}$. The inner part is still sufficient for the implementation of [[SuZex]] along the real axis, using the [[transfer equation]]; the error due to the approximation is smaller than the rounding error at the [[double precision]] arithmetics. Perhaps, even less terms would be sufficient for the professional implementation of this superfunction.<br /> <br /> ==Expansion at infinity==<br /> [[File:SuZexo20testTjpg.jpg|600px|thumb|Fig.5. Map of agreement $B_{20}$ by equation (12) for the asymptotic approximation $Q_{20}$ by equations (9, (10);<br /> (8) $~ ~ ~ u\!+\!\mathrm i v\!=\!B_{20}(x\!+\!\mathrm i y)$]]<br /> <br /> For large values of the argument, [[SuZex]] can be approximated using the asymptotic expansion. Let<br /> <br /> (9) $~ ~ ~ \displaystyle Q_N(z)=\frac{1}{z}\, \sum_{n=0}^{N} \, z^{-n}\, \sum_{m=0}^n\, a_{m,n} \ell^m$<br /> <br /> where $\ell=\ln(-z)$. Then <br /> <br /> (10) $~ ~ ~\mathrm{SuZex}(z) \approx Q_N(x_1\!+\!z)~$<br /> <br /> where $x_1\!\approx\! -1.1259817765745028~$ is solution of the equation<br /> <br /> (11) $~ ~ ~\displaystyle \lim_{k \rightarrow \infty} \mathrm{zex}^k\Big(Q_N(x_1-k)\Big) = 1$<br /> <br /> For $N\!=\!20$, the [[complex map]] of approximation (8) is shown in Figure 4. Practically, with $k\!=\! 20$, the error of evaluation of $x_1$ becomes of order of rounding errors at the &quot;double&quot; precision; at $\Re(z)\!&lt;\!-20$, the last term in the asymptotic expansion is smaller than $10^{-16}$ and does not contribute to the estimated value.<br /> <br /> The [[complex map]] of $Q(x_1\!+\!z)$ for $z\!=\!x\!+\!\mathrm i y$ <br /> is shown in figure at right. In the region $~x\!&lt;\!0~$, $~x^2\!+\!y^2\!&lt;\!4~$, the approximation through $Q(20)$ shows reasonable agreement with the polynomial expansion $P_{48}$ above. In particular, the same level $v\!=\!0.4$<br /> looks in the similar way in both figures. However, the corresponding values of the argument are out of range of high precision of each of the approximations.<br /> <br /> Coefficients $a_{n,m}$ in the expansion:<br /> <br /> $\begin{array}{cccccccccc}<br /> ~ ~ n ~ \backslash~ m\!\! &amp; \bf 0 &amp; \bf 1 &amp; \bf 2 &amp; \bf 3 &amp;\\<br /> \!\bf 0&amp;-1&amp; 0 &amp; 0 &amp;0\\<br /> \!\bf 1&amp; 0&amp;1/2&amp;0 &amp;0\\<br /> \!\bf 2&amp; -1/6&amp; 1/4&amp; -1/4 &amp;0\\ &lt;!--<br /> \frac{7}{48} &amp; \frac{3}{8} &amp; -\frac{5}{16} &amp; \frac{1}{8} !--&gt;<br /> \!\bf 3&amp; {-7}/{48}~ &amp; {3}/{8} &amp; -{5}/{16}~ &amp; {1}/{8} <br /> \end{array}$<br /> <br /> Below the same table appears as the Mathematica output produced after calculation of the coefficients with the command <br /> <br /> &lt;b&gt;<br /> TeXForm[Table[Table[If[n &gt;= m, a[n, m], 0], {m, 0, 7}], {n, 0, 7}]] &lt;/b&gt;<br /> <br /> $\!\!\!\!\!\!\!\!\!\! ^{<br /> \begin{array}{ccccccccccc}<br /> -1 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 \\<br /> 0 &amp; \frac{1}{2} &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 \\<br /> -\frac{1}{6} &amp; \frac{1}{4} &amp; -\frac{1}{4} &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 \\<br /> -\frac{7}{48} &amp; \frac{3}{8} &amp; -\frac{5}{16} &amp; \frac{1}{8} &amp; 0 &amp; 0 &amp; 0 &amp; 0 \\<br /> -\frac{707}{4320} &amp; \frac{23}{48} &amp; -\frac{17}{32} &amp; \frac{13}{48} &amp; -\frac{1}{16} &amp; 0 &amp; 0 &amp; 0 \\<br /> -\frac{1637}{8640} &amp; \frac{1121}{1728} &amp; -\frac{83}{96}<br /> &amp; \frac{37}{64} &amp; -\frac{77}{384} &amp; \frac{1}{32} &amp; 0 &amp; 0 \\<br /> -\frac{274133}{1209600} &amp; \frac{15427}{17280} &amp;<br /> -\frac{1619}{1152} &amp; \frac{443}{384} &amp;<br /> -\frac{205}{384} &amp; \frac{87}{640} &amp; -\frac{1}{64} &amp; 0 \\<br /> -\frac{4024763}{14515200} &amp; \frac{142801}{115200} &amp;<br /> -\frac{156559}{69120} &amp; \frac{1915}{864} &amp;<br /> -\frac{1307}{1024} &amp; \frac{53}{120} &amp;<br /> -\frac{223}{2560} &amp; \frac{1}{128} &lt;!--\\<br /> -\frac{633245021}{1828915200} &amp; \frac{5019103}{2903040}<br /> &amp; -\frac{2496407}{691200} &amp; \frac{214009}{51840} &amp;<br /> -\frac{157849}{55296} &amp; \frac{4769}{3840} &amp;<br /> -\frac{3115}{9216} &amp; \frac{481}{8960} &amp;<br /> -\frac{1}{256} &amp; 0 \\<br /> -\frac{403880483}{914457600} &amp;<br /> \frac{328194077}{135475200} &amp;<br /> -\frac{110236243}{19353600} &amp;<br /> \frac{31028023}{4147200} &amp; -\frac{3357353}{552960} &amp;<br /> \frac{196001}{61440} &amp; -\frac{101417}{92160} &amp;<br /> \frac{17499}{71680} &amp; -\frac{4609}{143360} &amp;<br /> \frac{1}{512} <br /> !--&gt;<br /> \end{array}}$<br /> &lt;!-- The only parenthesis are suppressed in the expression above. !--&gt;<br /> <br /> The precision of the approximation through the asymptotic expansion (9) can be characterized with agreement <br /> <br /> (12) $~ ~ ~ \displaystyle<br /> B_{N}(z)=- \lg\left( <br /> \frac{|Q_N(x_1\!+\!z)-\mathrm{SuZex}(z)|}<br /> {|Q_N(x_1\!+\!z)|+|\mathrm{SuZex}(z)|} <br /> \right)$<br /> <br /> For $N\!=\!20$, this function is shown in figure 5. <br /> Outside the loops, the approximation provides at least 15 correct decimal digits.<br /> While $\Re(z)&lt;5$, for $|z\!+\!2|&gt;8$, the error of approximation of $\mathrm{SuZex}(z)$ with <br /> $Q_N(x_1\!+\!z)$ is smaller than the rounding errors at the use of the [[complex double]] arithmetics.<br /> <br /> ==Taylor expansion at $z=-12+x_1$==<br /> [[File:SuZexTay2008t12MapT.jpg|600px|thumb|Fig.6. Approximation of [[SuZex]] with the Taylor expansion $\Phi_{12,80}$ at $-12+x_1$ ; here $u\!+\!\mathrm i v=\Phi(x_1\!+\!12+ x\!+\!\mathrm i y)$]]<br /> [[File:SuZexTay2008deviTjpg.jpg|600px|thumb|Fig.7. Agreement $C_{80}$ by (15) of the approximation of [[SuZex]] with the Taylor expansion $\Phi_{12,80}$ at $-12+x_1$]]<br /> At positive part of the real axis, the asymptotic approximation above has the cutline; for moderate values of the real part of the argument, the Taylor expansion would be better. In addition, the precise evaluation with direct application of the asymptotic expansion requires $N$ of order of 20, and needs approximately $N^2$ (id est, of order of 400) operations. The speed of evaluation can be boosted doe an order of magnitude with the Taylor expansion at some point far from the region of fast growth of function [[SuZex]]. Such a point is chosen to be $z_{12}=-12\!+\!x_1\approx -13.1$<br /> <br /> The [[Taylor approximation]] $\Phi$ of [[SuZex]] at some point $z_{12}$ can be written as the truncated [[Taylor series]],<br /> <br /> (13) $~ ~ ~ \Phi_{12,N}(z)=$ $<br /> \displaystyle<br /> \sum_{n=0}^N f_n (z-z_{12})^n=$ $\displaystyle<br /> \sum_{n=0}^N f_n (z+12-x_{1})^n$<br /> <br /> The coefficients $f$ in (13) were evaluated from the asymptotic approximation, expanding expression<br /> <br /> (14) $~ ~ ~ \mathrm{zex}^8\Big( Q_{20}(-20\!+\!z) \Big)$<br /> <br /> at small values of $z$.<br /> <br /> The [[complex map]] of the expansion (13) for $N\!=\!80$ is shown in figure 6. The point of expansion (approximately, $-13.1259817765745028$) is a little bit outside the field covered by the map. In order to simplify the comparison with other pictures, the same scale is used. <br /> <br /> The constant 20 in expression (14) is chosen for the following reason. While doing numerical calculation with [[complex double]] variables, with 21 terms of the expansion (8), the last term does not affect the value $Q_20(z)$ for $\Re(z)&lt;-20$. The additional misplacement of the expansion point to the left would not improve the precision of the evaluation. The precision can be improved, using some patience ([[to press a key, to have a tea]]) and the [[long double]] variables; then it would have sense to get more terms in asymptotic expansion (9) and use more iterations of function [[zex]] in (14). However, the 15 digits seem to be more than sufficient to plot all the figures. In particular, the expansion (13) reproduces such properties of function [[SuZex]] as its value unity at zero and even value 2.7.. (approximately $\mathrm e$) at unity, although $\Phi(z)$ it is designed to approximate $\mathrm{Suzex}(z)$ in vicinity of $z\!=\!-12$, id est, mainly outside of the field of the map shown.<br /> <br /> The precision of approximation of [[SuZex]] with function $\Phi$ by (13) can be characterized with the agreement<br /> <br /> (15) $~ ~ ~ \displaystyle<br /> C_{N}(z)=- \lg\left( <br /> \frac{|\Phi_N(z)-\mathrm{SuZex}(z)|}<br /> {|\Phi_N(z)|+|\mathrm{SuZex}(z)|} <br /> \right)$<br /> <br /> For $N=80$, the map of agreement by (15) is shown in Figure 7. (Hope, the last figure to be loaded for this article)<br /> <br /> Inside the loop, the approximation (14) gives at least 15 decimal digits, and the deviation in 16th digits (not plotted) should be attributed to the rounding errors (in particular in the evaluation of the Taylor coefficients $f$, but not to the lack of term in the Taylor polynomial (13).<br /> <br /> ==Numerical implementation==<br /> <br /> The numerical impementation [[SuZex.cin]] in [[C++]] of function [[SuZex]] is constructed on the base of approximations described above.<br /> <br /> For $|\Im(z)|\!&gt;\!8$ the espansion $Q$ is used.<br /> <br /> For small values of $|z|&lt;1.6$, the Taylor expansion (4) at zero is used, truncated keeping the 96th power of $z$, id est, $P_{96}(z)$ is used as approximation of $\mathrm{SuZex}(z)$<br /> <br /> For positive $~\Re(z)~$, but $~|\Im(z)|\!&lt;\!1.5~$, the iteration $~\mathrm{zex}^n( P_{96}(z\!-\!n)~$is used as approximation of $\mathrm{SuZex}(z)$, with integer $~n \!\approx\! \Re(z)$.<br /> <br /> If not a case, for $|z\!+\!12\!+\!x_1|&lt;8.1$, the approximation $\Phi$ is used; and, fot positive $~\Re(z)~$, but<br /> $~|\Im(z)|\!&lt;\!1.5~$, the iteration $~\mathrm{zex}^n\!\Big( \Phi(z\!-\!n)\Big)~$is used as approximation of $\mathrm{SuZex}(z)$, with integer $~n \!\approx\! \Re(z)$.<br /> <br /> For the rest of cases, id est, $\Re(z)&lt;-14$, again, the asymptotic expansion $Q$ is used.<br /> <br /> The approximations described above have wide areas of overlapping, where at least two or three of approximations above provide at least 15 correct decimal digits. This allows to use the implementation without any further worries about the error of the approximation. The [[SuZex]] can be used as any other special function with known behavior, known asymptotic and the efficient algorithm for the evaluation available.<br /> <br /> ==Keywords==<br /> [[SuZex]], [[zex]], [[Superfunction]]<br /> <br /> [[Category:Suzex]]<br /> [[Category:zex]]<br /> [[Category:Superfunction]]<br /> [[Category:Articles in English]]</div> Maintenance script