11import logging
2- from math import (floor , ceil , trunc , log , sqrt ,
3- cos , sin , tan , asin , acos , atan )
2+ from math import (floor , ceil , trunc , log , cos ,
3+ sin , tan , asin , acos , atan )
44from numbers import Number
55from decimal import Decimal , getcontext , setcontext , Context , ROUND_HALF_UP
66
@@ -282,7 +282,7 @@ def __ge__(self, other):
282282
283283 def __add__ (self , other ):
284284 if isinstance (other , labfloat ):
285- return labfloat (self ._mean + other .mean , sqrt (self ._uncertainty ** 2 + other .uncertainty ** 2 ))
285+ return labfloat (self ._mean + other .mean , (self ._uncertainty ** 2 + other .uncertainty ** 2 ) ** 0.5 )
286286 if isinstance (other , Number ):
287287 return labfloat (self ._mean + other , self ._uncertainty )
288288
@@ -294,13 +294,13 @@ def __iadd__(self, other):
294294
295295 def __sub__ (self , other ):
296296 if isinstance (other , labfloat ):
297- return labfloat (self ._mean - other .mean , sqrt (self ._uncertainty ** 2 + other .uncertainty ** 2 ))
297+ return labfloat (self ._mean - other .mean , (self ._uncertainty ** 2 + other .uncertainty ** 2 ) ** 0.5 )
298298 if isinstance (other , Number ):
299299 return labfloat (self ._mean - other , self ._uncertainty )
300300
301301 def __rsub__ (self , other ):
302302 if isinstance (other , labfloat ):
303- return labfloat (other .mean - self ._mean , sqrt (other .uncertainty ** 2 + self ._uncertainty ** 2 ))
303+ return labfloat (other .mean - self ._mean , (other .uncertainty ** 2 + self ._uncertainty ** 2 ) ** 0.5 )
304304 if isinstance (other , Number ):
305305 return labfloat (other - self ._mean , self ._uncertainty )
306306
@@ -309,7 +309,7 @@ def __isub__(self, other):
309309
310310 def __mul__ (self , other ):
311311 if isinstance (other , labfloat ):
312- return labfloat (self ._mean * other .mean , sqrt ((other .mean * self ._uncertainty ) ** 2 + (self ._mean * other .uncertainty ) ** 2 ))
312+ return labfloat (self ._mean * other .mean , ((other .mean * self ._uncertainty ) ** 2 + (self ._mean * other .uncertainty ) ** 2 ) ** 0.5 )
313313 if isinstance (other , Number ):
314314 return labfloat (self ._mean * other , abs (other * self ._uncertainty ))
315315
@@ -321,7 +321,7 @@ def __imul__(self, other):
321321
322322 def __div__ (self , other ):
323323 if isinstance (other , labfloat ):
324- return labfloat (self ._mean / other .mean , sqrt ((self ._uncertainty / other .mean ) ** 2 + (self ._mean * other .uncertainty / (other .mean ** 2 )) ** 2 ))
324+ return labfloat (self ._mean / other .mean , ((self ._uncertainty / other .mean ) ** 2 + (self ._mean * other .uncertainty / (other .mean ** 2 )) ** 2 ) ** 0.5 )
325325 if isinstance (other , Number ):
326326 return labfloat (self ._mean / other , abs (self ._uncertainty / other ))
327327
@@ -336,7 +336,7 @@ def __itruediv__(self, other):
336336
337337 def __rdiv__ (self , other ):
338338 if isinstance (other , labfloat ):
339- return labfloat (other .mean / self ._mean , sqrt ((other .uncertainty / self ._mean ) ** 2 + (other .mean * self ._uncertainty / (self ._mean ** 2 )) ** 2 ))
339+ return labfloat (other .mean / self ._mean , ((other .uncertainty / self ._mean ) ** 2 + (other .mean * self ._uncertainty / (self ._mean ** 2 )) ** 2 ) ** 0.5 )
340340 if isinstance (other , Number ):
341341 return labfloat (other / self ._mean , abs (other * self ._uncertainty / self ._mean ** 2 ))
342342
@@ -345,13 +345,13 @@ def __rtruediv__(self, other):
345345
346346 def __pow__ (self , other ):
347347 if isinstance (other , labfloat ):
348- return labfloat (self ._mean ** other .mean , sqrt ((other .mean * self ._mean ** (other .mean - 1 ) * self ._uncertainty ) ** 2 + (self ._mean ** other .mean * log (abs (self ._mean )) * other .uncertainty ) ** 2 ))
348+ return labfloat (self ._mean ** other .mean , ((other .mean * self ._mean ** (other .mean - 1 ) * self ._uncertainty ) ** 2 + (self ._mean ** other .mean * log (abs (self ._mean )) * other .uncertainty ) ** 2 ) ** 0.5 )
349349 if isinstance (other , Number ):
350350 return labfloat (self ._mean ** other , abs (other * self ._mean ** (other - 1 ) * self ._uncertainty ))
351351
352352 def __rpow__ (self , other ):
353353 if isinstance (other , labfloat ):
354- return labfloat (other .mean ** self ._mean , sqrt ((self ._mean * other .mean ** (self ._mean - 1 ) * other .uncertainty ) ** 2 + (other .mean ** self ._mean * log (abs (other .mean )) * self ._uncertainty ) ** 2 ))
354+ return labfloat (other .mean ** self ._mean , ((self ._mean * other .mean ** (self ._mean - 1 ) * other .uncertainty ) ** 2 + (other .mean ** self ._mean * log (abs (other .mean )) * self ._uncertainty ) ** 2 ) ** 0.5 )
355355 if isinstance (other , Number ):
356356 return labfloat (other ** self ._mean , abs (other ** self ._mean * log (abs (other )) * self ._uncertainty ))
357357
@@ -368,13 +368,13 @@ def sin(self):
368368 return labfloat (sin (self ._mean ), abs (cos (self ._mean ) * self ._uncertainty ))
369369
370370 def tan (self ):
371- return labfloat (tan (self ._mean ), sqrt ((cos (self ._mean ) ** - 4 ) * self ._uncertainty ** 2 ))
371+ return labfloat (tan (self ._mean ), ((cos (self ._mean ) ** - 4 ) * self ._uncertainty ** 2 ) ** 0.5 )
372372
373373 def arcsin (self ):
374- return labfloat (asin (self ._mean ), self ._uncertainty / sqrt (1 - self ._mean ** 2 ))
374+ return labfloat (asin (self ._mean ), self ._uncertainty / (1 - self ._mean ** 2 ))
375375
376376 def arccos (self ):
377- return labfloat (acos (self ._mean ), abs (- self ._uncertainty / sqrt (1 - self ._mean ** 2 )))
377+ return labfloat (acos (self ._mean ), abs (- self ._uncertainty / (1 - self ._mean ** 2 )) ** 0.5 )
378378
379379 def arctan (self ):
380380 return labfloat (atan (self ._mean ), self ._uncertainty / (1 + self ._mean ** 2 ))
0 commit comments