0
|
3859 Views
|
10 Replies
|
0 Total Likes
View groups...
Share
GROUPS:

# Problem with distinguishing terms in Sum

Posted 9 years ago
 I am doing a sum and the code for this is given as LH:=Sum[((-1)^(j + jp))*h1[\[Lambda]l, 1/2]* KroneckerDelta[\[Lambda]2 - \[Lambda]w, \[Lambda]2 - \[Lambda]wp]* d3[j, \[Lambda]w, \[Lambda]l - (1/2)]* d3[jp, \[Lambda]wp, \[Lambda]l - (1/2)]*H[\[Lambda]2, \[Lambda]w]* Conjugate[H[\[Lambda]2, \[Lambda]wp]], {j, 0, 1}, {jp, 0, 1}, {\[Lambda]w, {1, 0, -1}}, {\[Lambda]wp, {1, 0, -1}}, {\[Lambda]l, {-1/2, 1/2}}, {\[Lambda]2, {-1/2, 1/2}}]  In the output of this, I am getting terms with H[1/2 ,0]^2, one is coming from j = jp =0 and [Lambda]w=[Lambda]wp =0 and another term with H[1/2 ,0], is from j = jp =1 and [Lambda]w=[Lambda]wp =0. I want to distinguish these two terms. How can i distinguish these terms ? Please help me .
10 Replies
Sort By:
Posted 9 years ago
 The Style declaration can interfere with further computation if you need to sum together terms with different styles. It seems that you had a styled 0. You can remove all Style's with a replacement mySum /. Style[a_, _] :> a 
Posted 9 years ago
 You can organize your conditions already inside Which Which[j == jp == 0 && \[Lambda]w == \[Lambda]wp == 0 && \[Lambda]1 + \[Lambda]2 == \[Lambda]w, Red, j == jp == 1 && \[Lambda]w == \[Lambda]wp == 0, Blue, True, Black] or whatever you want. You may consider other conditional constructs such as If and Switch, depending on your needs. A condition can also be inserted into the replacement rule: {Style[term_ /; condition, Red] :> (term /. H[1/2, 0] -> value1), Style[term_, Blue] :> (term /. H[1/2, 0] -> value2)} provided that the condition only depends on the term.
Posted 9 years ago
 Thank you for a very nice explanation of my doubts.
Posted 9 years ago
 You can make a replacement: {Style[term_, Red] :> (term /. H[1/2, 0] -> value1), Style[term_, Blue] :> (term /. H[1/2, 0] -> value2)} 
Posted 9 years ago
 Thank you very much. This is very useful. I have another small doublt. Can we put a constraint on lambdaW and lambdaWp as lambda1+lambda2 = lambdaW where lambda1 takes values 1/2 and -1/2 inside the Sum ?
Posted 9 years ago
 How about coloring them? Sum[Style[((-1)^(j + jp)) h1[\[Lambda]l, 1/2] KroneckerDelta[\[Lambda]2 - \[Lambda]w, \[Lambda]2 - \ \[Lambda]wp]*d3[j, \[Lambda]w, \[Lambda]l - (1/2)]* d3[jp, \[Lambda]wp, \[Lambda]l - (1/ 2)] H[\[Lambda]2, \[Lambda]w] Conjugate[ H[\[Lambda]2, \[Lambda]wp]], Which[j == jp == 0 && \[Lambda]w == \[Lambda]wp == 0, Red, j == jp == 1 && \[Lambda]w == \[Lambda]wp == 0, Blue, True, Black]], {j, 0, 1}, {jp, 0, 1}, {\[Lambda]w, {1, 0, -1}}, {\[Lambda]wp, {1, 0, -1}}, {\[Lambda]l, {-1/2, 1/2}}, {\[Lambda]2, {-1/2, 1/2}}] 
Posted 9 years ago
 Thank you very much for this. This is useful only if we are looking for the terms. Now if we want to assign some values for H[1/2,0] for combination j= jp= lambdaW= lambdaWp = 0 and different value for combination j= jp=1, lambdaW= lambdaWp = 0 then in that case it won't take those different values as we are assinging values to H[1/2,0] for both cases. So I want the notation such that for both cases i can assign different values to H[1/2,0].
Posted 9 years ago
 In the output I am getting one term 96*0 which I copied here and got following command: 96 \!(* StyleBox["0", StripOnInput->False, LineColor->GrayLevel[0], FrontFaceColor->GrayLevel[0], BackFaceColor->GrayLevel[0], GraphicsColor->GrayLevel[0], FontColor->GrayLevel[0]]) I am not able to understand this line. Why is it appearing in output ?
Posted 9 years ago
 you could replace the sum by table to see the individual terms for each combination of j, jp, lambdaW, lambdaWp. Try lh = Flatten[ Table[{{j, jp, \[Lambda]w, \[Lambda]wp}, (-1)^(j + jp) h1[ \[Lambda]1, 1/2] KroneckerDelta[\[Lambda]2 - \[Lambda]w, \[Lambda]2 - \ \[Lambda]wp] d3[j, \[Lambda]w, \[Lambda]1 - (1/2)] d3[ jp, \[Lambda]wp, \[Lambda]1 - (1/ 2)] h[\[Lambda]2, \[Lambda]w] Conjugate[ h[\[Lambda]2, \[Lambda]wp]]}, {j, 0, 1}, {jp, 0, 1}, {\[Lambda]w, {1, 0, -1}}, {\[Lambda]wp, {1, 0, -1}}, {\[Lambda]1, {-1/2, 1/2}}, {\[Lambda]2, {-1/2, 1/2}}], 5] To look at the result you could use ableForm[lh, TableHeadings -> {None, {index, f}}, TableDepth -> 2] You can always latter sum up the term from the list. Does this help your analysis?
Posted 9 years ago
 Thank you for your reply. This is useful for me but is there a way that with the combination of j= jp= lambdaW= lambdaWp = 0, then h[1/2,0] is defined as h[1/2,t] ? This is easily distinguishable from the other combination because it will be helpful in my further analysis if we can do in this way .