3
$\begingroup$

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?

2 Answers 2

4

$\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.

  • 0
    You saved me a lot of time, thanks! ;)2011-05-09
  • 0
    `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.2011-05-09
  • 0
    @J.M.: Actually you don't need to specify the variable to solve for in this case, because there is only one variable.2011-05-09
  • 1
    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.2011-05-09
  • 0
    @J.M.: Yes, you're right. I edited my answer to clarify that. Thank you.2011-05-09
1

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] 

Mathematica will answer:

{{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...

  • 0
    As far as I can see, I get the same answer as you do by using the method I suggested.2011-05-09
  • 0
    Hmm, I thought your expression forgot the searched variable. I'll try it in a second. It really works, mea culpa!2011-05-09
  • 0
    Anyways, thanks for your efforts!2011-05-09
  • 0
    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.2011-05-09
  • 0
    @Eivind: That could be the reason. I added the variable because reading the command gets more user-friendly.2011-05-13