Chapter 2 Operators

The basic arithmetic operations are

+, -, *, /

Decimals are declared with a “.”, not a comma

1.8 not 1,8

Exponents are declared with ^, i.e. \(2^3\) is written as

2^3

For mathematical calculations, only parentheses can be used. ()

Frequently used mathematical functions are

sqrt()            # square root
exp()             # exponential function
log()             # nat.  Logarithm
log(...,10)       # Logarithm with Base 10
abs()             # absolute value
round(...,x)      # rounding to x decimals.
pi 
exp(1)            # Eulers number
sin(),cos(),tan() # trigonemetric functions
min(), max()      # returns the lowest/highest value of a vector/matrix

Enter the following calculations and understand the command

 1.8+2
 1.8-2
 1.8*2
 1.8/2
 2+2*3
 (2+2)*3
 2^3
 8^(1/3)
 3^2
 9^0.5
 2^2*2+2
 2^(2*((0.2+0.3)*(1+2)))+4
 sqrt(2)
 exp(1)
 exp(2)
 log(7.389056)
 log(exp(3))
 log(100,10)
 abs(1.8-2)
 round(sqrt(2),2)
 round(sqrt(2),4)
 pi
 sin(pi/2)
 sin(pi/2)
 sin(pi)
 tan(pi)
 x=2+3i
 y=4+1i
 x
 y
 x+y
 x*y

Attention:

 1.224606e-16

is interpreted as $ 1.224606 10^{-16}$. This is often exactly zero, but for internal memory purposes (R only has up to 16 decimals), can be a rounding mistake.