# The Left and Right Commands

The Left and Right commands are used to reorder terms in algebraic expressions involving addition, subtraction, and multiplication. This command normally modifies one of the parent expressions of the highlighted term. The Left and Right commands will also reorder terms in other commutative monoids. For expressions involving addition and subtraction, the RightIn and LeftIn commands will move terms in and out of parenthesized terms. The shortcuts for the Left and Right commands are the "l" and "r" keys, respectively. For the LeftIn and RightIn commands, the shortcuts are the "L" and "R" keys.

## Simple term ordering

The simplest example is moving a term in an expression where several terms are added together: If you highlight the "h" term and apply the Left command, the result will be: The "h" term has been moved to the left by one position. (Note: we will use "h" for the highlighted term in all of the examples that follow).

With "h" still highlighted, applying the Right command will return the expression to its original form.

The Left and Right commands behave in exactly the same way for terms that are multipled, so the Left command on:

a b c h d

gives

a b h c d

and with the "h" still highlighted, the Right command returns you to the original expression.

## Expressions that mix addition and subtraction

The Left and Right commands can also move terms in expressions that mix addition and subtraction. So in the expression

a + b - c - d + h

Using the Left command repeatedly (with "h" highlighted each time) gives:

a + b - c + h - d

a + b + h - c - d

a + h + b - c - d

h + a + b - c - d

## Expressions with parentheses

In expressions involving addition and subtraction that have parentheses, the Left and Right commands will treat the parenthesized terms as a single term and move the highlighted term across the whole parenthesized term. For example, with "h" highlighted, the Left command on:

a - (b + c) + h

gives:

a + h - (b + c)

If the highlighted term is inside of the parentheses, the Left and Right commands won't move the term outside of the parentheses. For example, with the "h" term highlighted in the expression

a - (b + c + h + d) + e

the Left and Right commands can be used to move the "h" anywhere from first to last position inside of the parentheses, but you would have to have the "h" at one side or the other and use either the LeftIn or RightIn command to move it out of the parentheses.

## The LeftIn and RightIn commands

While the Left command on

a - (b + c) + h

moves the "h" across the parenthesized term, the LeftIn command on this same expression gives

a - (b + c - h)

The LeftIn and RightIn commands move the highlighted term into parenthesized expressions rather than moving it over them.

The LeftIn and RightIn commands will also move the highlighted term out of a parenthesized term. So applying the RightIn command to the previous expression with "h" still highlighted returns the expression to its original form.

Similarly, using LeftIn on results in and with the "h" still highlighted, the RightIn command returns us to the first expression.

Note that the LeftIn and RightIn commands do the same thing as the Left and Right commands in cases where the highlighted term is not adjacent to a parenthesized term. So on our original expression the Left and Right commands and the LeftIn and RightIn commands do exactly the same thing.