Summation of Kronecker deltas should give the dimension

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite
1












I have a really simple problem but I don't know how to solve it. Basically, I am doing vecor manipulation and I am summing a lot of Kronecker delta here and there. How can I teach Mathematica that for any sum of the form $
sum_i=1^ddelta_munudelta_munu=d $
.
I tried



$Assumptions = Sum[KroneckerDelta[μ, ν] KroneckerDelta[μ, ν], u, 1,
d, μ, 1, d] == d


Which does not work. To be precise, consider a Ansatz of the following form, depending on a vector $vecs$ and some coefficients.



customAnsatzC[s_, μ_, ν_, λ_, σ_] := C1 s.s KroneckerDelta[μ, ν] KroneckerDelta[λ, σ] + 
C2 s.s (KroneckerDelta[μ, σ] KroneckerDelta[λ, ν] +
KroneckerDelta[μ, λ]KroneckerDelta[ν, σ]);


When I take the Trace of something like this, it gives back



Sum[KroneckerDelta[μ, ν] KroneckerDelta[λ, σ] customAnsatzC[s1, s2, s3, 
s4, μ, ν, λ, σ], λ, 1, 4, σ, 1, 4, μ, 1, 4, ν, 1, 4] // FullSimplify


This gives back $8 (2 C1 + C2) (s1^2 + s2^2 + s3^2 + s4^2)$ but I would like it to give back $(d^2C1 + 2dC2)(s1^2+s2^2+s3^2+s4^2)$ instead. Is there a way to do this ?










share|improve this question























  • What are the dummy indices, exactly?
    – Î‘λέξανδρος Ζεγγ
    6 hours ago














up vote
1
down vote

favorite
1












I have a really simple problem but I don't know how to solve it. Basically, I am doing vecor manipulation and I am summing a lot of Kronecker delta here and there. How can I teach Mathematica that for any sum of the form $
sum_i=1^ddelta_munudelta_munu=d $
.
I tried



$Assumptions = Sum[KroneckerDelta[μ, ν] KroneckerDelta[μ, ν], u, 1,
d, μ, 1, d] == d


Which does not work. To be precise, consider a Ansatz of the following form, depending on a vector $vecs$ and some coefficients.



customAnsatzC[s_, μ_, ν_, λ_, σ_] := C1 s.s KroneckerDelta[μ, ν] KroneckerDelta[λ, σ] + 
C2 s.s (KroneckerDelta[μ, σ] KroneckerDelta[λ, ν] +
KroneckerDelta[μ, λ]KroneckerDelta[ν, σ]);


When I take the Trace of something like this, it gives back



Sum[KroneckerDelta[μ, ν] KroneckerDelta[λ, σ] customAnsatzC[s1, s2, s3, 
s4, μ, ν, λ, σ], λ, 1, 4, σ, 1, 4, μ, 1, 4, ν, 1, 4] // FullSimplify


This gives back $8 (2 C1 + C2) (s1^2 + s2^2 + s3^2 + s4^2)$ but I would like it to give back $(d^2C1 + 2dC2)(s1^2+s2^2+s3^2+s4^2)$ instead. Is there a way to do this ?










share|improve this question























  • What are the dummy indices, exactly?
    – Î‘λέξανδρος Ζεγγ
    6 hours ago












up vote
1
down vote

favorite
1









up vote
1
down vote

favorite
1






1





I have a really simple problem but I don't know how to solve it. Basically, I am doing vecor manipulation and I am summing a lot of Kronecker delta here and there. How can I teach Mathematica that for any sum of the form $
sum_i=1^ddelta_munudelta_munu=d $
.
I tried



$Assumptions = Sum[KroneckerDelta[μ, ν] KroneckerDelta[μ, ν], u, 1,
d, μ, 1, d] == d


Which does not work. To be precise, consider a Ansatz of the following form, depending on a vector $vecs$ and some coefficients.



customAnsatzC[s_, μ_, ν_, λ_, σ_] := C1 s.s KroneckerDelta[μ, ν] KroneckerDelta[λ, σ] + 
C2 s.s (KroneckerDelta[μ, σ] KroneckerDelta[λ, ν] +
KroneckerDelta[μ, λ]KroneckerDelta[ν, σ]);


When I take the Trace of something like this, it gives back



Sum[KroneckerDelta[μ, ν] KroneckerDelta[λ, σ] customAnsatzC[s1, s2, s3, 
s4, μ, ν, λ, σ], λ, 1, 4, σ, 1, 4, μ, 1, 4, ν, 1, 4] // FullSimplify


This gives back $8 (2 C1 + C2) (s1^2 + s2^2 + s3^2 + s4^2)$ but I would like it to give back $(d^2C1 + 2dC2)(s1^2+s2^2+s3^2+s4^2)$ instead. Is there a way to do this ?










share|improve this question















I have a really simple problem but I don't know how to solve it. Basically, I am doing vecor manipulation and I am summing a lot of Kronecker delta here and there. How can I teach Mathematica that for any sum of the form $
sum_i=1^ddelta_munudelta_munu=d $
.
I tried



$Assumptions = Sum[KroneckerDelta[μ, ν] KroneckerDelta[μ, ν], u, 1,
d, μ, 1, d] == d


Which does not work. To be precise, consider a Ansatz of the following form, depending on a vector $vecs$ and some coefficients.



customAnsatzC[s_, μ_, ν_, λ_, σ_] := C1 s.s KroneckerDelta[μ, ν] KroneckerDelta[λ, σ] + 
C2 s.s (KroneckerDelta[μ, σ] KroneckerDelta[λ, ν] +
KroneckerDelta[μ, λ]KroneckerDelta[ν, σ]);


When I take the Trace of something like this, it gives back



Sum[KroneckerDelta[μ, ν] KroneckerDelta[λ, σ] customAnsatzC[s1, s2, s3, 
s4, μ, ν, λ, σ], λ, 1, 4, σ, 1, 4, μ, 1, 4, ν, 1, 4] // FullSimplify


This gives back $8 (2 C1 + C2) (s1^2 + s2^2 + s3^2 + s4^2)$ but I would like it to give back $(d^2C1 + 2dC2)(s1^2+s2^2+s3^2+s4^2)$ instead. Is there a way to do this ?







linear-algebra vector tensors vector-calculus






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 4 hours ago









Carl Woll

63.6k282165




63.6k282165










asked 6 hours ago









Ezareth

708




708











  • What are the dummy indices, exactly?
    – Î‘λέξανδρος Ζεγγ
    6 hours ago
















  • What are the dummy indices, exactly?
    – Î‘λέξανδρος Ζεγγ
    6 hours ago















What are the dummy indices, exactly?
– Î‘λέξανδρος Ζεγγ
6 hours ago




What are the dummy indices, exactly?
– Î‘λέξανδρος Ζεγγ
6 hours ago










1 Answer
1






active

oldest

votes

















up vote
6
down vote













You could just do:



Sum[KroneckerDelta[μ, ν] KroneckerDelta[μ, ν], ν, d, μ, d, Assumptions->d>1]



d




Although it might make sense to use symbolic tensors instead, e.g., something like:



Tr[IdentityMatrix[d] . IdentityMatrix[d]]


although in this case you would need some extra code for simplification (as you can find in my TensorSimplify package). Install the paclet with:



PacletInstall[
"TensorSimplify",
"Site" -> "http://raw.githubusercontent.com/carlwoll/TensorSimplify/master"
]


Once installed, you can load the package with:



<<TensorSimplify`


Then:



Tr[IdentityMatrix[d] . IdentityMatrix[d]] //TensorSimplify



d




Update



(For the updated question)



Using symbolic tensors, your customAnsatz function can be written:



IXI = TensorProduct[IdentityMatrix[d], IdentityMatrix[d]];

ansatz[s_] := s.s (
C1 IXI +
C2 (TensorTranspose[IXI, 1, 4, 3, 2] + TensorTranspose[IXI, 1,3,2,4])
)


Then, your sum can be written:



$Assumptions = (C1|C2) ∈ Complexes && s ∈ Vectors[d];

TensorContract[
TensorProduct[IXI, ansatz[s]],
1, 5, 2, 6, 3, 7, 4, 8
] //TensorSimplify



2 C2 d s.s + C1 d^2 s.s







share|improve this answer






















  • Thank you for your answer. I updated the question more specifically to what I am actually needing. Would be wonderful if you could have a second look.
    – Ezareth
    4 hours ago










Your Answer





StackExchange.ifUsing("editor", function ()
return StackExchange.using("mathjaxEditing", function ()
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
);
);
, "mathjax-editing");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "387"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f185053%2fsummation-of-kronecker-deltas-should-give-the-dimension%23new-answer', 'question_page');

);

Post as a guest






























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
6
down vote













You could just do:



Sum[KroneckerDelta[μ, ν] KroneckerDelta[μ, ν], ν, d, μ, d, Assumptions->d>1]



d




Although it might make sense to use symbolic tensors instead, e.g., something like:



Tr[IdentityMatrix[d] . IdentityMatrix[d]]


although in this case you would need some extra code for simplification (as you can find in my TensorSimplify package). Install the paclet with:



PacletInstall[
"TensorSimplify",
"Site" -> "http://raw.githubusercontent.com/carlwoll/TensorSimplify/master"
]


Once installed, you can load the package with:



<<TensorSimplify`


Then:



Tr[IdentityMatrix[d] . IdentityMatrix[d]] //TensorSimplify



d




Update



(For the updated question)



Using symbolic tensors, your customAnsatz function can be written:



IXI = TensorProduct[IdentityMatrix[d], IdentityMatrix[d]];

ansatz[s_] := s.s (
C1 IXI +
C2 (TensorTranspose[IXI, 1, 4, 3, 2] + TensorTranspose[IXI, 1,3,2,4])
)


Then, your sum can be written:



$Assumptions = (C1|C2) ∈ Complexes && s ∈ Vectors[d];

TensorContract[
TensorProduct[IXI, ansatz[s]],
1, 5, 2, 6, 3, 7, 4, 8
] //TensorSimplify



2 C2 d s.s + C1 d^2 s.s







share|improve this answer






















  • Thank you for your answer. I updated the question more specifically to what I am actually needing. Would be wonderful if you could have a second look.
    – Ezareth
    4 hours ago














up vote
6
down vote













You could just do:



Sum[KroneckerDelta[μ, ν] KroneckerDelta[μ, ν], ν, d, μ, d, Assumptions->d>1]



d




Although it might make sense to use symbolic tensors instead, e.g., something like:



Tr[IdentityMatrix[d] . IdentityMatrix[d]]


although in this case you would need some extra code for simplification (as you can find in my TensorSimplify package). Install the paclet with:



PacletInstall[
"TensorSimplify",
"Site" -> "http://raw.githubusercontent.com/carlwoll/TensorSimplify/master"
]


Once installed, you can load the package with:



<<TensorSimplify`


Then:



Tr[IdentityMatrix[d] . IdentityMatrix[d]] //TensorSimplify



d




Update



(For the updated question)



Using symbolic tensors, your customAnsatz function can be written:



IXI = TensorProduct[IdentityMatrix[d], IdentityMatrix[d]];

ansatz[s_] := s.s (
C1 IXI +
C2 (TensorTranspose[IXI, 1, 4, 3, 2] + TensorTranspose[IXI, 1,3,2,4])
)


Then, your sum can be written:



$Assumptions = (C1|C2) ∈ Complexes && s ∈ Vectors[d];

TensorContract[
TensorProduct[IXI, ansatz[s]],
1, 5, 2, 6, 3, 7, 4, 8
] //TensorSimplify



2 C2 d s.s + C1 d^2 s.s







share|improve this answer






















  • Thank you for your answer. I updated the question more specifically to what I am actually needing. Would be wonderful if you could have a second look.
    – Ezareth
    4 hours ago












up vote
6
down vote










up vote
6
down vote









You could just do:



Sum[KroneckerDelta[μ, ν] KroneckerDelta[μ, ν], ν, d, μ, d, Assumptions->d>1]



d




Although it might make sense to use symbolic tensors instead, e.g., something like:



Tr[IdentityMatrix[d] . IdentityMatrix[d]]


although in this case you would need some extra code for simplification (as you can find in my TensorSimplify package). Install the paclet with:



PacletInstall[
"TensorSimplify",
"Site" -> "http://raw.githubusercontent.com/carlwoll/TensorSimplify/master"
]


Once installed, you can load the package with:



<<TensorSimplify`


Then:



Tr[IdentityMatrix[d] . IdentityMatrix[d]] //TensorSimplify



d




Update



(For the updated question)



Using symbolic tensors, your customAnsatz function can be written:



IXI = TensorProduct[IdentityMatrix[d], IdentityMatrix[d]];

ansatz[s_] := s.s (
C1 IXI +
C2 (TensorTranspose[IXI, 1, 4, 3, 2] + TensorTranspose[IXI, 1,3,2,4])
)


Then, your sum can be written:



$Assumptions = (C1|C2) ∈ Complexes && s ∈ Vectors[d];

TensorContract[
TensorProduct[IXI, ansatz[s]],
1, 5, 2, 6, 3, 7, 4, 8
] //TensorSimplify



2 C2 d s.s + C1 d^2 s.s







share|improve this answer














You could just do:



Sum[KroneckerDelta[μ, ν] KroneckerDelta[μ, ν], ν, d, μ, d, Assumptions->d>1]



d




Although it might make sense to use symbolic tensors instead, e.g., something like:



Tr[IdentityMatrix[d] . IdentityMatrix[d]]


although in this case you would need some extra code for simplification (as you can find in my TensorSimplify package). Install the paclet with:



PacletInstall[
"TensorSimplify",
"Site" -> "http://raw.githubusercontent.com/carlwoll/TensorSimplify/master"
]


Once installed, you can load the package with:



<<TensorSimplify`


Then:



Tr[IdentityMatrix[d] . IdentityMatrix[d]] //TensorSimplify



d




Update



(For the updated question)



Using symbolic tensors, your customAnsatz function can be written:



IXI = TensorProduct[IdentityMatrix[d], IdentityMatrix[d]];

ansatz[s_] := s.s (
C1 IXI +
C2 (TensorTranspose[IXI, 1, 4, 3, 2] + TensorTranspose[IXI, 1,3,2,4])
)


Then, your sum can be written:



$Assumptions = (C1|C2) ∈ Complexes && s ∈ Vectors[d];

TensorContract[
TensorProduct[IXI, ansatz[s]],
1, 5, 2, 6, 3, 7, 4, 8
] //TensorSimplify



2 C2 d s.s + C1 d^2 s.s








share|improve this answer














share|improve this answer



share|improve this answer








edited 4 hours ago

























answered 6 hours ago









Carl Woll

63.6k282165




63.6k282165











  • Thank you for your answer. I updated the question more specifically to what I am actually needing. Would be wonderful if you could have a second look.
    – Ezareth
    4 hours ago
















  • Thank you for your answer. I updated the question more specifically to what I am actually needing. Would be wonderful if you could have a second look.
    – Ezareth
    4 hours ago















Thank you for your answer. I updated the question more specifically to what I am actually needing. Would be wonderful if you could have a second look.
– Ezareth
4 hours ago




Thank you for your answer. I updated the question more specifically to what I am actually needing. Would be wonderful if you could have a second look.
– Ezareth
4 hours ago

















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f185053%2fsummation-of-kronecker-deltas-should-give-the-dimension%23new-answer', 'question_page');

);

Post as a guest













































































Comments

Popular posts from this blog

What does second last employer means? [closed]

List of Gilmore Girls characters

Confectionery