Skip to main content
deleted 61 characters in body
Source Link
Mr.Wizard
  • 275.2k
  • 34
  • 606
  • 1.5k

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}]]; \[CapitalSigma]Σ = Inactivate[Table[Subscript[\[Sigma]Inactivate[Table[Subscript[σ, i], {i, 0, N}]]; H =  Inactivate[-Sum[Subscript[j, i, j] Subscript[\[Sigma]Subscript[σ, i] Subscript[\[Sigma]Subscript[σ,j], {i, 0, N}, {j, 0, N}] -h*Sum[Subscript[\[Sigma]h*Sum[Subscript[σ, i], {i, 0, N}], Sum]; Z =  Inactivate[Product[Sum[Exp[-\[Beta]*H]β*H], {Subscript[\[Sigma]Subscript[σ, i],-1,1}], {k,0, N}], Sum | Product] D[Z, \[Beta]]β] 


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) $$


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}]]; \[CapitalSigma] = Inactivate[Table[Subscript[\[Sigma], i], {i, 0, N}]]; H = Inactivate[-Sum[Subscript[j, i, j] Subscript[\[Sigma], i] Subscript[\[Sigma],j], {i, 0, N}, {j, 0, N}] -h*Sum[Subscript[\[Sigma], i], {i, 0, N}], Sum]; Z = Inactivate[Product[Sum[Exp[-\[Beta]*H], {Subscript[\[Sigma], i],-1,1}], {k,0, N}], Sum | Product] D[Z, \[Beta]] 


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) $$


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) $$

Tweeted twitter.com/StackMma/status/1002007347609432064
added 2 characters in body
Source Link
kglr
  • 403.4k
  • 18
  • 501
  • 959

I would like to know, how to change parts of a formula in HoldForm`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**`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 eveluateevaluate the level 2 sum while the level 3 operator is not applied but remains in the HoldForm`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}]]; \[CapitalSigma] = Inactivate[Table[Subscript[\[Sigma], i], {i, 0, N}]]; H = Inactivate[-Sum[Subscript[j, i, j] Subscript[\[Sigma], i] Subscript[\[Sigma],j], {i, 0, N}, {j, 0, N}] -h*Sum[Subscript[\[Sigma], i], {i, 0, N}], Sum]; Z = Inactivate[Product[Sum[Exp[-\[Beta]*H], {Subscript[\[Sigma], i],-1,1}], {k,0, N}], Sum | Product] D[Z, \[Beta]] 


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) $$


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 eveluate 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}]]; \[CapitalSigma] = Inactivate[Table[Subscript[\[Sigma], i], {i, 0, N}]]; H = Inactivate[-Sum[Subscript[j, i, j] Subscript[\[Sigma], i] Subscript[\[Sigma],j], {i, 0, N}, {j, 0, N}] -h*Sum[Subscript[\[Sigma], i], {i, 0, N}], Sum]; Z = Inactivate[Product[Sum[Exp[-\[Beta]*H], {Subscript[\[Sigma], i],-1,1}], {k,0, N}], Sum | Product] D[Z, \[Beta]] 


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) $$


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}]]; \[CapitalSigma] = Inactivate[Table[Subscript[\[Sigma], i], {i, 0, N}]]; H = Inactivate[-Sum[Subscript[j, i, j] Subscript[\[Sigma], i] Subscript[\[Sigma],j], {i, 0, N}, {j, 0, N}] -h*Sum[Subscript[\[Sigma], i], {i, 0, N}], Sum]; Z = Inactivate[Product[Sum[Exp[-\[Beta]*H], {Subscript[\[Sigma], i],-1,1}], {k,0, N}], Sum | Product] D[Z, \[Beta]] 


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) $$

added 554 characters in body
Source Link

HoldForm for any/Inactivate and exchange operators


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 eveluate 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}]]; \[CapitalSigma] = Inactivate[Table[Subscript[\[Sigma], i], {i, 0, N}]]; H = Inactivate[-Sum[Subscript[j, i, j] Subscript[\[Sigma], i] Subscript[\[Sigma],j], {i, 0, N}, {j, 0, N}] -h*Sum[Subscript[\[Sigma], i], {i, 0, N}], Sum]; Z = Inactivate[Product[Sum[Exp[-\[Beta]*H], {Subscript[\[Sigma], i],-1,1}], {k,0, N}], Sum | Product] D[Z, \[Beta]] 


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) $$

HoldForm for any operators


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 eveluate 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}]]; \[CapitalSigma] = Inactivate[Table[Subscript[\[Sigma], i], {i, 0, N}]]; H = Inactivate[-Sum[Subscript[j, i, j] Subscript[\[Sigma], i] Subscript[\[Sigma],j], {i, 0, N}, {j, 0, N}] -h*Sum[Subscript[\[Sigma], i], {i, 0, N}], Sum]; Z = Inactivate[Product[Sum[Exp[-\[Beta]*H], {Subscript[\[Sigma], i],-1,1}], {k,0, N}], Sum | Product] D[Z, \[Beta]] 


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

 $$ \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) $$

HoldForm/Inactivate and exchange operators


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 eveluate 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}]]; \[CapitalSigma] = Inactivate[Table[Subscript[\[Sigma], i], {i, 0, N}]]; H = Inactivate[-Sum[Subscript[j, i, j] Subscript[\[Sigma], i] Subscript[\[Sigma],j], {i, 0, N}, {j, 0, N}] -h*Sum[Subscript[\[Sigma], i], {i, 0, N}], Sum]; Z = Inactivate[Product[Sum[Exp[-\[Beta]*H], {Subscript[\[Sigma], i],-1,1}], {k,0, N}], Sum | Product] D[Z, \[Beta]] 


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) $$

added 554 characters in body
Source Link
Loading
Source Link
Loading