Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Ln(x) algorithm

  1. Aug 5, 2003 #1
    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).
     
  2. jcsd
  3. Aug 5, 2003 #2

    chroot

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    You've discovered the fact that [inte](1/x) dx is ln(x). Congratulations!

    - Warren
     
  4. Aug 5, 2003 #3
    Thanks :)
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?



Similar Discussions: Ln(x) algorithm
  1. X ln(x) (Replies: 1)

  2. Ln(-x) invalidity? (Replies: 9)

  3. Ln(x) =f(x) (Replies: 2)

  4. Ln(x) or log(x)? (Replies: 17)

Loading...