Find when integral of an interpolated function is equal to a specific value (python)
<p>I have arrays <code>t_array</code> and <code>dMdt_array</code> of x and y points. Let's call <code>M = trapz(dMdt_array, t_array)</code>. I want to find at what value of t the integral of dM/dt vs t is equal to a certain value -- say <code>0.05*M</code>. In python, is there a nice way to do this?</p>

<p>I was thinking something like <code>F = interp1d(t_array, dMdt_array)</code>. Then some kind of root find for where the integral of F is equal to 0.05*M. Can I do this in python?</p>

<p>One simple way is to use the CubicSpline class instead. Then it's <code>CubicSpline(x, y).antiderivative().solve(0.05*M)</code> or thereabouts.</p>

python scipy