Solved

Logarithm

Posted on 2011-03-17
17
354 Views
Last Modified: 2012-05-11
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
Comment
Question by:vimalalex
  • 8
  • 4
  • 3
  • +2
17 Comments
 
LVL 10

Expert Comment

by:Martin_J_Parker
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

by:TommySzalapski
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

by:TommySzalapski
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

by:StraySod
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 20

Expert Comment

by:CompProbSolv
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

by:vimalalex
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 20

Expert Comment

by:CompProbSolv
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

by:TommySzalapski
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 2

Author Comment

by:vimalalex
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

by:TommySzalapski
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 20

Accepted Solution

by:
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

by:TommySzalapski
ID: 35168080
That should read 'rounded up' not 'rounded down'.
0
 
LVL 2

Author Comment

by:vimalalex
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

by:TommySzalapski
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

by:TommySzalapski
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

by:vimalalex
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

by:TommySzalapski
ID: 35168260
Glad to help. I'll be watching for your next questions.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

This algorithm (in C#) will resize any image down to a given size while maintaining the original aspect ratio. The maximum width and max height are both optional but if neither are given, the original image is returned. This example is designed t…
Lithium-ion batteries area cornerstone of today's portable electronic devices, and even though they are relied upon heavily, their chemistry and origin are not of common knowledge. This article is about a device on which every smartphone, laptop, an…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now