def integrate_function(function, x_array):
    """
    Calculate the numeric integral of a function along a given x array.
    :param function: a callable function that returns numbers.
    :x_array: a list of ascending number along which to integrate.
    """

    i = integral = 0
    while i < len(x_array) - 2:
        average = (function(x_array[i]) + function(x_array[i + 1])) / 2
        interval = x_array[i + 1] - x_array[i]
        integral += average * interval
        i += 1

    return integral