# Inverse of the definite integral of a strictly positive function

I'm looking for a way to (sort of) invert the area under the curve formula. Usually, given a function, you can calculate the area under the curve between a starting point and and ending point by calculating the definite integral of the function.

I want to use the function, the starting point, and the area to calculate the ending point.

Take the simple linear function y = mx + b as an example. In my case, I know x > 0 and y > 0.

If I want to calculate the area of under the curve between points a and z, I can use the definite integral: $$\int_a^z (m x+b) \, dx=-\frac{1}{2} (a-z) (m (a+z)+2 b)\$$

Now let's assume I fix point "a" to a certain value. I want a formula that tells me what I need to set point "z" to in order to have the area under the curve equal a certain value.

For example, let's set m = 2, b = 100, and a = 10. I want the area under the curve to be equal to 1000. What do I need to set z to?

This is equivalent to solving: $$\left\{1000=-\frac{1}{2} ((a-z) (m (a+z)+2 b)),a=10,m=2,b=100\right\}$$

Solving for z gives: $$z=-10 (5+\sqrt{46})$$ and $$z=10 (\sqrt{46}-5)$$

And since I only care about positive values, the answer I'm looking for is $$z=10 (\sqrt{46}-5)$$.

When I try to solve for z more generally using WolframAlpha, it gives me an ungodly mess of formulae.

And this seems like an odd sequence of steps. I'd like to do this for multiple formulae (all strictly positive ones), e.g. exponential, sigmoid, etc.

I was hoping I could simply take a function inverse somewhere, but that doesn't seem to be the case either. I think this and this might be relevant, but don't understand them well enough to apply it to the example above.

I also think I might be able to take advantage of the inverse of the indefinite integral. Let's call the indefinite integral F(x).

We know the definite integral $$\int_a^z f(x) \, dx = F(z) - F(a) = AUC$$ (where AUC is area under the curve).

We know the AUC we're aiming for. We know a, so we can calculate F(a). We want to calculate z. We know AUC + F(a) = F(z). We can calculate the function inverse of F(x), let's call this F⁻¹(x).

Let's go back to y = mx + b. $$\int (b+m x) \, dx=\left(b x+\frac{m x^2}{2}\right)+C$$

The function inverse of this is: $$-\frac{2 (b x+C-m)}{x^2}$$

Put it all together...somehow...and can maybe get z?

After some more work, here's my current answer:

Let $$\int f(x) = F(x)$$. The area under the curve of $$f(x)$$ between points $$a$$ and $$z$$ is equal to $$F(z) - F(a)$$.

$$F(z)$$ is the total area A between points 0 and $$z$$ (i.e. $$\int f(z)$$).

That means $$F^{-1}(q)$$ is the the point at which A = $$q$$.

I know my starting area $$A_{start}$$ (i.e. $$F(a)$$) and the target area $$A_{end}$$, so I can calculate: $$F^{-1}(A_{end}) - F^{-1}(A_{start})$$.

If I want to increase the area by x (so end = start + x), I can alternatively write this as: $$F^{-1}(A_{start} + x) - F^{-1}(A_{start})$$.

If I want to decrease the area by x (so end = start - x), I can alternatively write this as: $$F^{-1}(A_{start} - x) - F^{-1}(A_{start})$$.

F(x) and $$F^{-1}$$ are usually simpler to write than the quadratic solutions I found, so this is easier to implement.

For example, for y = mx + b, $$F(x) = \int (mx+b)dx = (bx + mx^2)/2$$ and $$F^{-1} = -2(bx-m)/x^2$$ (WolframAlpha links here and here).

It is better to write $$A=\int_a^z (m x+b) \, dx=\frac{m}{2} (z-a)^2+(am+b)(z-a)$$ and you just have to solve a quadratic in $$(z-a)$$

• I like this. To gain an intuition about this, I tried to a specific example with a=1,000, z=1,100, m=2, b=0: $\int_{1000}^{1100} (2 x+0) \, dx=210000 = A$. $A=\frac{m}{2} (z-a)^2+(am+b)(z-a) = \frac{2}{2} (1100-1000)^2+(1000*2+0)(1100-1000) = 210,000$...so that matched Mar 26, 2022 at 20:43
• When I try to solve for z directly I get three formulas. I can use the positive formula that assumes m != 0 and check: $z=\frac{1}{2} \left(\sqrt{2 \left(1000^2 2+2\ 210000\right)+0^2+0*2*2*1000}+0\right) = 1,100$, as expected. Mar 26, 2022 at 20:57
• I can substitute (z-a) for q and solve for q, which also gives me three formulae. Plugging in the numbers and checking shows the formula works as expected. Mar 26, 2022 at 21:01
• This approach seems to work, but I found the resulting formulas a bit complicated to implement, so I went with what I think is a simpler solution (posted in an answer) Mar 26, 2022 at 21:13