def simpson(x,func): "Simpson rule inplementation,for function" delta = (rotate(x,-1) - x)[1] #assumes the function can be evaluated in between discrete points return (delta*(func(rotate(x,-1)) + func(x) + 4*func((rotate(x,-1) + x)/2.)))[:-1] / 6.
def trapez(x,func): "Trapezoid rule inplementation,for function" h = (rotate(x,-1) - x)[1] return (0.5*h*(func(rotate(x,-1)) + func(x)))[:-1]
def df_cent(x): "Central derivative at x, in step size h" h = (rotate(x,-1) - x)[1] return (f(rotate(x,-1)) - f(rotate(x,1)))[1:-1] / (2*h) #does not include edge points
def central_diff(x,func): "Centra Difference" h = np.mean( (trace.value - rotate(trace.value,-1))[:-1]) # print (func(x + h) - func(x - h))/(2*h) return (func(x + h) - func(x - h))/(2*h)
def df_for(x): "Forward derivative at x, using input descritization, ouput array has n-1" h = (rotate(x,-1) - x)[1] return ( f(rotate(x,-1)) - f(x))[:-1] / h #does not include the latter edge point