Message Boards Message Boards

0
|
5114 Views
|
5 Replies
|
3 Total Likes
View groups...
Share
Share this post:

How to assign a variable to a particular type of number series?

Posted 2 years ago

Hello,

I am new to using Mathematica so please excuse this question.

My question is, is it possible to assign a variable a set of specific numbers, such as p = all primes.

I would like to know this because I am working with equations that uses a series of all primes versus all real numbers.

Alternatively could one explain how I could adapt this equation in a way to work in Mathematica. (p = all primes)

enter image description here

Thank you,

POSTED BY: Jacob Hutchins
5 Replies
Posted 5 months ago
Clear[fn]
fn[s_, n1_] := ParallelSum[ 1/(k Prime[j]^(k s)), {j, n1}, {k, Infinity}]

Sum over all the prime is taking time in my machine so I have restricted the sum to the first n1 number of primes for a given value of s. Example is:

In[19]:= fn[1, 20]

Out[19]= log(27855244711645124539/3559835660451840000)


In[41]:= AbsoluteTiming[fn[2, 1000] // N]

Out[41]= {0.985389,0.497688}

Later you can take exponential of the sum.

I hope you will find this helpful.

POSTED BY: Alam Khan

This won't converge unless the real part of s exceeds 1 (switch order of summation and see that the k=1 subsum diverges). For larger s, numeric approximation using NSum might work.

POSTED BY: Daniel Lichtblau
Posted 2 years ago

Thank you for both your replies.

This did help me.

I apologize again, I am new at this.

POSTED BY: Jacob Hutchins

To get the list of the first 100 primes, we can use the Prime function and assign it to a variable primes:

In[12]:= primes = Prime[Range[100]]

Out[12]= {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, \
59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, \
131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, \
199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, \
281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, \
373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, \
457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541}

Evaluating the given expression in Mathematica using Sum and Exp functions, with N to get the numerical value:

In[16]:= N[Exp[Sum[1/(k p^k), {k, 1, 100}, {p, primes}]]]

Out[16]= 11.2676

I don't know what is s in your equation, so I couldn't insert it in the above expression (Sorry!).

For the upper bound of the k sum (over reals), I have taken 100 and not infinity, since the series seems to be converged (up to four decimal places) for n=100.

One can check the result for the sum over k for three different upper limits, n=10, 100, 1000:

In[18]:= Table[N[Exp[Sum[1/(k p^k), {k, 1, 10^n}, {p, Prime[Range[100]]}]]], {n, {1,2,3}}]

Out[18]= {11.2667, 11.2676, 11.2676}
POSTED BY: Adiba Shaikh

For typesetting purposes you can try this:

Inactive[Exp][
 Inactive[Sum][Inactive[Sum][1/(k ^(k s)), {k, 1, Infinity}], 
  Element[p, Primes]]]

but I doubt you can make any actual calculation with it.

POSTED BY: Gianluca Gorni
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract