Minimal example

fun = (r /.NDSolve[
    {D[r[t], t] == -I (PauliMatrix[1].r[t]-r[t].PauliMatrix[1]), 
     r[0] == {{1, 0}, {0, 0}}},
     {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.


returns an InterpolatingFunction which returns a vector of length 2.


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:

FunctionInterpolation[PDF[NormalDistribution[1, 0.1], t]*fun[t], {t, 0, 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.

I'd appreciate any comments,


  • $\begingroup$ Note that fun already is a function interpolation. It doesn't seem that FunctionInterpolation should even be considered in this case. $\endgroup$
    – Michael E2
    Dec 14, 2016 at 14:58
  • $\begingroup$ Related: (77589), (126342) $\endgroup$
    – Michael E2
    Dec 14, 2016 at 15:05
  • $\begingroup$ 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! $\endgroup$
    – AndreasP
    Dec 14, 2016 at 15:06
  • $\begingroup$ 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. $\endgroup$
    – Ramble
    Dec 14, 2016 at 15:40

1 Answer 1


Using NDSolve is mentioned in my answer to NIntegrate over a list of functions:

{fun, expectation} = {r, int} /. First@NDSolve[
     {D[r[t], t] == -I (PauliMatrix[1].r[t] - r[t].PauliMatrix[1]), 
      r[0] == {{1, 0}, {0, 0}},
      int'[t] == PDF[NormalDistribution[1, 0.1], t]*r[t], 
      int[0] == {{0, 0}, {0, 0}}},
     {r, int}, {t, 0, 2}];
(*  {{0.296047 + 0. I, 0. + 0.445646 I}, {0. - 0.445646 I, 0.703953 + 0. I}}  *)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.