I have a list of x and y values for two curves, both having weird shapes, and I don\'t have a function for any of them. I need to do two things: (1) plot it and shade the ar
Define your two curves as functions f
and g
that are linear by segment, e.g. between x1
and x2
, f(x) = f(x1) + ((x-x1)/(x2-x1))*(f(x2)-f(x1))
.
Define h(x)=abs(g(x)-f(x))
. Then use scipy.integrate.quad
to integrate h.
That way you don't need to bother about the intersections. It will do the "trapeze summing" suggested by ch41rmn automatically.