home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2 / Openstep-4.2-Intel-User.iso / usr / lib / lib.b < prev    next >
Text File  |  1992-03-05  |  2KB  |  199 lines

  1. /*    lib.b    4.1    83/04/02    */
  2. /*
  3. */
  4.  
  5. scale = 20
  6. define e(x){
  7.     auto a, b, c, d, e, g, w, y
  8.  
  9.     t = scale
  10.     scale = t + .434*x + 1
  11.  
  12.     w = 0
  13.     if(x<0){
  14.         x = -x
  15.         w = 1
  16.     }
  17.     y = 0
  18.     while(x>2){
  19.         x = x/2
  20.         y = y + 1
  21.     }
  22.  
  23.     a=1
  24.     b=1
  25.     c=b
  26.     d=1
  27.     e=1
  28.     for(a=1;1==1;a++){
  29.         b=b*x
  30.         c=c*a+b
  31.         d=d*a
  32.         g = c/d
  33.         if(g == e){
  34.             g = g/1
  35.             while(y--){
  36.                 g = g*g
  37.             }
  38.             scale = t
  39.             if(w==1) return(1/g)
  40.             return(g/1)
  41.         }
  42.         e=g
  43.     }
  44. }
  45.  
  46. define l(x){
  47.     auto a, b, c, d, e, f, g, u, s, t
  48.     if(x <=0) return(1-10^scale)
  49.     t = scale
  50.  
  51.     f=1
  52.     scale = scale + scale(x) - length(x) + 1
  53.     s=scale
  54.     while(x > 2){
  55.         s = s + (length(x)-scale(x))/2 + 1
  56.         if(s>0) scale = s
  57.         x = sqrt(x)
  58.         f=f*2
  59.     }
  60.     while(x < .5){
  61.         s = s + (length(x)-scale(x))/2 + 1
  62.         if(s>0) scale = s
  63.         x = sqrt(x)
  64.         f=f*2
  65.     }
  66.  
  67.     scale = t + length(f) - scale(f) + 1
  68.     u = (x-1)/(x+1)
  69.  
  70.     scale = scale + 1.1*length(t) - 1.1*scale(t)
  71.     s = u*u
  72.     b = 2*f
  73.     c = b
  74.     d = 1
  75.     e = 1
  76.     for(a=3;1==1;a=a+2){
  77.         b=b*s
  78.         c=c*a+d*b
  79.         d=d*a
  80.         g=c/d
  81.         if(g==e){
  82.             scale = t
  83.             return(u*c/d)
  84.         }
  85.         e=g
  86.     }
  87. }
  88.  
  89. define s(x){
  90.     auto a, b, c, s, t, y, p, n, i
  91.     t = scale
  92.     y = x/.7853
  93.     s = t + length(y) - scale(y)
  94.     if(s<t) s=t
  95.     scale = s
  96.     p = a(1)
  97.  
  98.     scale = 0
  99.     if(x>=0) n = (x/(2*p)+1)/2
  100.     if(x<0) n = (x/(2*p)-1)/2
  101.     x = x - 4*n*p
  102.     if(n%2!=0) x = -x
  103.  
  104.     scale = t + length(1.2*t) - scale(1.2*t)
  105.     y = -x*x
  106.     a = x
  107.     b = 1
  108.     s = x
  109.     for(i=3; 1==1; i=i+2){
  110.         a = a*y
  111.         b = b*i*(i-1)
  112.         c = a/b
  113.         if(c==0){scale=t; return(s/1)}
  114.         s = s+c
  115.     }
  116. }
  117.  
  118. define c(x){
  119.     auto t
  120.     t = scale
  121.     scale = scale+1
  122.     x = s(x+2*a(1))
  123.     scale = t
  124.     return(x/1)
  125. }
  126.  
  127. define a(x){
  128.     auto a, b, c, d, e, f, g, s, t
  129.     if(x==0) return(0)
  130.     if(x==1) {
  131.         if(scale<52) {
  132. return(.7853981633974483096156608458198757210492923498437764/1)
  133.         }
  134.     }
  135.     t = scale
  136.     f=1
  137.     while(x > .5){
  138.         scale = scale + 1
  139.         x= -(1-sqrt(1.+x*x))/x
  140.         f=f*2
  141.     }
  142.     while(x < -.5){
  143.         scale = scale + 1
  144.         x = -(1-sqrt(1.+x*x))/x
  145.         f=f*2
  146.     }
  147.     s = -x*x
  148.     b = f
  149.     c = f
  150.     d = 1
  151.     e = 1
  152.     for(a=3;1==1;a=a+2){
  153.         b=b*s
  154.         c=c*a+d*b
  155.         d=d*a
  156.         g=c/d
  157.         if(g==e){
  158.             scale = t
  159.             return(x*c/d)
  160.         }
  161.         e=g
  162.     }
  163. }
  164.  
  165. define j(n,x){
  166. auto a,b,c,d,e,g,i,s,k,t
  167.  
  168.     t = scale
  169.     k = 1.36*x + 1.16*t - n
  170.     k = length(k) - scale(k)
  171.     if(k>0) scale = scale + k
  172.  
  173. s= -x*x/4
  174. if(n<0){
  175.     n= -n
  176.     x= -x
  177.     }
  178. a=1
  179. c=1
  180. for(i=1;i<=n;i++){
  181.     a=a*x
  182.     c = c*2*i
  183.     }
  184. b=a
  185. d=1
  186. e=1
  187. for(i=1;1;i++){
  188.     a=a*s
  189.     b=b*i*(n+i) + a
  190.     c=c*i*(n+i)
  191.     g=b/c
  192.     if(g==e){
  193.         scale = t
  194.         return(g/1)
  195.         }
  196.     e=g
  197.     }
  198. }
  199.