2. Simple Mathematics

You can use MATLAB as a calculator. Firstly, we will perform simple arithmetic using the operations + (addition), - (subtraction), * (multiplication), / (division), ^ (raise to a power, or exponentiation). We will also include parentheses (brackets).

Enter the MATLAB Command Window. Type in each of the following arithmetic expressions after the >> prompt and press the Enter key at the end of each line. Before doing so, mentally calculate the answer you expect to see in each case.

(7+6)/(10-2)

7+6/(10-2)

7+6/10-2


9+(6*2)/(3*4)

9+6*2/(3*4)

9+6*2/3*4


1.00001^100000

You will notice that the last expression is very close to the exponential number e. This will be explained later in lectures.

Some students are unsure of the use of parentheses (brackets). They often use many unnecessary brackets, thereby making expressions hard to interpret. But other students omit brackets when they are absolutely needed. The order in which these operations are evaluated in a given expression is given by the usual rules of precedence, which can be summarised as follows:

Expressions are evaluated from left to right, with the power operation having the highest order of precedence, followed by both multiplication and division having equal precedence, followed by both addition and subtraction having equal precedence. Brackets can be used to alter this usual ordering.