def apply_finite_diff(order, x_list, y_list, x0=S(0)):
 N = (len(x_list) - 1)
 if (len(x_list) != len(y_list)):
  raise ValueError('x_list and y_list not equal in length.')
 delta = finite_diff_weights(order, x_list, x0)
 derivative = 0
 for nu in range(0, len(x_list)):
  derivative += (delta[order][N][nu] * y_list[nu])
 return derivative

def apply_finite_diff ( order , x_list , y_list , x0 = S ( 0 ) ) : N = ( len ( x_list ) - 1 ) if ( len ( x_list ) != len ( y_list ) ) : raise ValueError ( 'x_list and y_list not equal in length.' ) delta = finite_diff_weights ( order , x_list , x0 ) derivative = 0 for nu in range ( 0 , len ( x_list ) ) : derivative += ( delta [ order ] [ N ] [ nu ] * y_list [ nu ] ) return derivative
calculates the finite difference approximation of the derivative of requested order at x0 from points provided in x_list and y_list .