Which programming language or a library can process Infinite Series?

后端 未结 13 1818
情书的邮戳
情书的邮戳 2021-02-03 23:46

Which programming language or a library is able to process infinite series (like geometric or harmonic)? It perhaps must have a database of some well-known series and automatica

13条回答
  •  感动是毒
    2021-02-04 00:14

    The C++ iRRAM library performs real arithmetic exactly. Among other things it can compute limits exactly using the limit function. The homepage for iRRAM is here. Check out the limit function in the documentation. Note that I'm not talking about arbitrary precision arithmetic. This is exact arithmetic, for a sensible definition of exact. Here's their code to compute e exactly, pulled from the example on their web site:

    //---------------------------------------------------------------------
    // Compute an approximation to e=2.71.. up to an error of 2^p
     REAL e_approx (int p)
    {
      if ( p >= 2 ) return 0;
    
      REAL y=1,z=2;
      int i=2;
      while ( !bound(y,p-1) ) {
        y=y/i;
        z=z+y;
        i+=1;
      }
      return z;
    };
    
    //---------------------------------------------------------------------
    // Compute the exact value of  e=2.71.. 
    REAL e()
    {
      return limit(e_approx);
    };
    

提交回复
热议问题