Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


logarithm


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 jenova   Members   -  Reputation: 122

Like
Likes
Like

Posted 28 June 2001 - 10:57 AM

is anyone aware of an algorithm to compute logarithm other than the Tayler series method? thanx for any responses.

Sponsor:

#2 Graylien   Members   -  Reputation: 160

Like
Likes
Like

Posted 28 June 2001 - 02:57 PM

Here's a little recursive algorithm due to John Napier (16th century).


//Globals defined outside of function for clarity
static double aMean = -1.0; //arithmetic mean
static double gMean = -1.0; //geometric mean
static double precision = 0.00001; //adjustable precision


/*
n is the number whose log is sought
b1 and b2 are two boundary values where b1 < n < b2
l1 and l2 are the known logs of b1 and b2, respectively
*/

double rLog(double n, double b1, double b2, double l1, double l2) {
if( abs(b1 - b2) > precision ) {
gMean = sqrt( b1 * b2 );
aMean = ( l1 + l2 ) / 2;
if( n <= gMean ) rLog(n, b1, gMean, l1, aMean);
else rLog(m, gMean, b2, aMean, l2);
}
return aMean;
}

Invoking, say, recLog(100, 10, 1000, 1, 3) gives 1.99999 or so. (Be wary of numberical errors)

Edited by - Graylien on June 28, 2001 9:59:41 PM

#3 jenova   Members   -  Reputation: 122

Like
Likes
Like

Posted 01 July 2001 - 05:59 AM

thanx alot, graylien. that''s exactly what i was looking for.

To the vast majority of mankind, nothing is more agreeable than to escape the need for mental exertion... To most people, nothing is more troublesome than the effort of thinking.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS