def derivative(xdata, ydata):
D_ydata = []<EOL>D_xdata = []<EOL>for n in range(<NUM_LIT:1>, len(xdata)-<NUM_LIT:1>):<EOL><INDENT>D_xdata.append(xdata[n])<EOL>D_ydata.append((ydata[n+<NUM_LIT:1>]-ydata[n-<NUM_LIT:1>])/(xdata[n+<NUM_LIT:1>]-xdata[n-<NUM_LIT:1>]))<EOL><DEDENT>return [D_xdata, D_ydata]<EOL>
performs d(ydata)/d(xdata) with nearest-neighbor slopes
must be well-ordered, returns new arrays [xdata, dydx_data]

neighbors: