# Compute unknown limit from known integral in Mathematica?

I have an integral

$\int_a^b \! f(x) \, \mathrm{d}x = c$

where I know c and either a or b. Now I want to compute either b or a (i.e., the missing limit). How would I do that in Mathematica/Wolfram Alpha?

-

$\tt{Solve[Integrate[f[x], \{x, a, b\}] == c]}$ seems to work.

Edit:
It has been pointed out by J.M. and monoid that the Solve function requires you to specify which variable you're searching for. In this case Mathematica understands which variable you want (assuming you have specified $c$ and either $a$ or $b$). In other cases it might be necessary to specify. For example $$\tt{Solve[Integrate[f[x], \{x, a, b\}] == c,b]}.$$ In any case there is no harm in specifying.

-
You saved me a lot of time, thanks! ;) – HelmutSteiner May 9 '11 at 12:16
Solve[], of course, requires you to specify the variable to solve for as well. So, something like Solve[Integrate[f[x], {x, a, b}] == c, a] or similarly for b. However, since the likelihood that Solve[] won't manage to do much is a bit high, FindRoot[] might be more useful than solve. – J. M. May 9 '11 at 13:09
@J.M.: Actually you don't need to specify the variable to solve for in this case, because there is only one variable. – please delete me May 9 '11 at 13:28
Hmm, yes, if only one variable remains; I was thinking of the case where everything is kept symbolic instead of substituting numerical values. In any event, indicating what variable you're solving for does no harm and makes for less ambiguous code. – J. M. May 9 '11 at 13:30
@J.M.: Yes, you're right. I edited my answer to clarify that. Thank you. – please delete me May 9 '11 at 13:37

Eivind answer will only solve the integral to c, but if you want to solve it for a or b you must add it into the Solve expression:

For example:

g[x] := x^2 - x^3;
c := 10;
a := 3;
Solve[Integrate[g[x], {x, a, b}] == c, b]


{{b -> -(1/3) + 1/(3 Sqrt[2/(2 - (3 471^(2/3))/(-1 + 2 Sqrt[118])^(1/3) + 3 (471 (-1 + 2 Sqrt[118]))^(1/3))]) -
1/2 \[Sqrt](8/9 + (2 157^(2/3))/(3 (-1 + 2 Sqrt[118]))^(1/3) - (
2 (157 (-1 + 2 Sqrt[118]))^(1/3))/3^(2/3) -
8/9 Sqrt[2/(
2 - (3 471^(2/3))/(-1 + 2 Sqrt[118])^(1/3) +
3 (471 (-1 + 2 Sqrt[118]))^(1/3))])},...


etc...

-
As far as I can see, I get the same answer as you do by using the method I suggested. – please delete me May 9 '11 at 11:57
Hmm, I thought your expression forgot the searched variable. I'll try it in a second. It really works, mea culpa! – monoid May 9 '11 at 12:00
Anyways, thanks for your efforts! – HelmutSteiner May 9 '11 at 12:16
After reading about the Solve function, I realize that you should specify a variable. Maybe it works in this case because there is only one variable to choose from. – please delete me May 9 '11 at 13:24
@Eivind: That could be the reason. I added the variable because reading the command gets more user-friendly. – monoid May 13 '11 at 10:21