Udemy | Introductory Programming Course | Math Prerequisite
Functions and Logarithms
Prerequisites for Programming and Algorithms
If you have not visited the sets and Relations concept, please go through them to brush up on terms and mathematical phrases that we would be using here.
Functions are a special type of relation where
input set and output set are non-empty
each element of the first set or input set has precisely one output from the second set.
f(a) = b where a ∈ A (input set/domain) and b ∈ B output set/co-domain)
Domain refers to the input set and codomain refers to the output set.
There are many different types of Functions but the ones that are of utmost importance are:
- One-one Function (Injective Function)
- Many-one Function
- Onto Function (Surjective Function)
- Into Function
- Modulus Function
- Signum Function
- Greatest Integer Function
- Fractional Part Function
- Even and Odd Function
- Periodic Function
- Constant Function (x=k or y = k where k is a constant)
- Identity Function (y=x)
Logarithms:
To understand logarithms, you need to ask yourself the question,
what exponent is required to achieve the output for a certain base?
we know that 2 × 2 × 2 × 2 × 2 = 32 then what would be? here
2^? = 32 (2 is the base and 32 is the product)
Logarithms/Logs answer this question. Hence Logarithms are a special type of function that finds the exponent from the base and product. They are also known as the inverse of exponentiation. In exponentiation you find the product and in logs you need to find the exponent.
log2(32) = x -> log2(32) = 5
You also need to learn about the natural number e.
e = 2.718 (Euler’s Number)
Here is a logarithmic graph of base e with horizontal and vertical assymptotes.
Logarithms have several useful properties.
A few of the main ones are here:
Product Rule: log a (mn) = log a (m) + log a (n)
Quotient Rule: log a (m/n) = log a (m) — log a (n)
Power Rule: log a (m)^n = n × log a (m)
Change Of Base Rule: log n (m) = log p (m)/ log p (n)
Reciprocal Rule: log n (m) = 1 / log m (n)
Hope this cleared the basics of Functions and Logarithms. In the next article I will be covering more on Counting and Probability.