How does brackets work?

11 Apr.,2024

 

The concept of interval notation comes up in both Mathematics and Computer Science. The Mathematical notation [, ], (, ) denotes the domain (or range) of an interval.

  • The brackets [ and ] means:

    1. The number is included,
    2. This side of the interval is closed,
  • The parenthesis ( and ) means:

    1. The number is excluded,
    2. This side of the interval is open.

An interval with mixed states is called "half-open".

For example, the range of consecutive integers from 1 .. 10 (inclusive) would be notated as such:

  • [1,10]

Notice how the word inclusive was used. If we want to exclude the end point but "cover" the same range we need to move the end-point:

  • [1,11)

For both left and right edges of the interval there are actually 4 permutations:

(1,10) =   2,3,4,5,6,7,8,9       Set has  8 elements
(1,10] =   2,3,4,5,6,7,8,9,10    Set has  9 elements
[1,10) = 1,2,3,4,5,6,7,8,9       Set has  9 elements
[1,10] = 1,2,3,4,5,6,7,8,9,10    Set has 10 elements

How does this relate to Mathematics and Computer Science?

Array indexes tend to use a different offset depending on which field are you in:

  • Mathematics tends to be one-based.
  • Certain programming languages tends to be zero-based, such as C, C++, Javascript, Python, while other languages such as Mathematica, Fortran, Pascal are one-based.

These differences can lead to subtle fence post errors, aka, off-by-one bugs when implementing Mathematical algorithms such as for-loops.

Integers

If we have a set or array, say of the first few primes [ 2, 3, 5, 7, 11, 13, 17, 19, 23, 29 ], Mathematicians would refer to the first element as the 1st absolute element. i.e. Using subscript notation to denote the index:

  • a1 = 2
  • a2 = 3
  • :
  • a10 = 29

Some programming languages, in contradistinction, would refer to the first element as the zero'th relative element.

  • a[0] = 2
  • a[1] = 3
  • :
  • a[9] = 29

Since the array indexes are in the range [0,N-1] then for clarity purposes it would be "nice" to keep the same numerical value for the range 0 .. N instead of adding textual noise such as a -1 bias.

For example, in C or JavaScript, to iterate over an array of N elements a programmer would write the common idiom of i = 0, i < N with the interval [0,N) instead of the slightly more verbose [0,N-1]:

function main() {
    var output = "";
    var a = [ 2, 3, 5, 7,  11, 13, 17, 19, 23, 29 ];
    for( var i = 0; i < 10; i++ ) // [0,10)
       output += "[" + i + "]: " + a[i] + "\n";

    if (typeof window === 'undefined') // Node command line
        console.log( output )
    else
        document.getElementById('output1').innerHTML = output;
}
 <html>
     <body onload="main();">
         <pre id="output1"></pre>
     </body>
 </html>

Mathematicians, since they start counting at 1, would instead use the i = 1, i <= N nomenclature but now we need to correct the array offset in a zero-based language.

e.g.

function main() {
    var output = "";
    var a = [ 2, 3, 5, 7,  11, 13, 17, 19, 23, 29 ];
    for( var i = 1; i <= 10; i++ ) // [1,10]
       output += "[" + i + "]: " + a[i-1] + "\n";

    if (typeof window === 'undefined') // Node command line
        console.log( output )
    else
        document.getElementById( "output2" ).innerHTML = output;
}
<html>
    <body onload="main()";>
        <pre id="output2"></pre>
    </body>
</html>

Aside:

In programming languages that are 0-based you might need a kludge of a dummy zero'th element to use a Mathematical 1-based algorithm. e.g. Python Index Start

Floating-Point

Interval notation is also important for floating-point numbers to avoid subtle bugs.

When dealing with floating-point numbers especially in Computer Graphics (color conversion, computational geometry, animation easing/blending, etc.) often times normalized numbers are used. That is, numbers between 0.0 and 1.0.

It is important to know the edge cases if the endpoints are inclusive or exclusive:

  • (0,1) = 1e-M .. 0.999...
  • (0,1] = 1e-M .. 1.0
  • [0,1) = 0.0 .. 0.999...
  • [0,1] = 0.0 .. 1.0

Where M is some machine epsilon. This is why you might sometimes see const float EPSILON = 1e-# idiom in C code (such as 1e-6) for a 32-bit floating point number. This SO question Does EPSILON guarantee anything? has some preliminary details. For a more comprehensive answer see FLT_EPSILON and David Goldberg's What Every Computer Scientist Should Know About Floating-Point Arithmetic

Some implementations of a random number generator, random() may produce values in the range 0.0 .. 0.999... instead of the more convenient 0.0 .. 1.0. Proper comments in the code will document this as [0.0,1.0) or [0.0,1.0] so there is no ambiguity as to the usage.

Example:

  • You want to generate random() colors. You convert three floating-point values to unsigned 8-bit values to generate a 24-bit pixel with red, green, and blue channels respectively. Depending on the interval output by random() you may end up with near-white (254,254,254) or white (255,255,255).
     +--------+-----+
     |random()|Byte |
     |--------|-----|
     |0.999...| 254 | <-- error introduced
     |1.0     | 255 |
     +--------+-----+

For more details about floating-point precision and robustness with intervals see Christer Ericson's Real-Time Collision Detection, Chapter 11 Numerical Robustness, Section 11.3 Robust Floating-Point Usage.

What are Brackets?

You must have seen different symbols like these: (, ), [, ], {, and } in your math books. These symbols are called brackets. Brackets in mathematics serve a very important purpose; these symbols help us group different expressions or numbers together. Brackets imply that the thing or expression enclosed by them is to be given higher precedence over other things.

Different kinds of Brackets

In math, you will often have to use brackets while creating or solving equations. They help in grouping numbers and defining the order of operations. Generally, three kinds of brackets are used in mathematics,

  • Parentheses or Round Brackets, ( )
  • Curly or Brace Brackets { }
  • Square or Box Brackets [ ]

Brackets always come in pairs, and if there is an opening bracket, there has to be a closing bracket. The opening brackets are (, [  and {. Their corresponding closing brackets are ), ] and }.  

Parentheses Brackets

These are also known as the round brackets and written as ( ). These are the most common types of brackets. They are used for grouping different values and equations together. Parentheses or “round brackets” are used to group terms together or specify the order of operations in an equation. 

How to Use Parentheses in Math?

  1. In math, you can use parentheses in math to separate numbers. For instance, you can use them to mention negative numbers when writing an addition equation.

Here is an example to understand this better:

$3 + ( −5) = −2$

  1. The second use of parentheses in math is to multiply numbers. If there is no arithmetic operation present in an equation, the presence of parentheses means you have to apply multiplication.

Let us understand this with an example:

$6 (4 + 2)$

can be written as $6 \times (4 + 2)$

Therefore, the answer is $6 \times 6 = 36$.

  1. The third and final use of parentheses in math is to group numbers and define the order of operations.
  2. When used simply around numbers, the round brackets denote multiplication.

For example : $(3)(4) = 12$

  1. They can also be used to write negative integers in mathematical expressions.

For example $5 + ( −4) = 1$

  1. Parentheses can also be used to separate out numbers from their exponents. For example: $(2)^{-3}$

Examples: $(2 + 4), 5(111), 25 − (12 + 8)$, etc.

Curly Brackets

Braces in math are symbols that are used twice, once to open “{“ and once to close “}” an argument, expression, or equation. These are commonly referred to as curly brackets and written as { }.

In general, we use braces in math for two purposes:

  • For grouping a large equation, in which the second-last bracket is braces or curly brackets. For example, $7[2 + \left\{3(1 + 1) + 1\right\}]$
  • For denoting a set, such as {x, y, z,…}

Like Parentheses, curly brackets are also used to group various mathematical components; however, curly brackets are also used to depict sets or to write nested expressions.  Examples: 

$[4+\left\{3\times(-2)\right\}] − [\left\{(4 \times 6)+(14 \div 7)\right\} − ( −3)]$,

 $[\left\{12 − (12 − 2)\right\} + (5 − 7)] + 9$, etc.

How Do We Use Braces in Math?

Braces in math are frequently used in mathematical expressions when we have two or more than two nested groups for calculations.

So, in the first nested group, we use parentheses. In the second nested group, we use braces, and in the third nested group, we use box brackets, which contain both parentheses and braces.

For example: $3[2 − \left\{4(2 + 2) + 2\right\}]$

Here, we have three nested groups with appropriate brackets.

So, the order of solving would be:

Fun Facts

  • Some conventions differentiate the order of solving brackets, which is:

We will use the first convention with curly brackets in the second position throughout this article.

You need to know the BODMAS or order of operations to simplify and solve a problem.

Square Brackets

Square brackets are generally used to distinguish between sub-expressions of a complex mathematical expression.

Examples: $[100 − (3 − 1) + (7 \times 8)], 10 \times [(4 − 2) \times ( 4 \times 2)]$, etc.

Order of Operations of Brackets

When we evaluate a mathematical expression that is made up of different brackets, we have to follow certain rules. This is called the rules of operation or order of operation of brackets.

When we have a long equation for multiplication, division, addition, and subtraction, we solve each function in order to find the right answer. If the problem is solved without this order, then the chances of getting a wrong answer are high!

  • The general order of operation of the bracket can be illustrated as $[ \left\{ ( ) \right\} ]$; this means that in a given problem, you would have to simplify the values in the innermost bracket first. This means that first $( )$ brackets will be solved, following which, $\left\{ \right\}$ brackets are solved and finally $[ ]$ brackets.
  • The second step in solving these problems is to look for an exponent; if there is any, solve it first.
  • In the third step, we look for expressions with multiplication or division operators. If both the operators are present, we check the expression from left to right. Whichever operator comes first, we solve that operator first.

For example, in the expression, $10 \times 6 \div 5$, we check from left to right, since multiplication comes first so we solve multiplication first and then division.

$10 \times 6 \div 5$ 

$=60 \div 5$

$= 12$

  • In the fourth and last step, we look for numbers that need to be added or subtracted. We follow the same instruction if both the operators are present, we look from left to right in the expression, and whichever operator comes first, we solve that expression first. But if the operations are in brackets, we always solve the brackets first since brackets have the utmost precedence.

To remember the above mention steps, we can use the acronym PEMDAS,

P – Parentheses,(or brackets)

E – Exponents, (or order)

M – Multiplication 

D – Division

A – Addition

S – Subtraction.

Example 1: Let’s use pemdas to evaluate the expression 

$100 − [(3 − 1) + (7 \times 8)]$

Step 1: Solve the brackets. Follow the order of solving round brackets $( )$ first, then curly brackets $\left\{ \right\}$, and then square brackets $[ ]$.

$= 100 − [(2) + (56)]$

$= 100 − 58$

Step 2: No exponent in the given expression.

Step 3: No multiplication or division in the given expression.

Step 4: Solve the subtraction.

$= 100 − 58$

$= 42$

Example 2: While we write the order in the above form, division or multiplication and addition or subtraction hold equal importance. This means that you can either take up multiplication first or division first.

Similarly, you can take either addition first or subtraction first. The answer will be the same. So, we usually try to solve these two from left to right.

Let’s solve the above example:

$4[2 + \left\{3(1 + 1) + 2\right\}]$

First, we start with the innermost bracket (the parentheses).

$= 4[2 + \left\{3(2) + 2\right\}]$

Now, we solve the braces or curly brackets.

$= 4[2 + \left\{6 + 2\right\}]$

$= 4[2 + 8]$

Then, we solve the square brackets.

$= 4[10]$

$= 40$

In summary:

Here is the order you can follow when multiple symbols are present in an equation:

If you come across parentheses in an equation, you will first look at the terms present within them. 

Let us understand this better with an example.

Take the problem: $9 − 10 \div 5 – 3 \times 2 + 7$

Let us solve this using the order of operations you have learned.

$= 9 − 10 \div 5 – 3 \times 2 + 7$

$= 9 − 2 − 3 \times 2 + 7$ (First, you divide)

$= 9 − 2 − 6 + 7$ (Then, you multiply)

$= 7 − 6 + 7$ (Then, you subtract)

$= 1 + 7$ (Then, you subtract)

$= 8$ (And finally, you add)

Now, let us look at the same problem with parentheses: 

$9 − 10 \div (5 − 3) \times 2 + 7$

You need to calculate the numbers within the parentheses first.

$= 9 − 10 \div 2 \times 2 + 7$ (Solve the expression inside the parentheses)

$= 9 − 5 \times 2 + 7$ (Divide)

$= 9 − 10 + 7$ (Multiply)

$= −1 + 7$ (Add)

$= 6$

Did you notice? The answer to the same equation changed because parentheses were present in the equation!

Point to Remember: If there are parentheses inside other parentheses, you solve the inner expression first.

Let us understand this with an example:

Simplify the expression $(2 + (3 \times 4))$

Here, we will solve the inner bracket first.

So, the expression will become $(2 + 12) = 14$

Note that it is highly recommended to write any mathematical equation or expression with proper use of parentheses, leaving no place for ambiguity. It is important to convey the intention behind writing the math operations and indicate which operations should be carried out first.

Solved Examples on Brackets

Question 1: Find the value of the expression: $(5 + 4) − (3 − 2)$.

Answer: The given expression is,

$(5 + 4) − (3 − 2)$,

Step 1: Solving the values in the brackets,

$(9) − (1)$,

Thus, the answer is $(9) − (1) = 8$.

Question 2: Find the value of the expression: $\left\{(7 − 2) \times 3\right\}  \div 5$

Answer: The given equation is,

$\left\{(7 − 2) \times 3\right\}  \div 5$

Step 1: Solving the parentheses 

$\left\{(7 − 2) \times 3\right\}  \div 5$

$= \left\{5 \times 3\right\} \div 5$

Solving the curly bracket

$= \left\{15\right\} \div 5$

$= 15 \div 5$

$= 3$

Question 3: Find the value of the expression: $(12 \div 6) \times (4 − 2)$

Solution:

The given equation is,

$(12 \div 6) \times (4 − 2)$ 

Solving the values in the brackets,

$(2) \times (2)$

Thus, the answer is $(2) \times (2) = 4$

Question 4: Find the value of the expression: $[120 + \left\{ (3 \times 4) + (4 − 2) − 1 \right\} + 20 ]$

Answer: Following the PEMDAS rule, first, 

Step 1: We solve the values in ( ) brackets,

$[120 + \left\{ (3 \times 4) + (4 − 2) − 1 \right\} + 20 ]$

$= [ 120 + \left\{ (12 ) + ( 2 ) − 1 \right\} + 20 ]$,

Now we solve the values inside the { } brackets,

$= [ 120 + \left\{ 13 \right\} + 20 ]$,

Finally, add all the values in the [ ] bracket,

The answer is 153.

Example 5: Simplify the expression: $(2 + 4 \times 6) − 4 + (2 \times 3)$

Solution: Start by solving the expressions inside the parentheses.

$= (2 + 24) − 4 + 6$ (Multiply inside the parentheses)

$= 26 − 4 + 6$ (Solve the terms inside the parentheses)

$= 22 + 6$ (Add)

$= 28$

Example 6: Simplify the expression: $( 2 \times (7 − 5)) − ((6 \div 3) + 4)$

Start by solving the innermost parentheses

$= (2 \times 2) − (2 + 4)$

$= 4 − 6$

$= − 2$

Example 7: Simplify the expression: $2 (3 + 5) + 8 (4 − 1)$

First, solve the expressions within the parentheses.

Here, the parentheses also denote a multiplication sign.

$= 2 \times 8 + 8 \times 3$

$= 16 + 24$

$= 40$

Example 8: If you have to solve the following equation, how will you proceed?

$2[1 − \left\{2(2 + 2) + 2\right\}]$

Solution: We solve the parentheses first:

$= 2[1 − \left\{2(4) + 2\right\}]$

$= 2[1 − \left\{8 + 2\right\}]$

Now, we solve the braces:

$= 2[1 − \left\{10\right\}]$

Finally, we solve the square brackets:

$= 2[ −9]$

$= −18$

Example 9: How would you solve the following equation?

$4\left\{5(4 + 2) + 1\right\}$

Solution: First, we solve the parentheses:

$= 4\left\{5(6) + 1\right\}$

Now, we need to solve the curly brackets. But within these brackets, we have to solve multiplication and addition.

So, we multiply first and then add:

$= 4 \left\{30 + 1\right\}$

$= 4 \left\{31\right\}$

Finally, we multiply 4 with the value inside the braces:

$= 124$

Example 10: What is the process you will follow to solve an equation with more than one parentheses?

$20 \div \left\{1(2 + 2) + (3 + 3)\right\}$

Solution: We will start by solving the equations within the parentheses:

$= 20 \div \left\{1(4) + (3 + 3)\right\}$

$= 20 \div \left\{1(4) + (6)\right\}$

Now, we have to solve the equation within the braces, but we have multiplication within the curly brackets, so we will solve that first:

 $= 20 \div \left\{4 + (6)\right\}$

$= 20 \div \left\{10\right\}$

$= 2 \div 1$

$= 2$

Practice Problems on Brackets

Brackets

Attend this Quiz & Test your knowledge.

1

Solve: $[\left\{(2^{2} + 3^{3}) \times 4^{2}\right\} − (20 \div 5)]$

490

492

494

500

Correct

Incorrect

Correct answer is: 492
Step 1: Solve all brackets keeping the precedence in mind.
$[\left\{(2^{2} + 3^{3}) \times 42\right\} − (20 \div 5)]$
$= [\left\{(4 + 27) \times 16\right\} − (4)]$
$= [\left\{(31) \times 16\right\} − (4)]$
$= [{31 \times 16} − 4]$
$= [496 − 4]$
$= 492$

2

What is the right representation of the order of operation in brackets?

$( \left\{ [ ] \right\} )$

$[ ( \left\{ \right\} ) ]$

$\left\{ [ ( ) ] \right\}$

$[ \left\{ ( ) \right\} ]$

Correct

Incorrect

Correct answer is: $[ \left\{ ( ) \right\} ]$
$[ \left\{ ( ) \right\} ]$ is the correct representation of order of operation in brackets.

3

$\Biggr [\bigg\{ \bigg( \frac{1}{2} \bigg)^2 \bigg\}^{-3} \Biggr]^2$

4,096

64

256

1,024

Correct

Incorrect

Correct answer is: 4,096
$\Biggr[\bigg\{ \bigg(\frac{1}{2}\bigg)^{2}\bigg\}^{-3}\Biggr]^{2} = \Biggr[\bigg\{\frac{1}{4}\bigg\}^{-3}\Biggr]^{2} = \Biggr[\bigg\{\frac{4}{1}\bigg\}^{3}\Biggr]^{2} = [64]^{2} = 4,096$

4

Solve this expression, $12 + (5 + 3)$,

18

20

16

8

Correct

Incorrect

Correct answer is: 20
$12 + (5 + 3) = 12 + 8 = 20$

5

Simplify the expression: $(3 + 2 \times 8) – 4 + (5 \times 7)$

45

50

24

40

Correct

Incorrect

Correct answer is: 50
We know that the equation within the parentheses is solved first.
So, $19 – 4 + 35 = 50$

6

Simplify the expression: $( 4 \times (6 – 2)) – ((8 \div 2) + 5 )$

7

2

17

10

Correct

Incorrect

Correct answer is: 7
We know that the equation within the parentheses is solved first.
So, $( 4 \times 4) – ( 4 + 5)$
$16 – 9 = 7$

7

Simplify the expression: $4 (3 + 2) + 4 (7 – 2)$

10

50

20

40

Correct

Incorrect

Correct answer is: 40
We know that parentheses also denote multiplication.
So, $4 \times 5 + 4 \times 5$
$20 + 20 = 40$

8

Solve the equation containing braces in math.
$57 \div \left\{5 + (4 \times 2) + (3 + 3)\right\}$

3

4

13

4

Correct

Incorrect

Correct answer is: 3
After solving the $( )$, we perform addition within the $\left\{ \right\}$, and then divide. $57 \div {5 + (4 2) + (3 + 3)} = 57 {5 + 8 + 6} = 57 19 = 3$

9

Which of the following examples use braces, brackets, and parentheses correctly?

60 $\div$ [(2 $\times$ 2) + (3 + 3)}

60 $\div$ {(2 $\times$ 2) + (3 + 3)}

60 $\div$ {[2 $\times$ 2] + (3 + 3)}

(60 $\div$ {[2 $\times$ 2] + (3 + 3})

Correct

Incorrect

Correct answer is: 60 $\div$ {(2 $\times$ 2) + (3 + 3)}
It uses the braces, brackets, and parentheses correctly because the innermost brackets have parentheses and then braces.

10

If we have the following expressions inside the curly brackets, which of the expressions would you solve first?
$10\left\{(\frac{4}{2}) + (6 \times 2) – (3 + 3) + (7 – 2)\right\}$

$(\frac{4}{2})$

$(\frac{4}{2}) \text{or} (6 \times 2)$

Any parentheses inside the $\left\{ \right\}, (\frac{4}{2}), (6 \times 2), (3 + 3), (7 – 2)$}

None of the above

Correct

Incorrect

Correct answer is: Any parentheses inside the $\left\{ \right\}, (\frac{4}{2}), (6 \times 2), (3 + 3), (7 – 2)$}
We can solve any of the parentheses inside the curly brackets first. Once these parentheses are solved, we have to simply add and subtract, which can be done in any order.

Frequently Asked Questions on Brackets

Why are brackets important in mathematics?

Brackets are very important parts of a mathematical equation; they separate different mathematical expressions from each other and help set the priority for expressions that need to be solved first.

Is PEMDAS the only method to solve bracket problems?

BODMAS is a different acronym for PEMDAS, where B stands for Bracket, O for Of or Exponents, D for Division, M for Multiplication, A for Addition, and S for Subtraction. Any expression is considered correctly solved if they have followed the PEMDAS or BODMAS rule.

Are there any more kinds of brackets?

Angle Brackets are also used in various mathematical expressions; they are represented with〈 〉. The angle brackets are used to represent a list of numbers or a sequence of numbers.

What are some other applications of brackets?

Brackets are also used to define the coordinates of a point on a map or to describe the variable of a function.

Are parentheses the same as braces?

No. Parentheses denoted by ( ) are different from braces { }. They have distinct uses in math. They are used in nesting expressions. You will learn more about them later.

Is there another name for parentheses?

Yes. Sometimes, parentheses are also called round brackets.

What are { } called?

These are curly brackets, also known as braces in math. Braces are used in math equations when we are making at least two nested groups for calculation.

In which other ways can we use braces besides in math equations?

Braces are also used to define a set.

For example, $\left\{3, 5, 7, 9, 10\right\}$ means a set containing the numbers 3, 5, 7, 9, 10.

Do braces mean multiplication?

Yes, braces can also mean multiplication. You need to multiply the value outside the braces by the value inside the braces.

Take this equation as an example: $2\left\{2(4 + 2) + 1\right\}$

Here, 2 will be multiplied by the answer inside the curly brackets or braces.

How does brackets work?

What are Brackets in Math? Definition, Types, Examples & Uses

Want more information on silver fabric emf, thermal conductivity of fabric, functional yarns? Feel free to contact us.