I would like to know, how to change parts of a formula in HoldForm. I have the formula
$$ \underbrace{\prod_{i=1}^N}_{\text{level 4}} \sum_{\sigma_i\in \{-1,1\}}\underbrace{\sum_{\lambda\in \{-1,1\}}}_{\text{level 2}}\underbrace{\frac{\partial}{\partial x_i}}_{\text{level 3}}\underbrace{\exp\left( -\lambda \sigma_i x_i^2\right)(x_i^2-\lambda)}_{\text{level 1}} $$ and I put it in HoldForm such that it is not evaluated.
1. I would like to work with the level 1 content first, change it by e.g. an expansion while the other parts remain fixed. After that I would like to exchange the level 2 and level 3 operators (if you regard summation as an operation as well) and evaluate only the level 2 - level 1 part with keeping the rest fixed. The result should read $$ \underbrace{\prod_{i=1}^N}_{\text{level 4}} \sum_{\sigma_i\in \{-1,1\}}\underbrace{\frac{\partial}{\partial x_i}}_{\text{level 3}}\left(\underbrace{\exp\left(\sigma_i x_i^2\right)(x_i^2+1)}_{\text{level 1}}+\underbrace{\exp\left(-\sigma_i x_i^2\right)(x_i^2-1)}_{\text{level 1}}\right)$$
2. I would like to keep the order and evaluate the level 2 sum while the level 3 operator is not applied but remains in the HoldForm. The result for the second task should read $$ \underbrace{\prod_{i=1}^N}_{\text{level 4}} \sum_{\sigma_i\in \{-1,1\}}\left(\underbrace{\frac{\partial}{\partial x_i}}_{\text{level 3}}\underbrace{\exp\left(\sigma_i x_i^2\right)(x_i^2+1)}_{\text{level 1}}+\underbrace{\frac{\partial}{\partial x_i}}_{\text{level 3}}\underbrace{\exp\left(-\sigma_i x_i^2\right)(x_i^2-1)}_{\text{level 1}}\right)$$ To summarize, there are two questions: How do I evaluate arbitrary things(different level combinations or maybe $N$ or the set of possible $\lambda$'s) and how do I change the operator order within the HoldForm of an overall summation or integration.
Edit
As recomended I add some code using a slightly simpler example. The code
J = Inactivate[Table[Subscript[j, i, j], {i, 0, N}, {j, 0, N}]]; Σ = Inactivate[Table[Subscript[σ, i], {i, 0, N}]]; H = Inactivate[-Sum[Subscript[j,i,j] Subscript[σ,i] Subscript[σ,j], {i, 0, N}, {j, 0, N}] -h*Sum[Subscript[σ, i], {i, 0, N}], Sum]; Z = Inactivate[Product[Sum[Exp[-β*H], {Subscript[σ, i],-1,1}], {k,0, N}], Sum | Product] D[Z, β]
yields $$ \frac{\partial \left(\underset{k=0}{\overset{N}{\prod }}\underset{\sigma _i=-1}{\overset{1}{\sum }}\exp \left(-\beta \left(-h \underset{i=0}{\overset{N}{\sum }}\sigma _i-\underset{i=0}{\overset{N}{\sum }}\underset{j=0}{\overset{N}{\sum }}\sigma _i \sigma _j j_{i,j}\right)\right)\right)}{\partial \beta } $$ using Inactivate. How do I pass the $\beta$ derivative past the product and the $\sigma_i$ sum and evaluate it to $$ \left(\underset{k=0}{\overset{N}{\prod }}\underset{\sigma _i=-1}{\overset{1}{\sum }}\left(h \underset{i=0}{\overset{N}{\sum }}\sigma _i+\underset{i=0}{\overset{N}{\sum }}\underset{j=0}{\overset{N}{\sum }}\sigma _i \sigma _j j_{i,j}\right)\exp \left(-\beta \left(-h \underset{i=0}{\overset{N}{\sum }}\sigma _i-\underset{i=0}{\overset{N}{\sum }}\underset{j=0}{\overset{N}{\sum }}\sigma _i \sigma _j j_{i,j}\right)\right)\right) $$

Inactivewas developed for just this kind of thing. $\endgroup$Sumwithsum. This lets you manipulate the expression without it being evaluated. Obviously, when you have something you want to evaluate you can simply useexpr /. sum -> Sum$\endgroup$