# FunctionInterpolation changes the Output dimensions of an InterpolatingFunction

Minimal example

fun = (r /.NDSolve[
{D[r[t], t] == -I (PauliMatrix[1].r[t]-r[t].PauliMatrix[1]),
r[0] == {{1, 0}, {0, 0}}},
r,
{t, 0, 2}][[1]])


fun is the solution of a differential equation of matrices as a InterpolatingFunction. It has Output dimensions {2,2}, i.e. for each t it returns a two by two matrix, as it should.

If apply FunctionInterpolation to it, the Output dimensions change to {2}, i.e.

FunctionInterpolation[fun[t],{t,0,2}]


returns an InterpolatingFunction which returns a vector of length 2.

Context

I want to multiply the output fun[t] by a probability-distribution e.g. PDF[NormalDistribution[1,0.1],t] and Integrate over t around 1. To achieve this I thought, inspired by the tutorial on Approximate Functions and Interpolation, I could do something like this:

NIntegrate[
FunctionInterpolation[PDF[NormalDistribution[1, 0.1], t]*fun[t], {t, 0, 2}],
{t,0.8,1.2}]


Which fails due to non-numerical values for all sampling points in the region with boundaries... which might but maybe not has something to do with the problem above.

Cheers

• Note that fun already is a function interpolation. It doesn't seem that FunctionInterpolation should even be considered in this case. Dec 14, 2016 at 14:58
• Related: (77589), (126342) Dec 14, 2016 at 15:05
• Hey @MichaelE2, thanks for your comment. In the link above, FunctionInterpolation is used as FunctionInterpolation[x+sin[x^2],{x,0,1}] where sin is an InterpolatingFunction of Sin, i.e. it is used to combine normal functions (Plus,Power) with an InterpolatingFunction which is what I want to do ultimately. The minimal example might as well include a +t to mirror the example better yet it has the same problem. Cheers Edit: The second link you provided might help me a lot later, thanks! Dec 14, 2016 at 15:06
• You may want to try other tacks like: Evaluating both as "fields" over the range. Separating the Integral into Real and Imaginary and/or separating it by "Parts" as two separate NIntegrate or N[Integrate[]] Functions. Dec 14, 2016 at 15:40

Using NDSolve is mentioned in my answer to NIntegrate over a list of functions:
{fun, expectation} = {r, int} /. First@NDSolve[