numpy - higher precision in python -


i running python v3.3.2 scripts use numpy , scipy , math. suspecting there issue of numerical precision in computation, , increase precision in particular modules have written , see if makes difference in final result. in module using algebraic manipulations , numpy.sqrt.

how manipulate precision of computations in module written me?(i can modify it). have seen there several modules available decimal , mpmath , bigfloat, , trying figure out documentation 1 more suitable task. first 1 installed , should install other two. ideally write command on top of module , specifying precision need in module, exist?

edit ---------

i think problem may come computation of second derivative:

def secondderivative(x,y):   xl     = np.roll(x,1) # x1   xr     = np.roll(x,-1)# x3   yl     = np.roll(y,1)   yr     = np.roll(y,-1)    ind    = np.where(np.isnan(y) | np.isnan(yl) | np.isnan(yr) )[0]    deriv2 = (2 * yl / ((x - xl)  * (xr - xl))         - 2 * y  / ((xr - x)  * (x - xl))         + 2 * yr / ((xr - xl) * (xr - x)))    in ind:     deriv2[i] = np.nan    deriv2[0]             = np.nan   deriv2[len(deriv2)-1] = np.nan   return deriv2 

i have seen result gradient different:

np.gradient(np.gradient(y,x),x) 

when code based on numpy/scipy , co., can use types supported these libs. here overview.

the paragraph extended precision relevant you.

combining numpy/scipy decimal, mpmath , co. need lot of work (in general case)!

it have been more wise show code 1 guess what's going on. limited precision, there techniques makes difference: e.g. iterative-refinement in solving linear systems.


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -