I couldn't think of an algorithm that may be able to do Log base n, I tried googling, still can not find one.
SO, Find an algorithm to calculate Logarithm.
Programming LOGARITHM
Moderators:Labib, bristy1588
-
- Posts:29
- Joined:Thu Jun 02, 2016 6:14 pm
EARLY TO BED AND EARLY TO RISE,MAKES A MAN HEALTHY,WELTHY AND WISE.[\color]
- Anindya Biswas
- Posts:264
- Joined:Fri Oct 02, 2020 8:51 pm
- Location:Magura, Bangladesh
- Contact:
Re: Programming LOGARITHM
Try this:
If $y=10^{n+\frac{a_1}{10}+\frac{a_2}{10^2}+\cdots}$ where $a_1,a_2,\cdots$ are digits, then $n.a_1a_2\cdots=\log_{10}{y}$. Now $n$ is simply the number of times you have to divide $y$ to get a number greater than or equal to $1$ and less than $10$. Here is a recursive relationship to get $1$ digit at a time:
If $10^{n+\frac{a_1}{10}+\frac{a_2}{10^2}+\cdots}=y$
Then $10^{a_1+\frac{a_2}{10}+\frac{a_3}{10^2}+\cdots}=\left(\frac{y}{10^{n}}\right)^{10}$
Now use the same method to find $a_1, a_2,\cdots$ as used to find $n$.
If $y=10^{n+\frac{a_1}{10}+\frac{a_2}{10^2}+\cdots}$ where $a_1,a_2,\cdots$ are digits, then $n.a_1a_2\cdots=\log_{10}{y}$. Now $n$ is simply the number of times you have to divide $y$ to get a number greater than or equal to $1$ and less than $10$. Here is a recursive relationship to get $1$ digit at a time:
If $10^{n+\frac{a_1}{10}+\frac{a_2}{10^2}+\cdots}=y$
Then $10^{a_1+\frac{a_2}{10}+\frac{a_3}{10^2}+\cdots}=\left(\frac{y}{10^{n}}\right)^{10}$
Now use the same method to find $a_1, a_2,\cdots$ as used to find $n$.