How can I automate this tensor computation?Why doesn't Mathematica make an obvious simplification?Simplify matrix algebraReduce the output from tuples by including symmetry?How to put the tensor product of two operators onto two variables?Symbolic Tensor AlgebraExpression containing $ttI$ is real — how can I show this is so in my notebook?Working with tensor algebraPython's einsum equivalent in Mathematica?Del as a Differential Operator: (Matrix times Del) cross vectorExplicitly construct tensor quantities with given symmetries
Why isn't a binary file shown as 0s and 1s?
When designing an adventure, how can I ensure a continuous player experience in a setting that's likely to favor TPKs?
I have found a mistake on someone's code published online: what is the protocol?
Should I have one hand on the throttle during engine ignition?
How many opportunity attacks can you make per turn before becoming exhausted?
How to tell readers that I know my story is factually incorrect?
Is this Android phone Android 9.0 or Android 6.0?
Why did my "seldom" get corrected?
How to extract interesting piece of output in bash
How long were the Apollo astronauts allowed to breathe 100% oxygen at 1 atmosphere continuously?
Left crank keeps coming loose
Diagram of Methods to Solve Differential Equations
Enumerate list with each item in a new row
Who or what determines if a curse is valid or not?
May I use a railway velocipede on actively-used British railways?
How to not confuse readers with simultaneous events?
Proof that every field is perfect???
Why are there few or no black super GMs?
Detecting existence of a class member
How did Jayne know when to shoot?
"This used to be my phone number"
Can error correction and detection be done without adding extra bits?
Why didn't Doctor Strange restore Tony Stark after he used the Stones?
Could a US citizen born through "birth tourism" become President?
How can I automate this tensor computation?
Why doesn't Mathematica make an obvious simplification?Simplify matrix algebraReduce the output from tuples by including symmetry?How to put the tensor product of two operators onto two variables?Symbolic Tensor AlgebraExpression containing $ttI$ is real — how can I show this is so in my notebook?Working with tensor algebraPython's einsum equivalent in Mathematica?Del as a Differential Operator: (Matrix times Del) cross vectorExplicitly construct tensor quantities with given symmetries
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
$begingroup$
I am doing this work by hand, but it takes a lot of time and I make several calculation errors, so I was thinking to make Mathematica to calculate this for me, but I am stuck at the very beginning.
I am working with tensors like this:
$XXV_ijk = dfrac16(X_iX_jV_k+X_iX_kV_j+X_jX_iV_k+X_kX_jV_i+X_jX_kV_i+X_kX_iV_j)$
$-dfrac15(delta_ij, (Xcdot X) V_k+delta_ik (Xcdot V) X_j+delta_jk (Xcdot V) X_i)$
where $X_i$ and $V_i$ are the components of the 3-vectors $vecX$ and $vecV$. I have to multiply these tensors, for example
$XXV times XXV = dfrac225V^2+dfrac825 (Xcdot V)^2$
I think I can obtain the first part with Tuples and Total(?) but I don't know how to obtain the part with the Kroeneker deltas; if I can write these tensors correctly I think I can multiply these tensors with . and Transpose.
As @yarchik has pointd out, I have to add that my tensors have unit length
simplifying-expressions tensors code-request
$endgroup$
add a comment |
$begingroup$
I am doing this work by hand, but it takes a lot of time and I make several calculation errors, so I was thinking to make Mathematica to calculate this for me, but I am stuck at the very beginning.
I am working with tensors like this:
$XXV_ijk = dfrac16(X_iX_jV_k+X_iX_kV_j+X_jX_iV_k+X_kX_jV_i+X_jX_kV_i+X_kX_iV_j)$
$-dfrac15(delta_ij, (Xcdot X) V_k+delta_ik (Xcdot V) X_j+delta_jk (Xcdot V) X_i)$
where $X_i$ and $V_i$ are the components of the 3-vectors $vecX$ and $vecV$. I have to multiply these tensors, for example
$XXV times XXV = dfrac225V^2+dfrac825 (Xcdot V)^2$
I think I can obtain the first part with Tuples and Total(?) but I don't know how to obtain the part with the Kroeneker deltas; if I can write these tensors correctly I think I can multiply these tensors with . and Transpose.
As @yarchik has pointd out, I have to add that my tensors have unit length
simplifying-expressions tensors code-request
$endgroup$
$begingroup$
Is there a typo in your last term on the first line, $X_kX_iV_k$? There should be a $j$-index somewhere.
$endgroup$
– Roman
8 hours ago
$begingroup$
@Roman yes it is a typo
$endgroup$
– mattiav27
7 hours ago
$begingroup$
I think your second term still needs a power correction. The answer should be proportional to $V^2$.
$endgroup$
– yarchik
7 hours ago
$begingroup$
@yarchik you are right, but this is a typo not a calculation error...
$endgroup$
– mattiav27
7 hours ago
add a comment |
$begingroup$
I am doing this work by hand, but it takes a lot of time and I make several calculation errors, so I was thinking to make Mathematica to calculate this for me, but I am stuck at the very beginning.
I am working with tensors like this:
$XXV_ijk = dfrac16(X_iX_jV_k+X_iX_kV_j+X_jX_iV_k+X_kX_jV_i+X_jX_kV_i+X_kX_iV_j)$
$-dfrac15(delta_ij, (Xcdot X) V_k+delta_ik (Xcdot V) X_j+delta_jk (Xcdot V) X_i)$
where $X_i$ and $V_i$ are the components of the 3-vectors $vecX$ and $vecV$. I have to multiply these tensors, for example
$XXV times XXV = dfrac225V^2+dfrac825 (Xcdot V)^2$
I think I can obtain the first part with Tuples and Total(?) but I don't know how to obtain the part with the Kroeneker deltas; if I can write these tensors correctly I think I can multiply these tensors with . and Transpose.
As @yarchik has pointd out, I have to add that my tensors have unit length
simplifying-expressions tensors code-request
$endgroup$
I am doing this work by hand, but it takes a lot of time and I make several calculation errors, so I was thinking to make Mathematica to calculate this for me, but I am stuck at the very beginning.
I am working with tensors like this:
$XXV_ijk = dfrac16(X_iX_jV_k+X_iX_kV_j+X_jX_iV_k+X_kX_jV_i+X_jX_kV_i+X_kX_iV_j)$
$-dfrac15(delta_ij, (Xcdot X) V_k+delta_ik (Xcdot V) X_j+delta_jk (Xcdot V) X_i)$
where $X_i$ and $V_i$ are the components of the 3-vectors $vecX$ and $vecV$. I have to multiply these tensors, for example
$XXV times XXV = dfrac225V^2+dfrac825 (Xcdot V)^2$
I think I can obtain the first part with Tuples and Total(?) but I don't know how to obtain the part with the Kroeneker deltas; if I can write these tensors correctly I think I can multiply these tensors with . and Transpose.
As @yarchik has pointd out, I have to add that my tensors have unit length
simplifying-expressions tensors code-request
simplifying-expressions tensors code-request
edited 5 hours ago
Carl Woll
87.6k3 gold badges115 silver badges224 bronze badges
87.6k3 gold badges115 silver badges224 bronze badges
asked 9 hours ago
mattiav27mattiav27
2,2772 gold badges15 silver badges33 bronze badges
2,2772 gold badges15 silver badges33 bronze badges
$begingroup$
Is there a typo in your last term on the first line, $X_kX_iV_k$? There should be a $j$-index somewhere.
$endgroup$
– Roman
8 hours ago
$begingroup$
@Roman yes it is a typo
$endgroup$
– mattiav27
7 hours ago
$begingroup$
I think your second term still needs a power correction. The answer should be proportional to $V^2$.
$endgroup$
– yarchik
7 hours ago
$begingroup$
@yarchik you are right, but this is a typo not a calculation error...
$endgroup$
– mattiav27
7 hours ago
add a comment |
$begingroup$
Is there a typo in your last term on the first line, $X_kX_iV_k$? There should be a $j$-index somewhere.
$endgroup$
– Roman
8 hours ago
$begingroup$
@Roman yes it is a typo
$endgroup$
– mattiav27
7 hours ago
$begingroup$
I think your second term still needs a power correction. The answer should be proportional to $V^2$.
$endgroup$
– yarchik
7 hours ago
$begingroup$
@yarchik you are right, but this is a typo not a calculation error...
$endgroup$
– mattiav27
7 hours ago
$begingroup$
Is there a typo in your last term on the first line, $X_kX_iV_k$? There should be a $j$-index somewhere.
$endgroup$
– Roman
8 hours ago
$begingroup$
Is there a typo in your last term on the first line, $X_kX_iV_k$? There should be a $j$-index somewhere.
$endgroup$
– Roman
8 hours ago
$begingroup$
@Roman yes it is a typo
$endgroup$
– mattiav27
7 hours ago
$begingroup$
@Roman yes it is a typo
$endgroup$
– mattiav27
7 hours ago
$begingroup$
I think your second term still needs a power correction. The answer should be proportional to $V^2$.
$endgroup$
– yarchik
7 hours ago
$begingroup$
I think your second term still needs a power correction. The answer should be proportional to $V^2$.
$endgroup$
– yarchik
7 hours ago
$begingroup$
@yarchik you are right, but this is a typo not a calculation error...
$endgroup$
– mattiav27
7 hours ago
$begingroup$
@yarchik you are right, but this is a typo not a calculation error...
$endgroup$
– mattiav27
7 hours ago
add a comment |
3 Answers
3
active
oldest
votes
$begingroup$
You can write it directly as you see it
xxv[i_,j_,k_]:= 1/6( x[i]x[j]v[k]+x[i]x[k]v[j]
+x[j]x[i]v[k]+x[k]x[j]v[i]
+x[j]x[k]v[i]+x[k]x[i]v[j] )
-1/5( KroneckerDelta[i,j]Sum[x[l]x[l],l,3]v[k]
+KroneckerDelta[i,k]Sum[x[l]v[l],l,3]x[j]
+KroneckerDelta[j,k]Sum[x[l]v[l],l,3]x[i] )
FullSimplify[ Sum[xxv[i,j,k] xxv[i,j,k],i,3,j,3,k,3],
Assumptions->Sum[x[i]^2,i,3]==1
&&Sum[x[i]v[i],i,3]==xv
&&Sum[v[i]v[i],i,3]==vv]
Out[1]= 2/25 (4 vv + xv^2)
where I assumed that your vector x is normalized
$endgroup$
add a comment |
$begingroup$
This is how I'd do it; maybe it's useful for you.
Define $vecX$ and $vecV$ as vectors:
X = Array[x, 3];
V = Array[v, 3];
useful $3times3times3$ tensors for assembling:
a = Outer[Times, X, X, V];
b = (X.X) Outer[Times, IdentityMatrix[3], V];
c = (X.V) Outer[Times, IdentityMatrix[3], X];
assemble $XXV$:
XXV = (a + Transpose[a, 3, 1, 2] + Transpose[a, 2, 3, 1])/3 -
(b + Transpose[c, 3, 1, 2] + Transpose[c, 2, 3, 1])/5;
check a formula:
Total[XXV*XXV, 3] == 2/25 (X.X) ((X.V)^2 + 4 (X.X) (V.V)) // FullSimplify
(* True *)
$endgroup$
$begingroup$
Nice that you verified my answer. I already started to doubt.
$endgroup$
– yarchik
7 hours ago
$begingroup$
@yarchik this is one of my calculation errors... I have corrected the formula in my post
$endgroup$
– mattiav27
7 hours ago
$begingroup$
@mattiav27 it's still wrong, the second term should be 8/25 and you need to specify that you're assuming that $vecX$ has unit length.
$endgroup$
– Roman
6 hours ago
add a comment |
$begingroup$
You can cast this as a symbolic tensor question, and make use of my TensorSimplify package. Install the paclet with:
PacletInstall[
"TensorSimplify",
"Site" -> "http://raw.githubusercontent.com/carlwoll/TensorSimplify/master"
]
Once installed, load the package with:
<<TensorSimplify`
Now, define your tensor using TensorProduct:
XXV = 1/3 (TensorProduct[X,X,V] + TensorProduct[X,V,X] + TensorProduct[V,X,X]) -
1/5 (X.X TensorProduct[Inactive[IdentityMatrix][3], V] +
X.V TensorTranspose[TensorProduct[Inactive[IdentityMatrix][3],X],1,3,2] +
X.V TensorProduct[X,Inactive[IdentityMatrix][3]]
);
Note the use of Inactive[IdentityMatrix][3] instead of IdentityMatrix[3]. Then:
TensorSimplify[
TensorContract[TensorProduct[XXV, XXV], 1, 4, 2, 5, 3, 6],
Assumptions -> (X|V) ∈ Vectors[3]
]
2/25 (V.X)^2 X.X + 8/25 V.V (X.X)^2
Using X.X == 1 reproduces your result.
$endgroup$
add a comment |
Your Answer
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',
autoActivateHeartbeat: false,
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f202373%2fhow-can-i-automate-this-tensor-computation%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
You can write it directly as you see it
xxv[i_,j_,k_]:= 1/6( x[i]x[j]v[k]+x[i]x[k]v[j]
+x[j]x[i]v[k]+x[k]x[j]v[i]
+x[j]x[k]v[i]+x[k]x[i]v[j] )
-1/5( KroneckerDelta[i,j]Sum[x[l]x[l],l,3]v[k]
+KroneckerDelta[i,k]Sum[x[l]v[l],l,3]x[j]
+KroneckerDelta[j,k]Sum[x[l]v[l],l,3]x[i] )
FullSimplify[ Sum[xxv[i,j,k] xxv[i,j,k],i,3,j,3,k,3],
Assumptions->Sum[x[i]^2,i,3]==1
&&Sum[x[i]v[i],i,3]==xv
&&Sum[v[i]v[i],i,3]==vv]
Out[1]= 2/25 (4 vv + xv^2)
where I assumed that your vector x is normalized
$endgroup$
add a comment |
$begingroup$
You can write it directly as you see it
xxv[i_,j_,k_]:= 1/6( x[i]x[j]v[k]+x[i]x[k]v[j]
+x[j]x[i]v[k]+x[k]x[j]v[i]
+x[j]x[k]v[i]+x[k]x[i]v[j] )
-1/5( KroneckerDelta[i,j]Sum[x[l]x[l],l,3]v[k]
+KroneckerDelta[i,k]Sum[x[l]v[l],l,3]x[j]
+KroneckerDelta[j,k]Sum[x[l]v[l],l,3]x[i] )
FullSimplify[ Sum[xxv[i,j,k] xxv[i,j,k],i,3,j,3,k,3],
Assumptions->Sum[x[i]^2,i,3]==1
&&Sum[x[i]v[i],i,3]==xv
&&Sum[v[i]v[i],i,3]==vv]
Out[1]= 2/25 (4 vv + xv^2)
where I assumed that your vector x is normalized
$endgroup$
add a comment |
$begingroup$
You can write it directly as you see it
xxv[i_,j_,k_]:= 1/6( x[i]x[j]v[k]+x[i]x[k]v[j]
+x[j]x[i]v[k]+x[k]x[j]v[i]
+x[j]x[k]v[i]+x[k]x[i]v[j] )
-1/5( KroneckerDelta[i,j]Sum[x[l]x[l],l,3]v[k]
+KroneckerDelta[i,k]Sum[x[l]v[l],l,3]x[j]
+KroneckerDelta[j,k]Sum[x[l]v[l],l,3]x[i] )
FullSimplify[ Sum[xxv[i,j,k] xxv[i,j,k],i,3,j,3,k,3],
Assumptions->Sum[x[i]^2,i,3]==1
&&Sum[x[i]v[i],i,3]==xv
&&Sum[v[i]v[i],i,3]==vv]
Out[1]= 2/25 (4 vv + xv^2)
where I assumed that your vector x is normalized
$endgroup$
You can write it directly as you see it
xxv[i_,j_,k_]:= 1/6( x[i]x[j]v[k]+x[i]x[k]v[j]
+x[j]x[i]v[k]+x[k]x[j]v[i]
+x[j]x[k]v[i]+x[k]x[i]v[j] )
-1/5( KroneckerDelta[i,j]Sum[x[l]x[l],l,3]v[k]
+KroneckerDelta[i,k]Sum[x[l]v[l],l,3]x[j]
+KroneckerDelta[j,k]Sum[x[l]v[l],l,3]x[i] )
FullSimplify[ Sum[xxv[i,j,k] xxv[i,j,k],i,3,j,3,k,3],
Assumptions->Sum[x[i]^2,i,3]==1
&&Sum[x[i]v[i],i,3]==xv
&&Sum[v[i]v[i],i,3]==vv]
Out[1]= 2/25 (4 vv + xv^2)
where I assumed that your vector x is normalized
edited 8 hours ago
answered 8 hours ago
yarchikyarchik
4,55610 silver badges34 bronze badges
4,55610 silver badges34 bronze badges
add a comment |
add a comment |
$begingroup$
This is how I'd do it; maybe it's useful for you.
Define $vecX$ and $vecV$ as vectors:
X = Array[x, 3];
V = Array[v, 3];
useful $3times3times3$ tensors for assembling:
a = Outer[Times, X, X, V];
b = (X.X) Outer[Times, IdentityMatrix[3], V];
c = (X.V) Outer[Times, IdentityMatrix[3], X];
assemble $XXV$:
XXV = (a + Transpose[a, 3, 1, 2] + Transpose[a, 2, 3, 1])/3 -
(b + Transpose[c, 3, 1, 2] + Transpose[c, 2, 3, 1])/5;
check a formula:
Total[XXV*XXV, 3] == 2/25 (X.X) ((X.V)^2 + 4 (X.X) (V.V)) // FullSimplify
(* True *)
$endgroup$
$begingroup$
Nice that you verified my answer. I already started to doubt.
$endgroup$
– yarchik
7 hours ago
$begingroup$
@yarchik this is one of my calculation errors... I have corrected the formula in my post
$endgroup$
– mattiav27
7 hours ago
$begingroup$
@mattiav27 it's still wrong, the second term should be 8/25 and you need to specify that you're assuming that $vecX$ has unit length.
$endgroup$
– Roman
6 hours ago
add a comment |
$begingroup$
This is how I'd do it; maybe it's useful for you.
Define $vecX$ and $vecV$ as vectors:
X = Array[x, 3];
V = Array[v, 3];
useful $3times3times3$ tensors for assembling:
a = Outer[Times, X, X, V];
b = (X.X) Outer[Times, IdentityMatrix[3], V];
c = (X.V) Outer[Times, IdentityMatrix[3], X];
assemble $XXV$:
XXV = (a + Transpose[a, 3, 1, 2] + Transpose[a, 2, 3, 1])/3 -
(b + Transpose[c, 3, 1, 2] + Transpose[c, 2, 3, 1])/5;
check a formula:
Total[XXV*XXV, 3] == 2/25 (X.X) ((X.V)^2 + 4 (X.X) (V.V)) // FullSimplify
(* True *)
$endgroup$
$begingroup$
Nice that you verified my answer. I already started to doubt.
$endgroup$
– yarchik
7 hours ago
$begingroup$
@yarchik this is one of my calculation errors... I have corrected the formula in my post
$endgroup$
– mattiav27
7 hours ago
$begingroup$
@mattiav27 it's still wrong, the second term should be 8/25 and you need to specify that you're assuming that $vecX$ has unit length.
$endgroup$
– Roman
6 hours ago
add a comment |
$begingroup$
This is how I'd do it; maybe it's useful for you.
Define $vecX$ and $vecV$ as vectors:
X = Array[x, 3];
V = Array[v, 3];
useful $3times3times3$ tensors for assembling:
a = Outer[Times, X, X, V];
b = (X.X) Outer[Times, IdentityMatrix[3], V];
c = (X.V) Outer[Times, IdentityMatrix[3], X];
assemble $XXV$:
XXV = (a + Transpose[a, 3, 1, 2] + Transpose[a, 2, 3, 1])/3 -
(b + Transpose[c, 3, 1, 2] + Transpose[c, 2, 3, 1])/5;
check a formula:
Total[XXV*XXV, 3] == 2/25 (X.X) ((X.V)^2 + 4 (X.X) (V.V)) // FullSimplify
(* True *)
$endgroup$
This is how I'd do it; maybe it's useful for you.
Define $vecX$ and $vecV$ as vectors:
X = Array[x, 3];
V = Array[v, 3];
useful $3times3times3$ tensors for assembling:
a = Outer[Times, X, X, V];
b = (X.X) Outer[Times, IdentityMatrix[3], V];
c = (X.V) Outer[Times, IdentityMatrix[3], X];
assemble $XXV$:
XXV = (a + Transpose[a, 3, 1, 2] + Transpose[a, 2, 3, 1])/3 -
(b + Transpose[c, 3, 1, 2] + Transpose[c, 2, 3, 1])/5;
check a formula:
Total[XXV*XXV, 3] == 2/25 (X.X) ((X.V)^2 + 4 (X.X) (V.V)) // FullSimplify
(* True *)
answered 7 hours ago
RomanRoman
14.3k1 gold badge19 silver badges51 bronze badges
14.3k1 gold badge19 silver badges51 bronze badges
$begingroup$
Nice that you verified my answer. I already started to doubt.
$endgroup$
– yarchik
7 hours ago
$begingroup$
@yarchik this is one of my calculation errors... I have corrected the formula in my post
$endgroup$
– mattiav27
7 hours ago
$begingroup$
@mattiav27 it's still wrong, the second term should be 8/25 and you need to specify that you're assuming that $vecX$ has unit length.
$endgroup$
– Roman
6 hours ago
add a comment |
$begingroup$
Nice that you verified my answer. I already started to doubt.
$endgroup$
– yarchik
7 hours ago
$begingroup$
@yarchik this is one of my calculation errors... I have corrected the formula in my post
$endgroup$
– mattiav27
7 hours ago
$begingroup$
@mattiav27 it's still wrong, the second term should be 8/25 and you need to specify that you're assuming that $vecX$ has unit length.
$endgroup$
– Roman
6 hours ago
$begingroup$
Nice that you verified my answer. I already started to doubt.
$endgroup$
– yarchik
7 hours ago
$begingroup$
Nice that you verified my answer. I already started to doubt.
$endgroup$
– yarchik
7 hours ago
$begingroup$
@yarchik this is one of my calculation errors... I have corrected the formula in my post
$endgroup$
– mattiav27
7 hours ago
$begingroup$
@yarchik this is one of my calculation errors... I have corrected the formula in my post
$endgroup$
– mattiav27
7 hours ago
$begingroup$
@mattiav27 it's still wrong, the second term should be 8/25 and you need to specify that you're assuming that $vecX$ has unit length.
$endgroup$
– Roman
6 hours ago
$begingroup$
@mattiav27 it's still wrong, the second term should be 8/25 and you need to specify that you're assuming that $vecX$ has unit length.
$endgroup$
– Roman
6 hours ago
add a comment |
$begingroup$
You can cast this as a symbolic tensor question, and make use of my TensorSimplify package. Install the paclet with:
PacletInstall[
"TensorSimplify",
"Site" -> "http://raw.githubusercontent.com/carlwoll/TensorSimplify/master"
]
Once installed, load the package with:
<<TensorSimplify`
Now, define your tensor using TensorProduct:
XXV = 1/3 (TensorProduct[X,X,V] + TensorProduct[X,V,X] + TensorProduct[V,X,X]) -
1/5 (X.X TensorProduct[Inactive[IdentityMatrix][3], V] +
X.V TensorTranspose[TensorProduct[Inactive[IdentityMatrix][3],X],1,3,2] +
X.V TensorProduct[X,Inactive[IdentityMatrix][3]]
);
Note the use of Inactive[IdentityMatrix][3] instead of IdentityMatrix[3]. Then:
TensorSimplify[
TensorContract[TensorProduct[XXV, XXV], 1, 4, 2, 5, 3, 6],
Assumptions -> (X|V) ∈ Vectors[3]
]
2/25 (V.X)^2 X.X + 8/25 V.V (X.X)^2
Using X.X == 1 reproduces your result.
$endgroup$
add a comment |
$begingroup$
You can cast this as a symbolic tensor question, and make use of my TensorSimplify package. Install the paclet with:
PacletInstall[
"TensorSimplify",
"Site" -> "http://raw.githubusercontent.com/carlwoll/TensorSimplify/master"
]
Once installed, load the package with:
<<TensorSimplify`
Now, define your tensor using TensorProduct:
XXV = 1/3 (TensorProduct[X,X,V] + TensorProduct[X,V,X] + TensorProduct[V,X,X]) -
1/5 (X.X TensorProduct[Inactive[IdentityMatrix][3], V] +
X.V TensorTranspose[TensorProduct[Inactive[IdentityMatrix][3],X],1,3,2] +
X.V TensorProduct[X,Inactive[IdentityMatrix][3]]
);
Note the use of Inactive[IdentityMatrix][3] instead of IdentityMatrix[3]. Then:
TensorSimplify[
TensorContract[TensorProduct[XXV, XXV], 1, 4, 2, 5, 3, 6],
Assumptions -> (X|V) ∈ Vectors[3]
]
2/25 (V.X)^2 X.X + 8/25 V.V (X.X)^2
Using X.X == 1 reproduces your result.
$endgroup$
add a comment |
$begingroup$
You can cast this as a symbolic tensor question, and make use of my TensorSimplify package. Install the paclet with:
PacletInstall[
"TensorSimplify",
"Site" -> "http://raw.githubusercontent.com/carlwoll/TensorSimplify/master"
]
Once installed, load the package with:
<<TensorSimplify`
Now, define your tensor using TensorProduct:
XXV = 1/3 (TensorProduct[X,X,V] + TensorProduct[X,V,X] + TensorProduct[V,X,X]) -
1/5 (X.X TensorProduct[Inactive[IdentityMatrix][3], V] +
X.V TensorTranspose[TensorProduct[Inactive[IdentityMatrix][3],X],1,3,2] +
X.V TensorProduct[X,Inactive[IdentityMatrix][3]]
);
Note the use of Inactive[IdentityMatrix][3] instead of IdentityMatrix[3]. Then:
TensorSimplify[
TensorContract[TensorProduct[XXV, XXV], 1, 4, 2, 5, 3, 6],
Assumptions -> (X|V) ∈ Vectors[3]
]
2/25 (V.X)^2 X.X + 8/25 V.V (X.X)^2
Using X.X == 1 reproduces your result.
$endgroup$
You can cast this as a symbolic tensor question, and make use of my TensorSimplify package. Install the paclet with:
PacletInstall[
"TensorSimplify",
"Site" -> "http://raw.githubusercontent.com/carlwoll/TensorSimplify/master"
]
Once installed, load the package with:
<<TensorSimplify`
Now, define your tensor using TensorProduct:
XXV = 1/3 (TensorProduct[X,X,V] + TensorProduct[X,V,X] + TensorProduct[V,X,X]) -
1/5 (X.X TensorProduct[Inactive[IdentityMatrix][3], V] +
X.V TensorTranspose[TensorProduct[Inactive[IdentityMatrix][3],X],1,3,2] +
X.V TensorProduct[X,Inactive[IdentityMatrix][3]]
);
Note the use of Inactive[IdentityMatrix][3] instead of IdentityMatrix[3]. Then:
TensorSimplify[
TensorContract[TensorProduct[XXV, XXV], 1, 4, 2, 5, 3, 6],
Assumptions -> (X|V) ∈ Vectors[3]
]
2/25 (V.X)^2 X.X + 8/25 V.V (X.X)^2
Using X.X == 1 reproduces your result.
answered 5 hours ago
Carl WollCarl Woll
87.6k3 gold badges115 silver badges224 bronze badges
87.6k3 gold badges115 silver badges224 bronze badges
add a comment |
add a comment |
Thanks for contributing an answer to Mathematica Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f202373%2fhow-can-i-automate-this-tensor-computation%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
$begingroup$
Is there a typo in your last term on the first line, $X_kX_iV_k$? There should be a $j$-index somewhere.
$endgroup$
– Roman
8 hours ago
$begingroup$
@Roman yes it is a typo
$endgroup$
– mattiav27
7 hours ago
$begingroup$
I think your second term still needs a power correction. The answer should be proportional to $V^2$.
$endgroup$
– yarchik
7 hours ago
$begingroup$
@yarchik you are right, but this is a typo not a calculation error...
$endgroup$
– mattiav27
7 hours ago