Manipulating subexpressions

### 2.9.3 Manipulating subexpressions

If a subexpression is selected in the expression editor, then any menu command will be applied to that subexpression.

For example, enter the expression (x+1)*(x+2)*(x-1) in the expression editor. Note that use the abilities of the editor to make this easier. First, enter x+1. Select this with the up arrow, then type * followed by x+2. Select the x+2 with the up arrow and then type * followed by x-1. Using the up arrow again will select the x-1. Select the entire expression with the up arrow, and then select eval from the M menu. This will put all factors at the same level. Suppose you want the factors (x+1)*(x+2) to be expanded. You could select (x+1)*(x+2) with the mouse and do one of the following:

- Select the Expression ▸ Misc ▸ normal menu item. You will then have normal((x+1)*(x+2))*(x-1) in the editor. If you hit enter, the result (x2+3x+2)(x−1) will appear in the output window.
- Select the Expression ▸ Misc ▸ normal menu item, so again you have normal((x+1)*(x+2))*(x-1) in the editor. Now if you select eval from the M menu, then the expression in the editor will become the result (x2+3x+2)(x−1), which you can continue editing.
- Choose normal from the M menu. This will apply normal to the selection, and again you will have the result (x2+3x+2)(x−1) in the editor.

There are also keystroke commands that use to operate on subexpressions that you have selected. There are the usual Ctrl+Z and Ctrl+Y for undoing and redoing. Some of the others are given in Table 2.1.

> Key | Action on selection | Key | Action on selection
> Ctrl+D | differentiate | Ctrl+P | partial fraction
> Ctrl+F | factor | Ctrl+R | integrate
> Ctrl+L | limit | Ctrl+S | simplify
> Ctrl+N | normalize | Ctrl+T | copy LATEX version to clipboard

> Table 2.1: Keystroke operations on subexpressions