from__future__importdivisionimportnumpyasnpimportmatplotlib.pyplotaspltdefinterpolated_intercepts(x,y1,y2):"""Find the intercepts of two curves, given by the same x data"""defintercept(point1,point2,point3,point4):"""find the intersection between two lines
the first line is defined by the line between point1 and point2
the first line is defined by the line between point3 and point4
each point is an (x,y) tuple.
So, for example, you can find the intersection between
intercept((0,0), (1,1), (0,1), (1,0)) = (0.5, 0.5)
Returns: the intercept, in (x,y) format
"""defline(p1,p2):A=(p1[1]-p2[1])B=(p2[0]-p1[0])C=(p1[0]*p2[1]-p2[0]*p1[1])returnA,B,-Cdefintersection(L1,L2):D=L1[0]*L2[1]-L1[1]*L2[0]Dx=L1[2]*L2[1]-L1[1]*L2[2]Dy=L1[0]*L2[2]-L1[2]*L2[0]x=Dx/D
y=Dy/Dreturnx,y
L1=line([point1[0],point1