Solved

# Logarithm

Posted on 2011-03-17
362 Views
Hi experts,
What is the application of logarithm and where to use it and give an example of a problem which we can solve using basic arithmatic(addition,mul,sub,etc...) and solving same problem using logarithm.I am not too skill in maths.Please help me with a good example for logarithm.

Regards,
Vimal.
0
Question by:vimalalex
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• 8
• 4
• 3
• +2

LVL 10

Expert Comment

ID: 35159458
I'm not sure that a problem which is solved with logs is also going to be solved with simple arithmetic.

It's not quite what you are after, but a great example of logarithms is in the news right now - earthquakes are measured on a log scale.

Although the official measurement of quakes is done on the Moment magnitude Scale, ( http://en.wikipedia.org/wiki/Moment_magnitude_scale ), the media still like to report using the old Richter magnitude scale ( http://en.wikipedia.org/wiki/Richter_magnitude_scale ) - probably because more people have heard of it.

The energy released by an earthquake, which closely correlates to its destructive power, scales with the power of 1.5 of the shaking amplitude. A difference in magnitude of 1.0 is equivalent to a factor of 31.6 in the energy released; a difference in magnitude of 2.0 is equivalent to a factor of 1000 in the energy released.

So the difference between the 8.9 size quake in Japan and the recent 6.3 size quake in New Zealand is 8.9-6.3=2.6, so the difference in destructive power is (inverse log 2.6) to the power of 1.5 - which gives an answer of nearly 8000x the destructive force in the recent Japan quake!

By the way, inverse log of x = 10 to the power of x.
0

LVL 37

Expert Comment

ID: 35159559
Let's say you have a tournament (with lots of teams) and you want to find out how many rounds there have to be. Each round removes half the group, so you could divide the number by 2 over and over until you get to <1 and count the divisions, or you could just use log. (Log base 2 of course).
Example:
65536 teams
/2 = 32768
/2 = 16384
/2 = 8192
/2 = 4096
/2 = 2048
/2 = 1024
/2 = 512
/2 = 256
/2 = 128
/2 = 64
/2 = 32
/2 = 16
/2 = 8
/2 = 4
/2 = 2
/2 = 1

=16 rounds
log2(65536) = 16. Done!
0

LVL 37

Expert Comment

ID: 35159576
If you don't have log2 you can use ln(x)/ln(2)
ln(65536)/ln(2) = 16
0

LVL 7

Expert Comment

ID: 35163708
Hi,

as mentioned shortly above, logarithms can play role wherever exponential functions are used.

It's application could be useful when solving some population-related problems.

Consider a single-cell organism, which replicates itself every minute. To solve the question of how many cells will there be after t = 100 minutes you can use following formula: 2^t = 2^100.

To solve an inverse problem: determine the time needed to reaching the number of 1.000.000 cells. Here's where the logarithm will be the way to go:

2^t = 1.000.000 where the variable t is unknown. following formula solves this: t = log2(1.000.000) = ln(1.000.000)/ln(2)
0

LVL 21

Expert Comment

ID: 35167458
As an example of the use of logarithms, take a look at a slide ruler.  By having bars in logarithmic scales, you can multiply by adding.  That is, adding logarithms together can give you the product of the original numbers.
0

LVL 2

Author Comment

ID: 35167885
Hi All,
I am a C++ programmer we have direct functions in c++ for finding logarithms. From the above comments I understand that when ever we are dealing with exponential  operations we can use logarithm. But I think we have solve the exponential  operations with out log also.For example
as TommySzalapski's example we can solve the same problem by doing LCM. I want to know the complexity of the TommySzalapski's example or the other examples mentioned above all comments which will take less time for do the job. How internally logarithm solves this problems what type of algorithm they are using. Since I am a programmer while designing a program i need to choose a less complexity method.

Thanks & Regards,
Vimal.
0

LVL 21

Expert Comment

ID: 35167935
Suppose you are dealing with audio frequencies and you want to jump up one octave.  That is an easy matter of just doubling the frequency.  Suppose instead that you want to write a function that allows you to jump up an arbitrary number of octaves, not necessarily integral.  Logarithms will make that much easier.
0

LVL 37

Expert Comment

ID: 35167966
Well, log base 2 can be computed in O(lg(lg(n))) time (which is rediculously fast, it takes 5 instruction sets to compute for numbers in the 4000000000 range).

Wikipedia has one version (you can make it a bit faster by hard coding more).
http://en.wikipedia.org/wiki/Binary_logarithm

Since logs can be converted easily (log10(x) = log2(x)/log2(10)) then you can do any logarithm by using log 2 and then dividing by a constant. So all logarithms have a complexity of O(lg(lg(n))).
0

LVL 2

Author Comment

ID: 35167990
Hi CompProbSolv,
Thanks for your precious reply.See in c++ by calling a single api log() we can achieve
the doubling the frequency or exponential operations but what my doubt is what is the internal concept of logarithm what type of maths operation they are using (+,-,/,*,etc). Why i am asking is in c++ application especially signal processing as you said performance is the main factor so before choosing a method we need to know its details. Now i am developing a software dealing with dsp. I think you can guide me for this doubt.

Thanks & regards,
Vimal
0

LVL 37

Expert Comment

ID: 35168029
Did you see http:#a35167966? It details how the log can be computed (it's very very efficient). The wikipedia article shows how it can be calculated for integers. For floats (which are stored as a mantissa and exponent) the log base 2 is basically there already. (The exponent is the log base 2 rounded down, and the mantissa gives the rest). So for floats and doubles, it's O(1).
0

LVL 21

Accepted Solution

CompProbSolv earned 250 total points
ID: 35168068
If I understand your question, you are wanting to replace the logarithm function in c++ with something faster by using the four basic math functions.

I know nothing about how it is done in any specific compiler, but can offer a couple of comments here.

As far as the algorithm goes, there are a number of them out there.  Try Googling "algorithm for logarithm".

As far as speed goes, I'm skeptical.  At least in the Intel world, ever since the 8087 chip (a coprocessor option for the original IBM PC), there has been hardware support for logarithms in the CPU available to most computers.  Since the first Pentium, I believe it has been a standard part of the CPU.  I would be surprised if external code could run faster than internal microcode for calculating logarithms, except in special cases.

One special case would be if you don't need the precision that the CPU offers.  That might make for a faster calculation.

This is all speculation, of course, and would welcome anyone who has better information to comment on it.
0

LVL 37

Expert Comment

ID: 35168080
That should read 'rounded up' not 'rounded down'.
0

LVL 2

Author Comment

ID: 35168137
Hi TommySzalapski and CompProbSolv,

I am satisfied with both your comments. One more question in school days i have used a logarithm table now I forget every thing about logarithm table.Because I am remembering we were used log table for solving log based problems with out using scientific calculator.Is CPU using any log tables for solving logarithms.

thanks & Regards,
Vimal.
0

LVL 37

Assisted Solution

TommySzalapski earned 250 total points
ID: 35168197
Nope. Since you can compute the log2 so quickly in binary (which is what the computer uses of course), there is no need to use a table. Again, floats and doubles are basically stored in log2 form. We just use tables since we store everything as decimals in base 10.
0

LVL 37

Expert Comment

ID: 35168205
A log table just gives you the logs for a bunch of numbers. You just pick whichever one is closest to your number to get an approximation.
0

LVL 2

Author Comment

ID: 35168238
Hi TommySzalapski and CompProbSolv,

You both has solved my doubt. Thanks Very much. I have some doubts in other maths topics I will post that by 2-3 days.

Thanks & regards,
Vimal.
0

LVL 37

Expert Comment

ID: 35168260
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

### Suggested Solutions

How to Win a Jar of Candy Corn: A Scientific Approach! I love mathematics. If you love mathematics also, you may enjoy this tip on how to use math to win your own jar of candy corn and to impress your friends. As I said, I love math, but I guâ€¦
Foreword (May 2015) This web page has appeared at Google. Â It's definitely worth considering! https://www.google.com/about/careers/students/guide-to-technical-development.html How to Know You are Making a Difference at EE In August, 2013, one â€¦
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaacâ€¦
###### Suggested Courses
Course of the Month6 days, 22 hours left to enroll