Annotation of 43BSDTahoe/usr.lib/lib.b, revision 1.1.1.1

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.