Example: Sum Integrate ≠ Integrate Sum

230: Mathematical Methods in Physics

R.G. Palmer, 10/9/00

\(∑\+\(n = 1\)\%∞∫\(f\_n\) \((x)\) dx\ \ \  ≠ \ \ ∫\ \(∑\+\(n = 1\)\%∞\( f\_n\) \((x)\) dx\)\)

Example:  (Subscript[f, n]) (x)

f[x_, n_] := 
      n x Exp[-n x^2] - (n  - 1) 
          x Exp[-(n - 1) x^2]

Sum: F(x) = (∑_(n = 1)^∞) (Subscript[f, n]) (x)

F[x_] = Sum[f[x, n], {n, 1, ∞}]

(∫_0^1)(∑_(n = 1)^∞) 
                (Subscript[f, n]) (x) dx  = (∫_0^1) F (x) dx = 0

Integrate[F[x], {x, 0, 1}]

(∫_0^1) (Subscript[f, n]) (x) dx

Integrate[f[x, n], {x, 0, 1}]

(∑_(n = 1)^∞)(∫_0^1) (Subscript[f, n]) (x) dx

Sum[%, {n, 1, ∞}]

% // Simplify

Plot

Sum partial: (Subscript[S, N])(x) = (∑_(n = 1)^N) (Subscript[f, n]) (x)

S[x_, nmax_] = Sum[f[x, n], {n, 1, nmax}]

samples = {1, 3, 10, 30, 100, 300, 1000};
lines = Map[(S[x, #] &), samples];
mount[n_] := (-1)*
          RotateRight[
            MapAt[(-x /. #) &, FindMinimum[-S[x, n], {x, 0, 1}], 
              2], 1];
texts = 
        Map[(Text[#, mount[#], {-1, -1}]) &, 
          samples];
Plot[Evaluate[lines], {x, 0, 1}, PlotRange -> All, 
      Epilog -> texts]