It is straightforward to Integrate
an InterpolatingFunction
. However, even for a simple functional of an InterpolatingFunction
, Integrate
returns unevaluated.
ifun1 =
First[
u /.
NDSolve[
{u''[t] + u[t] == 0, u[0] == 0, u'[0] == 1},
u,
{t, 0, π}
]
]
Integrate[ifun1[t], {t, 0, π}]
Integrate[2*ifun1[t], {t, 0, π}]
The former Integrate
returns a Real
, the latter, the expression unevaluated.
How can the second integral be evaluated symbolically? (In my non-MWE, symbolically is important because the solution to my PDE has two arguments, over only one of which I would like to integrate, so NIntegrate
will not work.) The solution should apply to more-complicated functionals, too (e.g. 2*t*ifun1[t]
). If a solution applies only to functionals that are restricted to a certain family, such as "linear," it would still be helpful.
NIntegrate
$\endgroup$NIntegrate
can't do that, in my experience (because the other argument is non-numerical). (updated my question) $\endgroup$FunctionInterpolation[2*ifun1[t], {t, 0, π}]
to get the resultingInterpolatingFunction
. $\endgroup$c*ifun1[t]
will converge. Even ifc
is constant. Only whenc=1
it will do it. $\endgroup$