I hear logarithms mentioned quite a lot in the programming context. They seem to be the solution to many problems and yet I can't seem to find a real-world way of making use of them. I've read the Wikipedia entry and that, quite frankly, leaves me none the wiser.
So, where can I learn about the real-world programming problems that logarithms solve? Has anyone got any examples of problems they faced that were solved by implementing a logarithm?
Logarithms are used for measuring the magnitude of earthquakes. Logarithms are used for measuring the noise levels in dBs (decibels). They are used to measure the pH level of chemicals. Logarithms are used in radioactivity, mainly to detect the half life of a radioactive element.
Explanation: One of the properties of logs is the ability to cancel out terms based on the base of the log. Since the base of the log is 10 we can simplify the 100 to 10 squared. The log base 10 and the 10 cancel out, leaving you with the value of the exponent, 2 as the answer.
Logarithms in programming are also frequently used in describing the efficiency of an algorithm using Big O notation.
For instance, a binary search algorithm would have a worst case scenario of O(log(n)) (on a sorted set), whereas a linear search's worst case is O(n)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With