Ln(x) algorithm

  • #1
AndersHermansson
61
0
I was fiddling around with C++ and iterations and I found an algorithm for computing ln(x).


n = any number, the higher, the better the approximation
ln_x = 0;
divisor = 10^n;

while ( divisor <= x*10^n ) // Where x is the ln(x) you want to find.
{

ln_x += 1 / divisor;
divisor++;

}

What it does is add all integer fractions from 1/10^n to 1/x*10^(n+1).
 

Answers and Replies

  • #2
chroot
Staff Emeritus
Science Advisor
Gold Member
10,275
40
You've discovered the fact that [inte](1/x) dx is ln(x). Congratulations!

- Warren
 
  • #3
AndersHermansson
61
0
Thanks :)
 

Suggested for: Ln(x) algorithm

  • Last Post
Replies
1
Views
397
MHB Ln(x)
  • Last Post
Replies
1
Views
736
Replies
20
Views
2K
Replies
1
Views
359
Replies
19
Views
348
Replies
4
Views
230
Replies
2
Views
1K
Replies
8
Views
415
Replies
6
Views
1K
  • Last Post
Replies
6
Views
2K
Top