# Inverse of Trefoil Knot Paramaterization

I'm working on a coding project at the moment where I have to integrate a function around a trefoil knot. I'm using the following parametrization to do so.
$$x = \sin(t) + 2\sin(2t)$$
$$y = \cos(t) - 2 \cos(2t)$$
$$z = -\sin(3t)$$
which is copied from wikipedia. When I actually integrate my function in code I want to make sure that I don't go ahead and pass a point on the knot to the integration routine. If I do that it blows up. I'm trying to integrate the electric potential around a charged knot. It has the following general form
$$\varphi=\int_0^{2\pi} \frac{|r'(t)|}{|x-r(t)|}\,dt$$ where the denominator of the fraction is the distance from a point to the knot itself. You can see that if the point is a position on the knot itself you get $$0$$ in the denominator and the function explodes.

To test if a point is on the knot I thought I could go ahead and find the inverses of my three functions. Then I'd just do a bit of linear algebra to see if there was a single solution for my point with $$x,y$$ and $$z$$ and I could reject the point if there was. However, while finding the inverse for $$z$$ is pretty trivial, for $$x$$ and $$y$$ I'm a little stumped. After noodling with it for awhile I gave up and used Wolfram, and in particular got a super gnarly response for $$x$$. Am I making some basic mistake in my trig identities that would simplify these? Or is there no simple way to deal with this? The function itself is the following:
$$\phi=\int_0^{2\pi} \frac{\sqrt{8cos(3t)+4.5cos(6t)+21.5}}{\sqrt{(x-(sin(t) + 2sin(2t)))^2+(y-(cos(t) - 2 cos(2t)))^2+(z-(-sin(3t)))^2)}}dt$$

• Please give the function. Jan 5 at 5:41
• I don't see the problem in using $z$. To a given $z$ you typically have six possibilities for $t$ in the range $[0,2\pi)$. These can be found easily. Then you can test both $x$ and $y$ for the six choices. Jan 5 at 7:39
• Hi David, I've added the function to the bottom of the post. Jyrki, I'm not sure I understand, why are there only 6 possibilities for $z$? I had an array of points from $[0,2\pi)$ for my $t$ variable but I was running into problems where the $z$ value didn't match the output for a specific value of $t$. Jan 5 at 18:03
• I think Jyrki is saying this: You want to test if a point $(x_0, y_0, z_0)$ is on your trefoil. The equation $z_0 = -\sin(3t)$, for $t \in [0,2\pi)$, has at most $6$ solutions for $t$. (There are fewer solutions if $z_0 = \pm 1$, say, and none at all if $z_0 = 2$, say, but no matter.) Okay, now take each of those (at most) $6$ solutions and plug them into the two equations $x_0 = \sin(t) + 2 \sin(2t)$ and $y_0 = \cos(t) - 2 \cos(2t)$. If $(x_0, y_0, z_0)$ lies on your curve, then one of the $t$ values should make those two equations simultaneously true. Jan 5 at 18:15
• Ahhhhhh thank you Jesse! Jan 5 at 18:30

## 1 Answer

I guess I don't understand your problem. You plot this function and it looks like the knot:

Then you take your function (which you haven't specified) and integrate along this knot.

• Hi David, I've added a bit more detail to clarify the problem in the original question. If I attempt to input a point on the knot itself, my function blows up. Jan 5 at 5:53