def area_under_curve(x, y):
    """Finds the area under unevenly spaced curve y=f(x)
        using the trapezoid rule. x,y should be arrays of reals
        with same length.
        returns: a - float, area under curve"""
    a = 0.0
    for i in range(0, len(x) - 1):
        # add area of current trapezium to sum
        a += (x[i + 1] - x[i]) * (y[i + 1] + y[i])
    a = a * 0.5
    return a