Plot Primorial[x] and Factorial[x] in Mathematica

  • Context: Mathematica 
  • Thread starter Thread starter TylerH
  • Start date Start date
  • Tags Tags
    Mathematica Plot
Click For Summary

Discussion Overview

The discussion revolves around plotting the Primorial and Factorial functions in Mathematica, addressing issues with the recognition of the Primorial function and how to define it. Participants explore the definition of Primorial, its implementation, and related functions in Mathematica.

Discussion Character

  • Technical explanation
  • Conceptual clarification
  • Homework-related

Main Points Raised

  • One participant notes that Mathematica does not recognize Primorial as a built-in function and suggests defining it manually.
  • A definition of Primorial is provided, using the product of primes up to a given n, with examples showing its output.
  • Another participant seeks clarification on generating a list of all primes less than or equal to n, indicating interest in a different interpretation of Primorial.
  • There are suggestions for beginners to break down the functions used in Mathematica, such as Range and Prime, to understand their roles in the context of the Primorial function.
  • A later reply mentions the prime counting function, PrimePi[], as a means to assist in defining Primorial in terms of the number of primes up to n.

Areas of Agreement / Disagreement

Participants generally agree on the need to define Primorial manually, but there is some confusion regarding the interpretation of "the other primorial" and how to generate a list of primes. The discussion remains unresolved regarding the best approach to achieve this.

Contextual Notes

There are limitations in the discussion regarding the assumptions made about the definitions of functions and the clarity of the original question. Some mathematical steps and definitions remain unresolved.

TylerH
Messages
729
Reaction score
0
How do I plot those together?

It seems like Mathematica isn't recognizing Primorial. Every time I try to use it, it just prints it back for output.

For example:
Code:
In[30]:= 
Primorial[2]
Out[30]= Primorial[2]
 
Physics news on Phys.org
Primorial is not a built in function. I have never heard of that function either. You will have to define it yourself.
 
Definition of Primorial http://oeis.org/A002110

In[1]:= Primorial[n_]:=Times@@Prime[Range[n]]

In[2]:= Primorial[1]
Out[2]= 2

In[3]:= Primorial[4]
Out[3]= 210
 
Okay, I see Times@@ can be used to multiply all the members of a list. How could I generate a list of all primes less than or equal to n? (I'm interested in the other primorial. n# := the product of all p such that p is prime and p <= n.)
 
If you are a beginner with Mathematica then you need to take the replies posted here apart, use the help system or Google to read the documentation for each function, see what each part does and how they work. Then you begin putting the pieces back together, one step at a time, until you see how the whole thing works.

What does Range[] do? Then what does Range[4] do?
What does Prime[] do? Then what does Prime[2] do?
What does Prime[{2,5}] do? What does Prime[Range[4]] do?
Finally how does all this come together in what I showed
and how does that relate to the original question?

I'm confused by your "I'm interested in the other primorial."
Is that different than what I showed? How?

Perhaps I misunderstood and made a mistake. If so then please explain what I missed.
 
Last edited:
Bill Simpson said:
If you are a beginner with Mathematica then you need to take the replies posted here apart, use the help system or Google to read the documentation for each function, see what each part does and how they work. Then you begin putting the pieces back together, one step at a time, until you see how the whole thing works.

What does Range[] do? Then what does Range[4] do?
What does Prime[] do? Then what does Prime[2] do?
What does Prime[{2,5}] do? What does Prime[Range[4]] do?
Finally how does all this come together in what I showed
and how does that relate to the original question?
I have prior programming experience, I've already deduced what they do. Range[n] = {1,...,n}, Prime[n] = nth prime, Prime[{2,5}] = 2nd and 5th prime = {3, 11}.

Bill Simpson said:
I'm confused by your "I'm interested in the other primorial."
Is that different than what I showed? How?

Perhaps I misunderstood and made a mistake. If so then please explain what I missed.
The other primorial is the product of all primes less than or equal to n. For example, Primorial[5]=Times@@{2,3,5}.

What I don't know how to do is create a list of all primes less than or equal to a given n.

EDIT: OH YEAH! I forgot about the prime counting function, which, research says, is called PrimePi[] in Mathematica. So,
Code:
Primorial[n_]:=Times@@Prime[Range[PrimePi[n]]]
 
Last edited:

Similar threads

  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 9 ·
Replies
9
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 6 ·
Replies
6
Views
2K