# How to calculate the area difference of an integral cut at a line with slope?

Using trapezoidal method (because I have a vector and no function is available) I know how to calculate the area difference one gets when the integral (Fig. 1) is cut by a horizontal line such as the mean (Fig. 2). The areas above the line become positive, the areas below negative.

$$\quad\sum_{k=1}^{N}\frac{x_{ik-1} + x_{ik}}{2}\Delta t_k-\bar{x}_{i}\big(t_{k} - t_{1}\big)$$

But how to do this when the line has a slope, such as a quantile regression line (Fig. 3)?

• Your question is very hard to understand. Are you asking how to draw a line such that the areas on both sides compensate each other ? If the slope is known, solve the horizontal problem on $x-st$. – Yves Daoust Feb 15 at 10:59
• Apologies, I've edited the question, hope now it's clear. I'm looking for what's left when a given line cuts the integral and some compensation occurs. – jay.sf Feb 15 at 11:29
• Just subtract the line. – Yves Daoust Feb 15 at 11:30
• Do you mean, just replace the part after the first minus with the line slope? – jay.sf Feb 15 at 11:43
• Replace $x$ by $x-st$. – Yves Daoust Feb 15 at 11:52