Quantcast
Channel: Active questions tagged string-manipulation - Mathematica Stack Exchange
Viewing all articles
Browse latest Browse all 186

Writing Mathematica code for putting in commutation relations in a string

$
0
0

I am trying to write a mathematica code to accomplish the following:

For a given $n$, consider $(ab)^n$, which is a string of the form $\underbrace{ababab...ab}_{n\text{ times}}$.

I want to replace $ba$ with $ab+1$, and then expand. For instance, if $n=2$, then we get abab->a(ab+1)b=aabb+ab

I have been having a very hard time writing code for this. Especially, manipulating strings using Mathematica has proved to be extremely difficult.

Any ideas how I could write this code?


Viewing all articles
Browse latest Browse all 186

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>