Parentheses in Expressions

Parentheses are added to expressions automatically. There are a few cases where you may want to add parentheses that would not normally appear in the expression. A Parentheses object has been created for this purpose.

An simple example of the automatic addition of parentheses is the expression

In expressions like this, the parentheses are added as part of the rendering. This expression contains a Mult object and an Add object, but there is no additional object for the parentheses.

In a few cases, you may want to add parentheses where they wouldn't automatically be added to an expression. For example, it's common to create expressions like

to indicate associativity. Since this expression would normally appear without any parentheses, we can use the Parentheses object to create this expression. Note that the Parentheses object appears in a different color to make it easier to distinguish from parentheses that are added as part of a rendering.

To create this expression,

  1. Create a + b as usual (see Building Expressions)
  2. Press the spacebar - note that this creates the Space object with "a + b" in the first parameter and an empty box (highlighted) as the second parameter
  3. Type "parentheses". This opens the autocomplete popup
  4. Select the Parentheses object from the autocomplete popup
  5. Create " + c" as usual.

Adding parentheses is generally something you will only want to do after an expression has been manipulated to its final form. Typically, the commands are not designed to work with the Parentheses object. For example, the expression

will simplify but this expression

containing a Parentheses object won't simplify.