1/* $OpenBSD: t1.in,v 1.1 2003/09/25 19:40:07 otto Exp $ */ 2 3/* 4 * Copyright (C) Caldera International Inc. 2001-2002. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code and documentation must retain the above 11 * copyright notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 3. All advertising materials mentioning features or use of this software 16 * must display the following acknowledgement: 17 * This product includes software developed or owned by Caldera 18 * International, Inc. 19 * 4. Neither the name of Caldera International, Inc. nor the names of other 20 * contributors may be used to endorse or promote products derived from 21 * this software without specific prior written permission. 22 * 23 * USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA 24 * INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR 25 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 26 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 27 * IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE LIABLE FOR ANY DIRECT, 28 * INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 33 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34 * POSSIBILITY OF SUCH DAMAGE. 35 */ 36 37/* 38 * @(#)bc.library 5.1 (Berkeley) 4/17/91 39 */ 40 41scale = 20 42define e(x){ 43 auto a, b, c, d, e, g, t, w, y 44 45 t = scale 46 scale = t + .434*x + 1 47 48 w = 0 49 if(x<0){ 50 x = -x 51 w = 1 52 } 53 y = 0 54 while(x>2){ 55 x = x/2 56 y = y + 1 57 } 58 59 a=1 60 b=1 61 c=b 62 d=1 63 e=1 64 for(a=1;1==1;a++){ 65 b=b*x 66 c=c*a+b 67 d=d*a 68 g = c/d 69 if(g == e){ 70 g = g/1 71 while(y--){ 72 g = g*g 73 } 74 scale = t 75 if(w==1) return(1/g) 76 return(g/1) 77 } 78 e=g 79 } 80} 81 82define l(x){ 83 auto a, b, c, d, e, f, g, u, s, t 84 if(x <=0) return(1-10^scale) 85 t = scale 86 87 f=1 88 scale = scale + scale(x) - length(x) + 1 89 s=scale 90 while(x > 2){ 91 s = s + (length(x)-scale(x))/2 + 1 92 if(s>0) scale = s 93 x = sqrt(x) 94 f=f*2 95 } 96 while(x < .5){ 97 s = s + (length(x)-scale(x))/2 + 1 98 if(s>0) scale = s 99 x = sqrt(x) 100 f=f*2 101 } 102 103 scale = t + length(f) - scale(f) + 1 104 u = (x-1)/(x+1) 105 106 scale = scale + 1.1*length(t) - 1.1*scale(t) 107 s = u*u 108 b = 2*f 109 c = b 110 d = 1 111 e = 1 112 for(a=3;1==1;a=a+2){ 113 b=b*s 114 c=c*a+d*b 115 d=d*a 116 g=c/d 117 if(g==e){ 118 scale = t 119 return(u*c/d) 120 } 121 e=g 122 } 123} 124 125define s(x){ 126 auto a, b, c, s, t, y, p, n, i 127 t = scale 128 y = x/.7853 129 s = t + length(y) - scale(y) 130 if(s<t) s=t 131 scale = s 132 p = a(1) 133 134 scale = 0 135 if(x>=0) n = (x/(2*p)+1)/2 136 if(x<0) n = (x/(2*p)-1)/2 137 x = x - 4*n*p 138 if(n%2!=0) x = -x 139 140 scale = t + length(1.2*t) - scale(1.2*t) 141 y = -x*x 142 a = x 143 b = 1 144 s = x 145 for(i=3; 1==1; i=i+2){ 146 a = a*y 147 b = b*i*(i-1) 148 c = a/b 149 if(c==0){scale=t; return(s/1)} 150 s = s+c 151 } 152} 153 154define c(x){ 155 auto t 156 t = scale 157 scale = scale+1 158 x = s(x+2*a(1)) 159 scale = t 160 return(x/1) 161} 162 163define a(x){ 164 auto a, b, c, d, e, f, g, s, t 165 if(x==0) return(0) 166 if(x==1) { 167 if(scale<52) { 168 return(.7853981633974483096156608458198757210492923498437764/1) 169 } 170 } 171 t = scale 172 f=1 173 while(x > .5){ 174 scale = scale + 1 175 x= -(1-sqrt(1.+x*x))/x 176 f=f*2 177 } 178 while(x < -.5){ 179 scale = scale + 1 180 x = -(1-sqrt(1.+x*x))/x 181 f=f*2 182 } 183 s = -x*x 184 b = f 185 c = f 186 d = 1 187 e = 1 188 for(a=3;1==1;a=a+2){ 189 b=b*s 190 c=c*a+d*b 191 d=d*a 192 g=c/d 193 if(g==e){ 194 scale = t 195 return(x*c/d) 196 } 197 e=g 198 } 199} 200 201define j(n,x){ 202 auto a,b,c,d,e,g,i,s,k,t 203 204 t = scale 205 k = 1.36*x + 1.16*t - n 206 k = length(k) - scale(k) 207 if(k>0) scale = scale + k 208 209 s= -x*x/4 210 if(n<0){ 211 n= -n 212 x= -x 213 } 214 a=1 215 c=1 216 for(i=1;i<=n;i++){ 217 a=a*x 218 c = c*2*i 219 } 220 b=a 221 d=1 222 e=1 223 for(i=1;1;i++){ 224 a=a*s 225 b=b*i*(n+i) + a 226 c=c*i*(n+i) 227 g=b/c 228 if(g==e){ 229 scale = t 230 return(g/1) 231 } 232 e=g 233 } 234} 235