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$$
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.