Given a positive number x, the task is to find the natural log (ln) and log to the base 10 (log10) of this number with the help of expansion.
Input: x = 5 Output: ln 5.000 = 1.609 log10 5.000 = 0.699 Input: x = 10 Output: ln 10.000 = 2.303 log10 10.000 = 1.000
- The expansion of natural logarithm of x (ln x) is:
- Therefore this series can be summed up as:
- Hence a function can be made to evaluate the nth term of the sequence for 1 ≤ x ≤ n
- Now to calculate log10 x, below formula can be used:
Below is the implementation of the above approach:
ln 5.000 = 1.609 log10 5.000 = 0.699
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Program to calculate the value of sin(x) and cos(x) using Expansion
- Middle term in the binomial expansion series
- Program to print binomial expansion series
- Sum of the Tan(x) expansion upto N terms
- Sum of N terms in the expansion of Arcsin(x)
- Find subsequences with maximum Bitwise AND and Bitwise OR
- Find the radii of the circles which are lined in a row, and distance between the centers of first and last circle is given
- Find the side of the squares which are lined in a row, and distance between the centers of first and last square is given
- Find minimum possible values of A, B and C when two of the (A + B), (A + C) and (B + C) are given
- Find the number of words of X vowels and Y consonants that can be formed from M vowels and N consonants
- Find smallest positive number Y such that Bitwise AND of X and Y is Zero
- Find two integers A and B such that A ^ N = A + N and B ^ N = B + N
- Find a number X such that (X XOR A) is minimum and the count of set bits in X and B are equal
- Program to find if two numbers and their AM and HM are present in an array using STL
- Find a number M < N such that difference between their XOR and AND is maximum
- Find the largest multiple of 2, 3 and 5
- Find n'th number in a number system with only 3 and 4
- Legendre's formula (Given p and n, find the largest x such that p^x divides n!)
- Find smallest values of x and y such that ax - by = 0
- Find the Largest number with given number of digits and sum of digits
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.