def avg_n_nplusone(x):
    """ returns x[0]/2, (x[0]+x[1])/2, ... (x[-2]+x[-1])/2, x[-1]/2 
    """

    y = np.zeros(1 + x.shape[0])
    hx = 0.5 * x 
    y[:-1] = hx
    y[1:] += hx 
    return y
returns x[0]/2, (x[0]+x[1])/2, ... (x[-2]+x[-1])/2, x[-1]/2