MathGroup Archive 2003

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Summations with Primes


On 3/12/03 at 2:29 AM, afelder at crsi.org (Anthony Felder) wrote:

>Can you tell me if, when calculating a summation of f(i) where i goes
>from imin to imax, Mathematica can be forced to only use prime values
>for i?

Yes, by adding the appropriate code. That is there isn't a built in directive to do what you want.

I think there are two basic approaches. First would be to generate a list of primes, map f to the elements of that list then sum. For example:

Tr[f/@Select[Range[imin, imax], PrimeQ]] will do the trick

This approach might be made more efficient using the NextPrime function in the package NumberTheory`NumberTheoryFunctions`

The other approach would be to modify f so that it returned zero for non-prime arguments. I think this approach is likely to be slower than the first approach.


  • Prev by Date: Re: Fourier bug
  • Next by Date: Don't understand Plot behavior
  • Previous by thread: Re: Summations with Primes
  • Next by thread: Re: Re: Summations with Primes