Arithmetic Operations
You can do arithmetic with Mathematica just as you would on an electronic calculator.
Arithmetic operations in Mathematica.
Operator
+ (add)
-( minus)
*( multiply)
Space(multiply)
/( divide)
^( power)
Mod
+ is the sum of two numbers.
In[1]:= 2.3 + 5.63
Out[1]= 7.93
- is the subtraction of two numbers.
+ is the sum of two numbers.
In[1]:= 10 -5
Out[1]= 5
Spaces denote multiplication in Mathematica. You can use a * for multiplication if you
want to.
In[3]:= 2 3 4
Out[3]= 24
In[3]:= 2*3*4
Out[3]=
Here the / stands for division, and the ^ stands for power.
In[2]:= 2.4 / 8.9 ^ 2
Out[2]= 0.0302992
In[6]:= 2.4 ^ 45
Out[6]= 1.28678X1017
This result is given in scientific notation.
Arithmetic operations in Mathematica are grouped according to the standard
mathematical conventions. As usual, 2 ^ 3 + 4, for example, means (2 ^ 3) + 4, and not 2
^ (3 + 4). You can always control grouping by explicitly using parentheses.
You can type arithmetic expressions with parentheses.
In[4]:= (3 + 4) ^ 2 - 2 (3 + 1)
Out[4]= 41
Spaces are not needed, though they often make your input easier to read.
In[5]:= (3+4)^2-2(3+1)
Out[5]= 41
You can enter numbers in scientific notation like this.
In[7]:= 2.3 10^70
Out[7]= 2.3X1070
Or like this. In[8]:= 2.3*10^70
Out[8]= 2.3*1070
RELATIONAL AND LOGICAL OPERATORS
Relational operators (comparison operators) compare two numbers and determine whether the comparing statement is
"true" ("correct") or "false" ("incorrect"). Logical operators examine expressions whose values may be true or false.
Relational and logical operators can be used in mathematical expressions, and are often used in combination with other
operators when making management related decisions during the execution of the program.