# Quick, dirty, imprecise way to find the root of a definite integral?

I'm trying to find a value x that satisfies an equation of the form $y=\int_0^xf(x')dx'$.

As far as I can tell, there's no closed-form solution for $y$, or $dy/dx$, so when I plug this into Solve, NSolve, FindRoot, etc. Mathematica churns for a very long time.

However, I can get an answer to the rough precision I require much quicker if I just plot $\int_0^xf(x')dx'-y$ and read off the value of the root from the plot.

This isn't accurate or precise, but it's quick, and it's good enough for my purposes. The question then is how can I wrangle Mathematica so it does something similar instead of trying to get me the most exact answer?

Playing around with precisiongoal and accuracygoal isn't cutting it, because really what I need is a less sophisticated algorithm. The function is monotonically increasing, so it really should be sufficient just to step up in x by some small amount until the sign changes. Unfortunately I don't know how to code this in Mathematica.

• May be this answer -- that uses minimization with memoization and a coarser grid of numbers -- would give you some ideas to get not very precise answers quickly. – Anton Antonov May 23 '17 at 21:30
• Use NDSolve[] + WhenEvent[]. – J. M.'s technical difficulties May 23 '17 at 21:33

Manipulating my above equation, I arrive at $dy/dx=f(x)$. This can be put into NDSolve with a WhenEvent:
Reap[NDSolve[{Y'[x] == f[x]), Y == 0,

• This event only works if Y[x] is initially less than y and f[x] is positive (at least long enough for the event to happen). You want Y[x] == y (or Y[x] - y == 0). – Michael E2 May 23 '17 at 23:30