I have to integrate a function and need to split the area under the function in segments of equal area. Of all the areas I get, I need the values of the borders on the x axis.
I found an approach with NDSolve and WhenEvent to specify
the area size (Nintegrate until a certain value is reached). However, I don't get it to work. For simplicity, my function I want to integrate is simply a straight line. I used an interpolating function to get the function of the straight line, because eventually I will also come from discrete points and have to fit a more complicated function.
Here is what I have so far:
timeVector = Table[x, {x, 0, 99}];
yVector = Table[2.5, {100}];(*my function*)
xy = {timeVector, yVector} // Transpose;
interpol = Interpolation[xy];
desiredArea=20;
(*here the actual problem*)
Reap[NDSolve[{x'[t]==interpol[t],x[0]==0,
WhenEvent[Integrate[interpol[t] == desiredArea, Sow[t]],
"StopIntegration"]}, t, {t,0,99}]]
How can I make the WhenEvent function detect multiples of the area?
