2
$\begingroup$

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?

$\endgroup$
0
7
$\begingroup$

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. *)
$\endgroup$
1
  • $\begingroup$ 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... $\endgroup$
    – kirma
    May 8 '16 at 15:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.