def memb_tri(x, triangle):
    """This function determines the membership value belonging to the user defined triangle
    INPUTS
    x - the value
    triangle - user defined triangle in order:left, center, right"""
    left = triangle[0]
    center = triangle[1]
    right = triangle[2]

    if left <= x < center:
        # Left side of triangle
        membership = (x - left) / (center - left)
    elif center <= x <= right:
        # Right side of triangle
        if (center - right) == 0:
            membership = 1
        else:
            membership = (x - right) / (center - right)
    else:
        # not in triangle
        membership = 0

    return membership