Logarithmic and Power Functions in R Programming
Logarithm and Power are two very important mathematical functions that help in the calculation of data that is growing exponentially with time.
First is the Logarithm, to which the general way to calculate the logarithm of the value in the base is with the
log() function which takes two arguments as value and base, by default it computes the natural logarithm and there are shortcuts for common and binary logarithm i.e. base 10 and 2. Value can be number or vector.
Second is the Power, to calculate a base number raised to the power of exponent number. In this article, there are three methods shown to calculate the same i.e. baseexponent.
Log Function in R
It is the inverse of the exponential function, where it represents the quantity that is the power to the fixed number(base) raised to give the given number. It returns the double value.
If y = bx
then logby = x
if 100 = 102 then log10100 = 2
List of various
The number is numeric or complex vector and the base is a positive or complex vector with the default value set to exp(1).
- The log function [log(number)] in R returns the natural logarithm i.e. base e.
log(10) = 2.302585
- [log10(number)] function returns the common logarithm i.e. base 10.
log10(10) := 1
- [log2(number)] returns the binary logarithm i.e. base 2.
log2(10) := 3.321928
- [log(number, b)] return the logarithm with base b.
log(10, 3) := 2.095903
- [log1p(number)] returns log(1+number) for number << 1 precisely.
log1p(10) := 2.397895
- [exp(number)] returns the exponential.
exp(10) := 22026.47
- [expm1(number)] returns the exp(number)-1 for number <<1 precisely.
expm1(10) := 22025.47
 2.302585  1  3.321928  2.095903  2.397895  22026.47  22025.47
If there two numbers base and exponent, it finds x raised to the power of y i.e. xy.
It returns double value. It needs two arguments:
x = floating point base value y = floating point power value
103 = 10*10*10 = 1000
 1000  1000  1000