# Nintegrate until a certain value is reached

I need to launch a Nintegrate command to integrate a function on a domain $(0,x_{b})$ where the value $x_{b}$ is determined by the fact that the integral reach a certain value. Is it possible to do this?

You can find the value of $x_{b}$ by using NDSolve and a stopping condition:

Reap[
NDSolve[{x'[t] == Sin[t], x[0] == 0,
WhenEvent[x[t] == 1, Sow[t]; "StopIntegration"]},
x, {t, Infinity}]][[2, 1, 1]]

(* 1.5708 *)


Just to verify:

Integrate[Sin[t], {t, 0, 1.5708}]

(* 1. *)

• This answer was clearly inspired by @MichaelE2 's answer (mathematica.stackexchange.com/a/109276/3056) to my earlier question, although I didn't remember this while writing my own... May 8 '16 at 15:45