home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 15 / 15.iso / s / s053 / 9.ddi / usr / lib / lib.b < prev    next >
Encoding:
Text File  |  1990-12-08  |  2.5 KB  |  220 lines

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