2

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?

falematte
  • 173
  • 4

1 Answers1

7

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. *)
kirma
  • 19,056
  • 1
  • 51
  • 93
  • This answer was clearly inspired by @MichaelE2 's answer (http://mathematica.stackexchange.com/a/109276/3056) to my earlier question, although I didn't remember this while writing my own... – kirma May 08 '16 at 15:45