Mathematica Asked by Takumi Hayashi on August 14, 2020
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.
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}]
Correct answer by Ulrich Neumann on August 14, 2020
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP