Skip to main content
edited tags
Link
edited body
Source Link
Bilentor
  • 515
  • 3
  • 12

I have been trying to do some oscillator algebra in Mathematica and having troubles with sorting and simplifying expressions. I am using the NCAlgebra package which helps to improve the properties of NonCommutativeMultiply in Mathematica. However I have to create a huge list of rules to replace terms using the algebra. This quickly becomes impractical since I get these enormous expressions and I have to sift through the terms to see what simplifies and add more rules.

I have been wondering if there is a way to write a sorting function that would take an elementary expression and change it to a list and then permute the elements of list to sort the expression. I am fairly new to Mathematica but I would eventually like to write a small package which would allow me to these kind of manipulations.

For example, I have terms like $a**b**c**a^\dagger$ where $a$, $b$, $c$, etc. commute with each other but $a**a^\dagger-a**a^\dagger =1$$a**a^\dagger-a^\dagger**a =1$. So I would like to sort things such that all dagger operators are to the left and have Mathematica use the fact that $a$, $b$, $c$ commute to rewrite the expressions. Right now I am assigning rules for every type of term that appears in my calculation but the number of terms has become unmanageable.

I have been trying to do some oscillator algebra in Mathematica and having troubles with sorting and simplifying expressions. I am using the NCAlgebra package which helps to improve the properties of NonCommutativeMultiply in Mathematica. However I have to create a huge list of rules to replace terms using the algebra. This quickly becomes impractical since I get these enormous expressions and I have to sift through the terms to see what simplifies and add more rules.

I have been wondering if there is a way to write a sorting function that would take an elementary expression and change it to a list and then permute the elements of list to sort the expression. I am fairly new to Mathematica but I would eventually like to write a small package which would allow me to these kind of manipulations.

For example, I have terms like $a**b**c**a^\dagger$ where $a$, $b$, $c$, etc. commute with each other but $a**a^\dagger-a**a^\dagger =1$. So I would like to sort things such that all dagger operators are to the left and have Mathematica use the fact that $a$, $b$, $c$ commute to rewrite the expressions. Right now I am assigning rules for every type of term that appears in my calculation but the number of terms has become unmanageable.

I have been trying to do some oscillator algebra in Mathematica and having troubles with sorting and simplifying expressions. I am using the NCAlgebra package which helps to improve the properties of NonCommutativeMultiply in Mathematica. However I have to create a huge list of rules to replace terms using the algebra. This quickly becomes impractical since I get these enormous expressions and I have to sift through the terms to see what simplifies and add more rules.

I have been wondering if there is a way to write a sorting function that would take an elementary expression and change it to a list and then permute the elements of list to sort the expression. I am fairly new to Mathematica but I would eventually like to write a small package which would allow me to these kind of manipulations.

For example, I have terms like $a**b**c**a^\dagger$ where $a$, $b$, $c$, etc. commute with each other but $a**a^\dagger-a^\dagger**a =1$. So I would like to sort things such that all dagger operators are to the left and have Mathematica use the fact that $a$, $b$, $c$ commute to rewrite the expressions. Right now I am assigning rules for every type of term that appears in my calculation but the number of terms has become unmanageable.

edited body
Source Link
rm -rf
  • 89.3k
  • 21
  • 297
  • 479

I have been trying to do some oscillator algebra in Mathematica and having troubles with sorting and simplifying expressions. I am using the NCAlgebra package which helps to improve the properties of NonCommutativeMultiply in Mathematica. However I have to create a huge list of rules to replace terms using the algebra. This quickly becomes impractical since I get these enormous expressions and I have to sift through the terms to see what simplifies and add more rules.

I have been wondering if there is a way to write a sorting function that would take an elementary expression and change it to a list and then permute the elements of list to sort the expression. I am fairly new to Mathematica but I would eventually like to write a small package which would allow me to these kind of manipulations.

For example, I have terms like a**b**c**a(dagger)$a**b**c**a^\dagger$ where a$a$, b$b$, c$c$, etc. commute with each other but a**a(dagger)-a**a(dagger) =1$a**a^\dagger-a**a^\dagger =1$. So I would like to sort things such that all dagger operators are to the left and have Mathematica use the fact that a$a$, b$b$, c$c$ commute to rewrite the expressions. Right now I am assigning rules for every type of term that appears in my calculation but the number of terms has become unmanageable.

I have been trying to do some oscillator algebra in Mathematica and having troubles with sorting and simplifying expressions. I am using the NCAlgebra package which helps to improve the properties of NonCommutativeMultiply in Mathematica. However I have to create a huge list of rules to replace terms using the algebra. This quickly becomes impractical since I get these enormous expressions and I have to sift through the terms to see what simplifies and add more rules.

I have been wondering if there is a way to write a sorting function that would take an elementary expression and change it to a list and then permute the elements of list to sort the expression. I am fairly new to Mathematica but I would eventually like to write a small package which would allow me to these kind of manipulations.

For example, I have terms like a**b**c**a(dagger) where a, b, c, etc. commute with each other but a**a(dagger)-a**a(dagger) =1. So I would like to sort things such that all dagger operators are to the left and have Mathematica use the fact that a, b, c commute to rewrite the expressions. Right now I am assigning rules for every type of term that appears in my calculation but the number of terms has become unmanageable.

I have been trying to do some oscillator algebra in Mathematica and having troubles with sorting and simplifying expressions. I am using the NCAlgebra package which helps to improve the properties of NonCommutativeMultiply in Mathematica. However I have to create a huge list of rules to replace terms using the algebra. This quickly becomes impractical since I get these enormous expressions and I have to sift through the terms to see what simplifies and add more rules.

I have been wondering if there is a way to write a sorting function that would take an elementary expression and change it to a list and then permute the elements of list to sort the expression. I am fairly new to Mathematica but I would eventually like to write a small package which would allow me to these kind of manipulations.

For example, I have terms like $a**b**c**a^\dagger$ where $a$, $b$, $c$, etc. commute with each other but $a**a^\dagger-a**a^\dagger =1$. So I would like to sort things such that all dagger operators are to the left and have Mathematica use the fact that $a$, $b$, $c$ commute to rewrite the expressions. Right now I am assigning rules for every type of term that appears in my calculation but the number of terms has become unmanageable.

added 77 characters in body
Source Link
Szabolcs
  • 236.5k
  • 31
  • 641
  • 1.3k
Loading
Example of a sample expression
Source Link
Bilentor
  • 515
  • 3
  • 12
Loading
Post Migrated Here from stackoverflow.com (revisions)
Source Link
Karan
  • 515
  • 3
  • 12
Loading