Loading ...
Sorry, an error occurred while loading the content.
 

computing Li(x)

Expand Messages
  • gehart24
    Hi, I am having trouble computing Li(x). Accoring to the Li(x) table on http:// www.utm.edu/research/primes/howmany.shtml my program is coming up short. Does
    Message 1 of 7 , Dec 10, 2003
      Hi, I am having trouble computing Li(x). Accoring to the Li(x) table on http://
      www.utm.edu/research/primes/howmany.shtml my program is coming up short.
      Does anyone have a program that computes Li(x)?

      Thank you, george.
    • pbtoau
      George, A couple of good formulas for Li(x) are at this URL. http://mathworld.wolfram.com/LogarithmicIntegral.html Best regards, David ... table on http:// ...
      Message 2 of 7 , Dec 11, 2003
        George,

        A couple of good formulas for Li(x) are at this URL.

        http://mathworld.wolfram.com/LogarithmicIntegral.html

        Best regards,

        David
        --- In primenumbers@yahoogroups.com, "gehart24" <gehart24@y...> wrote:
        > Hi, I am having trouble computing Li(x). Accoring to the Li(x)
        table on http://
        > www.utm.edu/research/primes/howmany.shtml my program is coming up
        short.
        > Does anyone have a program that computes Li(x)?
        >
        > Thank you, george.
      • Eric W. Weisstein
        ... Of course, the easiest thing is to simply use Mathematica s built-in LogIntegral[x], which is what was used to generate the figures on that page... Cheers,
        Message 3 of 7 , Dec 11, 2003
          On Thu, 11 Dec 2003, pbtoau wrote:

          > George,
          >
          > A couple of good formulas for Li(x) are at this URL.
          >
          > http://mathworld.wolfram.com/LogarithmicIntegral.html

          Of course, the easiest thing is to simply use Mathematica's built-in
          LogIntegral[x], which is what was used to generate the figures on that
          page...

          Cheers,
          -Eric

          > --- In primenumbers@yahoogroups.com, "gehart24" <gehart24@y...> wrote:
          > > Hi, I am having trouble computing Li(x). Accoring to the Li(x)
          > table on http://
          > > www.utm.edu/research/primes/howmany.shtml my program is coming up
          > short.
          > > Does anyone have a program that computes Li(x)?
          > >
          > > Thank you, george.
        • Jud McCranie
          ... I used those too, #7 and #8. I think I had to make a small correction to #8 to get it to work. Here is my implementation in Pascal. It refers to Eq #7,
          Message 4 of 7 , Dec 11, 2003
            At 11:13 AM 12/11/2003, pbtoau wrote:
            >George,
            >
            >A couple of good formulas for Li(x) are at this URL.
            >
            ><http://mathworld.wolfram.com/LogarithmicIntegral.html>http://mathworld.wolfram.com/LogarithmicIntegral.html

            I used those too, #7 and #8. I think I had to make a small correction to
            #8 to get it to work.

            Here is my implementation in Pascal. It refers to Eq #7, but I think it is
            currently #8.


            type tFloat = double; // or whatever

            const EulerConstant = 0.5772156649015328606; // Euler's constant



            function Li( const x : tFloat) : tFloat;

            { li(x) - log integral - integral of 1/ln(t) from 0 to x.
            Li(x) is used in number theory and is integral from 2 to x.
            Li(x)=li(x)-li(2) = li(x) - 1.04516.
            This formula is by Ramanujan, and it is the integral
            from Soldner's constant, mu( mu=1.451369, where li(mu)=0) to x.
            Ref: Weisstein, Logarithmic integral eq. 7.
            By Judson McCranie }

            // SoldnerConstant = 1.451369234883381050; // li(Soldner)=0

            var n,
            k : integer;

            sum,
            LogX,
            FirstPart,
            LastPart,
            term : tFloat;

            begin { --- li --- }

            LogX := ln( x);
            n := 0;
            sum := 0;
            FirstPart := 2.0;
            LastPart := 0;

            repeat
            inc( n);

            FirstPart := FirstPart * LogX / (2.0 * n);

            if odd( n) then
            begin
            k := (n - 1) div 2;
            LastPart := LastPart + 1.0 / (2.0 * k + 1);
            end;

            term := FirstPart * LastPart;

            if odd( n)
            then sum := sum + term
            else sum := sum - term;
            until term < 1.0E-10 * sum;

            li := EulerConstant + ln( LogX) + sqrt( x) * sum;
            end; { --- li --- }
          • Yves Gallot
            ... And the most expensive thing :o( Another one is to download UBASIC (free) and to use the function Logarithmic Integral Li(x) from 0 to x Li(x) =
            Message 5 of 7 , Dec 11, 2003
              > Of course, the easiest thing is to simply use Mathematica's built-in
              > LogIntegral[x], which is what was used to generate the figures on that
              > page...

              And the most expensive thing :o(

              Another one is to download UBASIC (free) and to use the function

              ' Logarithmic Integral Li(x) from 0 to x
              ' Li(x) = Ei(log(x)), x>1
              ' Ei(a) = gamma + log(a) + SUM (a^n)/(n*n!), from n=1 to oo, a>0
              fnLi(x)
              local n, a, b, s
              a=log(x)
              s=#euler+log(a)
              for n=1 to 100
              b=(a^n)/(n*!(n))
              if b<.001 then cancel for: goto 990
              s=s+b
              next n
              return(s)

              Yves
            • Edwin Clark
              ... or, for example, Maple s procedure Li. --Edwin Clark
              Message 6 of 7 , Dec 11, 2003
                >
                > Of course, the easiest thing is to simply use Mathematica's built-in
                > LogIntegral[x],

                or, for example, Maple's procedure Li.

                --Edwin Clark
              • Alan Eliasen
                ... UBASIC is interesting, but is it in development any more? The only versions that I see are quite old. You may also be interested in a programming
                Message 7 of 7 , Dec 13, 2003
                  >>Of course, the easiest thing is to simply use Mathematica's built-in
                  >>LogIntegral[x], which is what was used to generate the figures on that
                  >>page...

                  Yves Gallot wrote:
                  > And the most expensive thing :o(
                  >
                  > Another one is to download UBASIC (free) and to use the function

                  UBASIC is interesting, but is it in development any more? The only
                  versions that I see are quite old. You may also be interested in a
                  programming language/calculating tool I'm developing called "Frink."
                  It handles arbitrary-length integers, arbitrary-precision floating-point
                  numbers, rational numbers, complex numbers, and more. Also, one of the
                  more interesting things about Frink is that it tracks units of measure
                  through all calculations, so you can do things like add:

                  1 foot + 3 meters

                  and it does the right thing.

                  Frink hasn't focused on number-theoretical functionality too much,
                  but I'd love to have good number-theoretical algorithms and appropriate
                  functions implemented in Frink. If you decide to take a look at it, and
                  are interested in contributing implementations of interesting functions
                  or algorithms, I'd be happy to work with you and make them part of the
                  standard distribution.

                  Frink runs on most platforms including handhelds, (it's written in
                  Java,) and you can read about it, download it, or try it online here:

                  http://futureboy.homeip.net/frinkdocs/

                  And it's free. Suggestions, comments, and criticism are most welcome.

                  --
                  Alan Eliasen | "You cannot reason a person out of a
                  eliasen@... | position he did not reason himself
                  http://futureboy.homeip.net/ | into in the first place."
                  | --Jonathan Swift
                Your message has been successfully submitted and would be delivered to recipients shortly.