Efficient calculation of Faulhaber's formula (sum of powers)?

This is a discussion on Efficient calculation of Faulhaber's formula (sum of powers)? within the General Discussions forums, part of the Community Boards category; What I'm actually trying to do is efficiently calculate Faulhaber(N, E) modulo M (or at least Faulhaber(N, E) - the ...

  1. #1
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708

    Efficient calculation of Faulhaber's formula (sum of powers)?

    What I'm actually trying to do is efficiently calculate Faulhaber(N, E) modulo M (or at least Faulhaber(N, E) - the modulo operation could be worked in later), where N, E, and M can be arbitrarily large. From what I have read, it seems that this is generally expressed in terms of either a polynomial to the degree of N+1 (memory-expensive) or some recursive relationship (time-expensive). Is there any way that this can be done that requires neither very much memory nor time?
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  2. #2
    Epy
    Epy is offline
    Fortran lover Epy's Avatar
    Join Date
    Sep 2009
    Location
    California, USA
    Posts
    963
    Since the exponent changes, you'll be forced to use something like this:
    Faulhaber's Formula -- from Wolfram MathWorld
    (the first equation with the Kronecker delta etc, not the individual cases)

    Power Sum -- from Wolfram MathWorld
    may also be helpful.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Sum of User Defined Matrix Powers
    By QuaX in forum C Programming
    Replies: 1
    Last Post: 04-19-2009, 11:33 PM
  2. Minor Problem
    By stewie1986 in forum C Programming
    Replies: 6
    Last Post: 11-30-2007, 07:40 AM
  3. string to int conversion not using atoi()
    By linucksrox in forum C Programming
    Replies: 2
    Last Post: 05-19-2004, 12:17 AM
  4. Loan calculation formula
    By C++Nerd in forum C++ Programming
    Replies: 1
    Last Post: 10-06-2002, 12:57 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21