There is an overhead when calling into Python. I just made a quick test showing that sinc(x) is between 4 and 5 times as slow when implemented in Python compared to a custom function in Graph. But this may vary depending on the complexity of the function.

]]>Import Graph

Import math

Graph.CustomFunctions["pmf1"] = pmf1

Graph.CustomFunctions["pmf2"] = pmf2

Graph.CustomFunctions["pmf3"] = pmf3

or does each function need to be in a separate file?

Do you know if there is a significant overhead in calling Python functions? For example, sinc() could also be a custom function in Graph. Would graphing speed of a complicated function using sinc() be noticeably different between the Graph defined sinc() and the Python defined sinc()?

]]>But here is an example. If you place the following code in a file called sinc.py in the Plugins directory and you have Python 3.2 installed, you will be able to use the function sinc in Graph like f(x)=sinc(x):

```
import Graph
import math
def sinc(x):
if x == 0:
return 1
return math.sin(x) / x
Graph.CustomFunctions["sinc"] = sinc
```

In the meantime, I'm in the category of being unfamiliar with the Python scripting language. Would it be possible to post or refer me to an example of a script that implements a function not native to graph and an example graph using it?

]]>Graph has some great functions, such as gamma and zeta, but none that directly relate to primes, such as:

pi(n): You would need another name for the function since pi is used as a constant in Graph.

isprime(n): For small n there are some good ideas on efficiently storing a lookup table of small primes at http://www.rsok.com/~jrm/printprimes.html and for large n there are primality tests much faster than trial division by all primes to sqrt(n).

iscomposite(n) or notprime(n): This one could be implemented using the Miller–Rabin test.

Graphing the behavior of primes is highly desirable for any graphing program. I might be able to implement a simple sieve just using Graph's existing functions. Though I suspect your recommendation will be to use a Python script, having some functions for working with primes built in to Graph would be more convenient. Remember, accuracy is only required to the limit of Graph's x-axis, not infinity.

Some other functions to consider implementing that would be useful to number theory graphs:

Riemann's prime-counting function

Logarithmic integral function

Exponential integral function

von Mangoldt function

Möbius function

Euler's totient (phi) function

sfn(n) is n a square free number?

Lucas-Lehmer test