(I should start by saying I'm a total beginner with Mathematica, so if the answer needs code I'll need it spelled out quite clearly, the learning curve for this is proving steep!)
Basically what I am trying to so is manipulate a power series for an expression involving the function alpha(r) inside an indefinite sum, so that I can pick out coefficients from it (series solving an ODE, for context). The following code is used to produce alpha and then the sum of squares of its first derivative.
α[r_] := Sum[Subscript[α, i, j]*r^i, {i, 0, 5}]
η[r_] :=
Sum[D[α[r], r]^2, {j, 1, N}] /. Sum[x_, y_] :> (Sum[#, y] & /@ Expand @ x)
Without /. Sum[x_, y_] :> (Sum[#, y] & /@ Expand@x)
, the output stays all collected into one sum over j
even when Expand
is applied, shown below:
With that code, the sum splits up into a series of sums, each only one term long:
However, the variable r
is still inside the sum in each case, meaning that when I apply Coefficient[,r,2]
(etc) to the output, it just spits out all of the output (i.e. doesn't do anything) rather than just identifying the terms of the correct power of r
. What I really need is some code that pulls the 'r' factor out of each summation term, so that Coefficient
will pick out the required terms.