Hi all:


I'm wondering if there is a simple formula for this.


Simple Example:



```
x=cos(pt);
y=cos(qt);
where p,q are integers. 

```

Question: How many intersection points are there?


0) only need to consider (p,q) are relatively prime.


1) Firstly, I thought it was just basic counting:


Let N(p,q) be the number of crossing. 



```
If p is odd, q is odd: N(p,q) = p(q-1) + (p-1)q = 2pq - p - q. 
If p is even, q is odd: N(p,q) = (p-1)(q-1)/2. 

```

But later I found some special cases p=2,q=5,where the intersection becomes unusual and the formula falls down.


Thanks



Formula for number of intersection points for Lissajous curve?
EDIT: with both functions switched to cosine I get $$ \frac{(p-1)(q-1)}{2} $$ for both odd-odd and for even-odd.


ORIGINAL, both functins sine: For $p$ even and $q$ odd I get $$ 2 p q - p - q $$ which is the same as you have when both are odd.


Examples, I had to count over a few times,
(p,q,count) :


(2,1,1); (2,3,7); (2,5,13); (2,7,19); 


(4,1,3); (4,3,17); (4,5,31); (4,7,45);


(6,1,5); (6,5,49); (6,7,71); (6,11,115);


Then for both odd I get $$ \frac{(p-1)(q-1)}{2} $$


(1,q,0);


(3,q, q-1);


(5,q, 2 q - 2);


(7,q, 3 q - 3);


However for both odd the figure is traced twice, there is no way around that, look on the website you supplied and slowly vary the maximum of $\Theta.$ So it is also reasonable to claim that both segments are doubled and what appears to be a single intersection counts as four as far as the parameter values are concerned. If you prefer that, the formula for both odd becomes
$$ 2 p q - 2 p - 2 q + 2. $$


