#include "FEATURE/uwin"12#if !_UWIN34void _STUB_exp__E(){}56#else78/*9* Copyright (c) 1985, 199310* The Regents of the University of California. All rights reserved.11*12* Redistribution and use in source and binary forms, with or without13* modification, are permitted provided that the following conditions14* are met:15* 1. Redistributions of source code must retain the above copyright16* notice, this list of conditions and the following disclaimer.17* 2. Redistributions in binary form must reproduce the above copyright18* notice, this list of conditions and the following disclaimer in the19* documentation and/or other materials provided with the distribution.20* 3. Neither the name of the University nor the names of its contributors21* may be used to endorse or promote products derived from this software22* without specific prior written permission.23*24* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND25* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE26* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE27* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE28* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL29* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS30* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)31* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT32* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY33* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF34* SUCH DAMAGE.35*/3637#ifndef lint38static char sccsid[] = "@(#)exp__E.c 8.1 (Berkeley) 6/4/93";39#endif /* not lint */4041/* exp__E(x,c)42* ASSUMPTION: c << x SO THAT fl(x+c)=x.43* (c is the correction term for x)44* exp__E RETURNS45*46* / exp(x+c) - 1 - x , 1E-19 < |x| < .346573647* exp__E(x,c) = |48* \ 0 , |x| < 1E-19.49*50* DOUBLE PRECISION (IEEE 53 bits, VAX D FORMAT 56 BITS)51* KERNEL FUNCTION OF EXP, EXPM1, POW FUNCTIONS52* CODED IN C BY K.C. NG, 1/31/85;53* REVISED BY K.C. NG on 3/16/85, 4/16/85.54*55* Required system supported function:56* copysign(x,y)57*58* Method:59* 1. Rational approximation. Let r=x+c.60* Based on61* 2 * sinh(r/2)62* exp(r) - 1 = ---------------------- ,63* cosh(r/2) - sinh(r/2)64* exp__E(r) is computed using65* x*x (x/2)*W - ( Q - ( 2*P + x*P ) )66* --- + (c + x*[---------------------------------- + c ])67* 2 1 - W68* where P := p1*x^2 + p2*x^4,69* Q := q1*x^2 + q2*x^4 (for 56 bits precision, add q3*x^6)70* W := x/2-(Q-x*P),71*72* (See the listing below for the values of p1,p2,q1,q2,q3. The poly-73* nomials P and Q may be regarded as the approximations to sinh74* and cosh :75* sinh(r/2) = r/2 + r * P , cosh(r/2) = 1 + Q . )76*77* The coefficients were obtained by a special Remez algorithm.78*79* Approximation error:80*81* | exp(x) - 1 | 2**(-57), (IEEE double)82* | ------------ - (exp__E(x,0)+x)/x | <=83* | x | 2**(-69). (VAX D)84*85* Constants:86* The hexadecimal values are the intended ones for the following constants.87* The decimal values may be used, provided that the compiler will convert88* from decimal to binary accurately enough to produce the hexadecimal values89* shown.90*/9192#include "mathimpl.h"9394vc(p1, 1.5150724356786683059E-2 ,3abe,3d78,066a,67e1, -6, .F83ABE67E1066A)95vc(p2, 6.3112487873718332688E-5 ,5b42,3984,0173,48cd, -13, .845B4248CD0173)96vc(q1, 1.1363478204690669916E-1 ,b95a,3ee8,ec45,44a2, -3, .E8B95A44A2EC45)97vc(q2, 1.2624568129896839182E-3 ,7905,3ba5,f5e7,72e4, -9, .A5790572E4F5E7)98vc(q3, 1.5021856115869022674E-6 ,9eb4,36c9,c395,604a, -19, .C99EB4604AC395)99100ic(p1, 1.3887401997267371720E-2, -7, 1.C70FF8B3CC2CF)101ic(p2, 3.3044019718331897649E-5, -15, 1.15317DF4526C4)102ic(q1, 1.1110813732786649355E-1, -4, 1.C719538248597)103ic(q2, 9.9176615021572857300E-4, -10, 1.03FC4CB8C98E8)104105#ifdef vccast106#define p1 vccast(p1)107#define p2 vccast(p2)108#define q1 vccast(q1)109#define q2 vccast(q2)110#define q3 vccast(q3)111#endif112113double __exp__E(x,c)114double x,c;115{116const static double zero=0.0, one=1.0, half=1.0/2.0, small=1.0E-19;117double z,p,q,xp,xh,w;118if(copysign(x,one)>small) {119z = x*x ;120p = z*( p1 +z* p2 );121#if defined(vax)||defined(tahoe)122q = z*( q1 +z*( q2 +z* q3 ));123#else /* defined(vax)||defined(tahoe) */124q = z*( q1 +z* q2 );125#endif /* defined(vax)||defined(tahoe) */126xp= x*p ;127xh= x*half ;128w = xh-(q-xp) ;129p = p+p;130c += x*((xh*w-(q-(p+xp)))/(one-w)+c);131return(z*half+c);132}133/* end of |x| > small */134135else {136if(x!=zero) one+small; /* raise the inexact flag */137return(copysign(zero,x));138}139}140141#endif142143144