Graphing a function.. the definition contains min, max, gcd.

61 Views Asked by At

Let $x=\frac{p}{q}$, where $p,q \in \mathbb{N}$.

Graph the function;

$$f(x)=\left\{\begin{matrix} \frac{\min(p,q)+1}{\max(p,q)+1} & \text{if }\text{GCD}(p,q)=1 \\ & \\ 0 & \text{if }\text{GCD}(p,q)\neq1 \end{matrix}\right.$$

Graphing the function by hand is quite easy to understand, and quite difficult to plot. Unfortunately I do not know any graphing website or software where we can define a function as mentioned. Any help will be appreciated.

1

There are 1 best solutions below

3
On

I think it is really difficult to plot this function, since it is a very particular and unusual case. However, I have a tip for you. You can generate your own script for plotting it using programming methods. Bellow is an idea of how to build your algorithm.

  • define $p=1$ and $q=1$

  • from $i=1$ to $N_1$ do

  • from $j=1$ to $N_2$ do

  • $p=p+1$

  • $q=q+1$

  • define $F=\dfrac{\text{min}(p,q)+1}{\text{max}(p,q)+1}$

  • find common divisors of p and q (this requires a factorization algorithm)

  • put their common divisors in decreasing order
  • if the highest common divisor is one, write in the external file $\left(\dfrac{p}{q}, F\right)$
  • else, write in the external file $\left(\dfrac{p}{q}, 0\right)$

You can choose the $N_1$ and $N_2$ values, but remember the bigger $N_1$ and $N_2$ the higher your program will take to factorize p and q. After that, you can use any simple program to plot your external file.