How to Find Logs: Algorithms & Binary Search

  • Thread starter madmike159
  • Start date
In summary, a logarithm is the inverse function of an exponential and is used to find the power to which a base number must be raised to equal a given number. The most common algorithm used to find logarithms is the binary search algorithm, which involves repeatedly dividing the search interval in half until the value is found. Binary search is used because of its efficiency, with a time complexity of O(log n). To use this algorithm, the base and target number must be determined and the search interval is divided in half until the target number is found. Other algorithms for finding logarithms include Newton's method and the bisection method, but binary search is the most widely used and efficient.
  • #1
madmike159
Gold Member
371
0
How do computers find log values, is there some sort of algorithm to find it or do they just use binary search?
 
Last edited:
Mathematics news on Phys.org
  • #2
I found this by Google which seemed interesting:

http://en.literateprograms.org/Logarithm_Function_(Python)

You might be able to find the code in the math.h source code. Most floating point operations are going to go through the processor, but there's probably some legacy junk in there that gets left out at compile time for computers that existed before coprocessors became common.
 
  • #3
Ok thanks.
 

1. What is a logarithm?

A logarithm is the inverse function of an exponential. It is used to find the power to which a base number must be raised to equal a given number.

2. How do I find logarithms using an algorithm?

The most common algorithm used to find logarithms is the binary search algorithm. This algorithm involves repeatedly dividing the search interval in half and checking which half the target value lies in until the value is found.

3. Why is binary search used for finding logarithms?

Binary search is used for finding logarithms because it is a highly efficient algorithm with a time complexity of O(log n). This means it can find the logarithm of a number in a very short amount of time, even for large numbers.

4. What is the process for using binary search to find a logarithm?

To use binary search to find a logarithm, you first need to determine the base and the target number. Then, you divide the search interval in half and check if the target number is larger or smaller than the result of the logarithm function using the midpoint as the exponent. You continue this process until the target number is found.

5. Are there any other algorithms for finding logarithms?

Yes, there are other algorithms for finding logarithms such as Newton's method and the bisection method. However, binary search is the most commonly used and efficient algorithm for finding logarithms.

Similar threads

Replies
9
Views
1K
Replies
10
Views
1K
  • General Math
Replies
5
Views
1K
Replies
1
Views
1K
  • General Math
Replies
5
Views
843
Replies
3
Views
2K
Replies
16
Views
1K
Replies
6
Views
2K
Replies
24
Views
2K
Replies
7
Views
587
Back
Top