Assume that you have membership functions defined using straight line segments.
Say, we have membership fucntion as: μ{cool}(temp), μ{moderate}(temp), μ{hot}(temp)
so, if you look at μ{cool}(temp) then we can write it as,
μ{cool}(temp) = 1 if Temp. ≤10
μ{cool}(temp) = 0 if Temp≥20
μ{cool}(temp) = <Equation of line joining (10, 1)and(20, 0) > if 10<Temp<20
You have to write separate functions for calculating union, intersection of two fuzzy sets and the complement of a fuzzy set. Use matplotlib to plot the original functions as well as the union, intersection and complement. Also, your code should find the equation of the line given the end points. You will give inputs as (a) Number of straight line segments and (b) The end points of each straight line.