Logarithmic function is the inverse to the exponential function. A logarithm to the base b is the power to which b must be raised to produce a given number. For example, is equal to the power to which 2 must be raised to in order to produce 8. Clearly, 2^3 = 8 so = 3. In general, for b > 0 and b not equal to 1.
Fact about Logarithm :
- Logarithms were quickly adopted by scientists because of various useful properties that simplified long, tedious calculations.
- Logarithm to base 10 (that is b = 10) is called the common logarithm and has many applications in science and engineering.
- Natural logarithm, is a logarithm with base e. It is used in mathematics and physics, because of its simpler derivative.
- Binary logarithm is a logarithm with base 2 and is commonly used in computer science.
Laws of Logarithms :
How to find logarithm of number?
The idea is to create a function that calculates and returns . For example, if n = 64, then your function should return 6, and if n = 129, then your function should return 7.
Time complexity: O(log n)
Auxiliary space: O(log n) if the stack size is considered during recursion otherwise O(1)
Practice problems on Logarithm:
Question 1: Find the value of x in equation given 8x+1 – 8x-1 = 63
Solution: Take 8x-1 common from the eq.
It reduce to
8x-1(82 – 1) = 63
8x-1 = 1
Hence, x – 1 = 0
x = 1
Question 2: Find the value of x for the eq. given log0.25x = 16
Solution: log0.25x = 16
It can be write as
x = (0.25)16
x = (1/4)16
x = 4-16
Question 3: Solve the equation log121728 x log96561
Solution: It can be written as
log12(123) x log9(94)
= 3log1212 x 4log99
= 3 x 4 = 12
Question 4: Solve for x
logx3 + logx9 + logx27 + logx81 = 10
Solution: It can be write as
logx(3 x 9 x 27 x 81) = 10
logx(31 x 32 x 33 x 34) = 10
logx(310) = 10
10 logx3 = 10
then, x = 3
Question 5: If log(a + 3 ) + log(a – 3) = 1 ,then a=?
Solution: log10((a + 3)(a – 3))=1
log10(a2 – 9) = 1
(a2 – 9) = 10
a2 = 19
a = √19
Question 6: Solve 1/logab(abcd) + 1/logbc(abcd) + 1/logcd(abcd) + 1/logda(abcd)
=logabcd(ab) + logabcd(bc) + logabcd(cd) + logabcd(da)
=logabcd(ab * bc * cd * da)
Question 7: If xyz = 10 , then solve log(xn yn / zn) + log(yn zn / xn) + log(zn xn / yn)
log(xn yn / zn * yn zn / xn * zn xn / yn)
= log xn yn zn
= log10 10n
Question 8: Find (121/10)x = 3
Solution: Apply logarithm on both sides
log(121/10)(121/10)x = log(121/10)3
x = (log 3) / (log 121 – log 10)
x = (log 3) / (2 log 11 – 1)
Question 9: Solve log(2x2 + 17)= log (x – 3)2
log(2x2 + 17)= log (x2 – 6x + 9)
2x2 + 17 = x2 – 6x + 9
x2 + 6x + 8 = 0
x2 + 4x + 2x + 8 = 0
x(x + 4) + 2(x + 4) = 0
(x + 4)(x + 2)=0
Question 10: log2(33 – 3x)= 10log(5 – x). Solve for x.
Solution: Put x = 0
log2(33 – 1)= 10log(5)
log232 = 5
5 log2 2 = 5
5 = 5
LHS = RHS
More problems related to Logarithm :
- Find minimum number of Log value needed to calculate Log upto N
- Find maximum among x^(y^2) or y^(x^2) where x and y are given
- Print all substring of a number without any conversion
- Program to compare m^n and n^m
- Find larger of x^y and y^x
- Iterated Logarithm log*(n)
- Discrete logarithm (Find an integer k such that a^k is congruent modulo b)
- Check if the sum of digits of number is divisible by all of its digits
- Program for Mobius Function | Set 2
- Make the list non-decreasing by changing only one digit of the elements
- Maximum items that can be bought with the given type of coins
- Count occurrences of a prime number in the prime factorization of every element from the given range
- Check if the number is valid when flipped upside down
- Find the count of subsequences where each element is divisible by K
- Count of numbers below N whose sum of prime divisors is K
- Queries for the smallest and the largest prime number of given digit
- Find two co-prime integers such that the first divides A and the second divides B
- Find a Square Matrix such that sum of elements in every row and column is K
- Divide first N natural numbers into 3 equal sum subsets
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.