def derivative(x,y,order=1):
    """Given the x any y arrays will return the derivative of this array, optionally higher derivatives
    can be calculated by giving the order"""
    for n in range(1,order+1,1):
        dy=y[1:]-y[:-1]
        dx=x[1:]-x[:-1]    
        y = dy/dx
        x = (x[1:]+x[:-1])/2.0
    return x, y