nested commutators
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
I have defined the commutator between two matrices as
comm[A_,B_]:=A.B-B.A
I have defined the nested commutator as
nestcomm[A_,B_,n_]:= ToExpression[
StringRepeat["comm[a,", n] <> "b" <> StringRepeat["]", n]
]
where $n$ indicates how many time the commutator must be nested.
Does exists a more simple way to define an $n$-time nested operation between two elements $A$ and $B$? I tried to use the Nest function but without success.
nest
add a comment |Â
up vote
1
down vote
favorite
I have defined the commutator between two matrices as
comm[A_,B_]:=A.B-B.A
I have defined the nested commutator as
nestcomm[A_,B_,n_]:= ToExpression[
StringRepeat["comm[a,", n] <> "b" <> StringRepeat["]", n]
]
where $n$ indicates how many time the commutator must be nested.
Does exists a more simple way to define an $n$-time nested operation between two elements $A$ and $B$? I tried to use the Nest function but without success.
nest
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I have defined the commutator between two matrices as
comm[A_,B_]:=A.B-B.A
I have defined the nested commutator as
nestcomm[A_,B_,n_]:= ToExpression[
StringRepeat["comm[a,", n] <> "b" <> StringRepeat["]", n]
]
where $n$ indicates how many time the commutator must be nested.
Does exists a more simple way to define an $n$-time nested operation between two elements $A$ and $B$? I tried to use the Nest function but without success.
nest
I have defined the commutator between two matrices as
comm[A_,B_]:=A.B-B.A
I have defined the nested commutator as
nestcomm[A_,B_,n_]:= ToExpression[
StringRepeat["comm[a,", n] <> "b" <> StringRepeat["]", n]
]
where $n$ indicates how many time the commutator must be nested.
Does exists a more simple way to define an $n$-time nested operation between two elements $A$ and $B$? I tried to use the Nest function but without success.
nest
nest
asked 5 hours ago
Galuoises
1887
1887
add a comment |Â
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
4
down vote
accepted
Redefine your comm function to take in and put out a pair of matrices, then Nest can be called easily:
comm[A_, B_] := A, A.B - B.A
Then just invoke Nest with the number of terms in the final position. For n=2:
Rest[Nest[comm, a, b, 2]]
a.(a.b - b.a) - (a.b - b.a).a
Thank you for your help!
â Galuoises
7 mins ago
add a comment |Â
up vote
2
down vote
Would something like the following work?
comm[A_,B_,1] := A.B-B.A
comm[A_, B_, n_Integer?Positive] := comm[comm[A, B, n-1], B, 1]
For example:
comm[A, B, 2] //TensorExpand
comm[A, B, 3] //TensorExpand
A.B.B - 2 B.A.B + B.B.A
A.B.B.B - 3 B.A.B.B + 3 B.B.A.B - B.B.B.A
Use:
comm[A_, B_, n_Integer?Positive] := comm[A, comm[A, B, n-1], 1]
to obtain the same definition as in @bill's answer.
Thank you! I appreciate your answer
â Galuoises
8 mins ago
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
4
down vote
accepted
Redefine your comm function to take in and put out a pair of matrices, then Nest can be called easily:
comm[A_, B_] := A, A.B - B.A
Then just invoke Nest with the number of terms in the final position. For n=2:
Rest[Nest[comm, a, b, 2]]
a.(a.b - b.a) - (a.b - b.a).a
Thank you for your help!
â Galuoises
7 mins ago
add a comment |Â
up vote
4
down vote
accepted
Redefine your comm function to take in and put out a pair of matrices, then Nest can be called easily:
comm[A_, B_] := A, A.B - B.A
Then just invoke Nest with the number of terms in the final position. For n=2:
Rest[Nest[comm, a, b, 2]]
a.(a.b - b.a) - (a.b - b.a).a
Thank you for your help!
â Galuoises
7 mins ago
add a comment |Â
up vote
4
down vote
accepted
up vote
4
down vote
accepted
Redefine your comm function to take in and put out a pair of matrices, then Nest can be called easily:
comm[A_, B_] := A, A.B - B.A
Then just invoke Nest with the number of terms in the final position. For n=2:
Rest[Nest[comm, a, b, 2]]
a.(a.b - b.a) - (a.b - b.a).a
Redefine your comm function to take in and put out a pair of matrices, then Nest can be called easily:
comm[A_, B_] := A, A.B - B.A
Then just invoke Nest with the number of terms in the final position. For n=2:
Rest[Nest[comm, a, b, 2]]
a.(a.b - b.a) - (a.b - b.a).a
answered 5 hours ago
bill s
51.8k375146
51.8k375146
Thank you for your help!
â Galuoises
7 mins ago
add a comment |Â
Thank you for your help!
â Galuoises
7 mins ago
Thank you for your help!
â Galuoises
7 mins ago
Thank you for your help!
â Galuoises
7 mins ago
add a comment |Â
up vote
2
down vote
Would something like the following work?
comm[A_,B_,1] := A.B-B.A
comm[A_, B_, n_Integer?Positive] := comm[comm[A, B, n-1], B, 1]
For example:
comm[A, B, 2] //TensorExpand
comm[A, B, 3] //TensorExpand
A.B.B - 2 B.A.B + B.B.A
A.B.B.B - 3 B.A.B.B + 3 B.B.A.B - B.B.B.A
Use:
comm[A_, B_, n_Integer?Positive] := comm[A, comm[A, B, n-1], 1]
to obtain the same definition as in @bill's answer.
Thank you! I appreciate your answer
â Galuoises
8 mins ago
add a comment |Â
up vote
2
down vote
Would something like the following work?
comm[A_,B_,1] := A.B-B.A
comm[A_, B_, n_Integer?Positive] := comm[comm[A, B, n-1], B, 1]
For example:
comm[A, B, 2] //TensorExpand
comm[A, B, 3] //TensorExpand
A.B.B - 2 B.A.B + B.B.A
A.B.B.B - 3 B.A.B.B + 3 B.B.A.B - B.B.B.A
Use:
comm[A_, B_, n_Integer?Positive] := comm[A, comm[A, B, n-1], 1]
to obtain the same definition as in @bill's answer.
Thank you! I appreciate your answer
â Galuoises
8 mins ago
add a comment |Â
up vote
2
down vote
up vote
2
down vote
Would something like the following work?
comm[A_,B_,1] := A.B-B.A
comm[A_, B_, n_Integer?Positive] := comm[comm[A, B, n-1], B, 1]
For example:
comm[A, B, 2] //TensorExpand
comm[A, B, 3] //TensorExpand
A.B.B - 2 B.A.B + B.B.A
A.B.B.B - 3 B.A.B.B + 3 B.B.A.B - B.B.B.A
Use:
comm[A_, B_, n_Integer?Positive] := comm[A, comm[A, B, n-1], 1]
to obtain the same definition as in @bill's answer.
Would something like the following work?
comm[A_,B_,1] := A.B-B.A
comm[A_, B_, n_Integer?Positive] := comm[comm[A, B, n-1], B, 1]
For example:
comm[A, B, 2] //TensorExpand
comm[A, B, 3] //TensorExpand
A.B.B - 2 B.A.B + B.B.A
A.B.B.B - 3 B.A.B.B + 3 B.B.A.B - B.B.B.A
Use:
comm[A_, B_, n_Integer?Positive] := comm[A, comm[A, B, n-1], 1]
to obtain the same definition as in @bill's answer.
answered 5 hours ago
Carl Woll
62.4k281158
62.4k281158
Thank you! I appreciate your answer
â Galuoises
8 mins ago
add a comment |Â
Thank you! I appreciate your answer
â Galuoises
8 mins ago
Thank you! I appreciate your answer
â Galuoises
8 mins ago
Thank you! I appreciate your answer
â Galuoises
8 mins ago
add a comment |Â
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
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f184631%2fnested-commutators%23new-answer', 'question_page');
);
Post as a guest
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
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
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