Name: Achmad Fahry Baihaki
NIM: 2206065110100
Institute: Maulana Malik Ibrahim Islamic State University of Malang
Departement: Computer Science
Lecturer: Prof. Dr. Suhartono, M.Kom


In R language we can also use arithmetic functions to solve complex calculations in mathematic.

There are many kinds of arithmetic functions that we can used in R language, including:

1. Logarithm

Logarithm is the inverse function to exponentiation. Formula: \(logb = (b^{x}\)) = x

Examples:

log2(16) # Logarithm base 2 for 16 (2^4)
## [1] 4
log2(1024) # Logarithm base 2 for 16 (2^10)
## [1] 10
2. Exponential

Example:

exp(10) # Exponential for 10
## [1] 22026.47
3. Trigonometry

Trigonometry studies relationships between side lengths and angles of triangles. Like sin, cos, tan, etc.

Example:

x = 1

sin(x) # sin 1
## [1] 0.841471
cos(x) # cos 1
## [1] 0.5403023
tan(x) # tan 1
## [1] 1.557408
asin(x) # arc-sin 1
## [1] 1.570796
acos(x) # arc-cos 1
## [1] 0
atan(x) #arc-tan 1
## [1] 0.7853982

In pracma package, trigonometry functions can be extended. The functions including:

library(pracma)
## Warning: package 'pracma' was built under R version 4.2.2
a = 1

cot(a) # cotan 1
## [1] 0.6420926
csc(a) # cosecan 1
## [1] 1.188395
sec(a) # secan 1
## [1] 1.850816
acot(a) # arc-cotan 1
## [1] 0.7853982
acsc(a) # arc-cosecan 1
## [1] 1.570796
asec(a) # arc-secan 1
## [1] 0
4. Hyperbolic

In mathematics, hyperbolic functions are analogues of the ordinary trigonometric functions, but defined using the hyperbola rather than the circle.

Example:

cosh(x) 
## [1] 1.543081
sinh(x)
## [1] 1.175201
tanh(x)
## [1] 0.7615942
acosh(x)
## [1] 0
asinh(x)
## [1] 0.8813736
atanh(x)
## [1] Inf

In pracma package, hyperbolic functions can be extended. The functions including:

library(pracma)

coth(x)
## [1] 1.313035
csch(x)
## [1] 0.8509181
sec
## function (z) 
## {
##     stopifnot(is.numeric(z) || is.complex(z))
##     1/cos(z)
## }
## <bytecode: 0x000001d568155dd0>
## <environment: namespace:pracma>
acoth(x)
## [1] Inf
acsch(x)
## [1] 0.8813736
asech(x)
## [1] 0
5. Other Math Functions
  1. Absolute (non-negative value (|x| = x))

Example:

abs(-100)
## [1] 100
  1. Square Root ( a factor of a number that, when multiplied by itself, gives the original number (\(y^{2}\) = x))

Example:

sqrt(9) 
## [1] 3