0
$\begingroup$

Let $f$ be some interpolated function (so not easily integrable in a strict way), and $g$ is analytic function (for example $\exp$). I want to perform indefinite integral, and plug it into $g$, and finally perform definite integral.

NIntegrate[g[NIntegrate[f[x],{x,0,y}]],{y,0,1}]

However, it fails since NIntegrate only allow definite integral. If I substitute Integrate for the second NIntegrate, it works, but it takes very long time, in my impression. I want to know how to perform this integral and obtain interpolated function $\int_0^x dx f(x)$. Since we can easily differentiate interpolated function directly, I think it should be possible.

Alternatively, if $g=1$ we can rewrite it as a multiple integral,

NIntegrate[Boole[x<y]f[x],{x,0,1},{y,0,1}]

and it works well with much less calculation time. So I also want to generalize such a kind of approach to the case with general $g$ if possible.

$\endgroup$
1
$\begingroup$

The integration NIntegrate[g[NIntegrate[f[x],{x,0,y}]],{y,0,1}]fails because the inner NIntegrate doesn't know about y to be numeric!

Try

int[y_?NumericQ]:=NIntegrate[f[x],{x,0,y}]
NIntegrate[int[y],{y,0,1}] 
| improve this answer | |
$\endgroup$

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.