# Tagged: R Mathematical Expression

## Mathematical Expressions used in Math Word Problems

To solve any mathematical problem, it is important to understand and know the mathematical meaning of the words used in the problem. Many mathematical expressions or even general expressions have the same meaning and may indicate a relationship between quantities or a mathematical operation (such as addition, subtraction, multiplication, and division).

Equality Expressions

All of the following expressions represents that two quantities are equal (=).

• is equal to (or equals)
• is the same as
• the result is
• yields
• gives

For example, 2+5 is equal to 7.

Note: The word “is” is also used to mean “equals”. For example, 8 is 5 more than 3, or 8 equal 5 + 3.

All of the following expression shows that the number $X$ and $Y$ are added

Subtraction Expressions

All of the following expressions show that the number $Y$ is to be subtracted from the number $X$

Multiplication Expressions

The following expression can be used if the numbers $X$ and $Y$ need to be multiplied.

For multiplication of two or more numbers symbol $\times$ or $\cdot$ is used. In algebra, a number before a variable is a coefficient, such as $4Y$ means 4 times $Y$, where 4 is coefficient.

Division Expressions

All of the following expression indicate the division of the numbers $X$ and $Y$ (in the order $X \div Y$.

## Using R as Calculator

In the Windows Operating system, The R installer will have created an icon for R on the desktop and a Start Menu item. Double click the R icon to start the R Program; R will open the console, to type the R commands.

The greater than sing (>) in the console is the prompt symbol. In this tutorial, we will use the R language as a calculator (we will be Using R as a Calculator for mathematical expressions), by typing some simple mathematical expressions at the prompt (>). Anything that can be computed on a pocket calculator can also be computed at the R prompt. After entering the expression on prompt, you have to press the Enter key from the keyboard to execute the command. Some examples using R as a calculator are as follows

> 1 + 2   #add two or more numbers
> 1 – 2   #abstracts two or more numbers
> 1 * 2   #multiply two or more numbers
> 1 / 2   #divides two more more numbers
> 1%/ %2   #gives the integer part of the quotient
> 2 ^ 1   #gives exponentiation
> 31 %% 7   #gives the remainder after division

These operators also work fine for complex numbers.

Upon pressing the enter key, the result of the expression will appear, prefixed by a number in square bracket:
> 1 + 2
 54

The  indicates that this is the first result from the command.

Some advanced calculations that are available in scientific calculators can also be easily done in R for example

> sqrt(5)   #Square Root of a number
> log(10)   #Natural log of a number
> sin(45)   #Trignometric function (sin function)
> pi   #pi value 3.141593
> exp(2)   #Antilog, e raised to a power
> log10(5)   #Log of a number base 10
> factorial(5)   #Factorial of a number e.g 5!
> abs(1/-2)   #Absolute values of a number
> 2*pi/360   #Number of radian in one Babylonian degree of a circle

Remember R prints all very large or very small numbers in scientific notation.

R language also makes use of parentheses for grouping operations to follow the rules for order of operations. for example

> 1-2/3   #It first computes 2/3 and then subtracts it from 1
> (1-2)/3   #It first computes (1-2) and then divide it by 3

R recognizes certain goofs, like trying to divide by zero, missing values in data, etc.

> 1/0   #Undefined, R tells it an infinity (Inf)
> 0/0   #Not a number (NaN)
> “one”/2   #Strings or character is divided by a number