```1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 ``` ```import math, mpmath from mpmath import mp import decimal mp.dps = 12 #print(mp.quad(lambda x: mp.exp(-x**2), [-mp.inf, mp.inf]) ** 2) st = 10 t = st ti = 1 lv = 44 pre = 0.00000000000 fp = 0.0 fluxList = [7, 3, 9, 6, 8, 2, 3, 7, 3, 9, 5, 2, 8, 9, 4, 3, 6, 7, 5, 9, 5, 6, 4, 4, 8, 7, 7, 8, 3, 6, 2, 3, 7, 6,] lpre = [] lxpre = [] #print(mpmath.polylog(3,3)) #print(fluxList) #encode xpre = 0.0 cnt = 0 ccn = 0.0 preflux = 0 prepre = 0.0 xerr = 0.0 totalerr = 0.0 lllvt = 0.0 for flux in fluxList: llvt = mpmath.log(t,lv) #print(lv ** llvt, ' - ',llvt) #print(pre, xerr) fp = flux + pre pre = mpmath.power(llvt, fp) # ======= reverse calculation for error correction if(pre!=0): lllvt = mpmath.log(pre, llvt) xpre = lllvt - flux xerr = prepre - xpre #pre = pre + xerr #print(pre, pre + xerr, xerr) #xpre = xpre+xerr #totalerr = totalerr + xerr #print(lllvt, fp) #pre = pre + xerr lpre.append(pre + xerr) #pre = pre + tpre #print('Time:',t,'LogTime:',llvt,'Fp:', fp,'Pre:', pre) t = t + ti #pre = mpmath.sqrt(llvt) cnt = cnt +1 prepre = pre #print(t, '|', llvt,'|', flux,'|', fp,'|', pre) #print('---', lpre) #print('---', lxpre) #print(totalerr) lastNum = pre # last number #--correct errors # xcn = 0 # t=st # for epre in lpre: # #print(epre,lxpre[xcn] ) # llvt = mpmath.log(t, lv) # lllvt = mpmath.log(epre, llvt) # xflux = int(lllvt) # xpre = lllvt - xflux # #lxpre.append(xpre) # if(xcn>0): # lpre[xcn-1] = lpre[xcn-1] # print(lpre[xcn-1], xpre) # # t = t+ti # xcn = xcn+1 #------------------------------------------------------ #print(lpre) ####decode #dd = mpmath.log(pre,100) print('-----------------------------------------------') print('number generated',lastNum) print('-----------------------------------------------') #x = mp.nsum(lambda k: 4*(-1)**(k+1)/(2*k-1), [1,mp.inf]) #print(x) #(exp(1+euler/2)/nprod(lambda n: (1+1/n)**n * exp(1/(2*n)-1), [1, inf]))**2/2 t = len(fluxList)+st-1 ##skip last flux = 0 count = 0 resultFlux = [] #lerr.append(aaa) while (t >= st): llvt = mpmath.log(t, lv) #lpre is from encoding lpr = lpre[t - st] err = lpr - lastNum #reencoding and decoding to calkulate error rate fp = flux + lastNum qpre = mpmath.power(llvt, fp) qlllvt = mpmath.log(qpre, llvt) qflux = int(qlllvt) qlast = qlllvt - qflux #print(lpr, qlast, lastNum) #lastNum = lastNum + (qlast-lastNum) print(lpr, lastNum, err) #errL.append(err) #print(lpr,lastNum) #print(flux, lastNum, err) #with error correction lastNum = lastNum + err lllvt = mpmath.log(lastNum,llvt) flux = int(lllvt) lastNum = lllvt-flux #print(t, flux) resultFlux.append(flux) t=t-1 #print(errL) resultFlux.reverse() #print(len(fluxList)) print('Results :',resultFlux) print('Original:',fluxList) ```
 ```1 2 3 4 ``` ```Traceback (most recent call last): Line 1, in import math, mpmath ImportError: No module named mpmath ```