Knots
By Mariam Al-Hawaj
In this program, I experimented with Mathematica’s built-in functions to present beautiful pictures of various knots and tried to produce some myself. 
KnotData
KnotData can be used to get all knots of crossing numbers up to 10 crossings as follows:

KnotData[All]

Basic Knots
KnotData is also used to present a picture of some of the knots. For example:

KnotData["Unknot"]//Timing

KnotData["Trefoil"]//Timing

KnotData["FigureEight"]//Timing

KnotData["SolomonSeal"]//Timing

KnotData["Stevedore"]//Timing

GraphicsGrid
GraphicsGrid is a Mathematica code that can put pictures in a grid form. However, the code does not work with 3D. So I experimented and tried to add “3D” to the code and it worked.

GraphicsGrid3D[KnotData["Unknot"],KnotData["Trefoil"],KnotData["FigureEight"],KnotData["SolomonSeal"],KnotData["Stevedore"]]//Timing

Torus Knots
Mathematica has a build-in code for the torus knots. You only need to decide on the values of p and q in the (p,q)-torus knot. The following example is the (2,3)-torus knot which is the trefoil knot.

KnotData[{"TorusKnot",{2,3}}]//Timing

Torus Knots up to 10 crossings
KnotData [ “Torus” ] is used to show the torus knots up to 10 crossings.

KnotData["Torus"]
GraphicsGrid3D[KnotData[{"TorusKnot",{1,1}}],KnotData[{"TorusKnot",{2,3}}],KnotData[{"TorusKnot",{2,5}}],KnotData[{"TorusKnot",{2,7}}],KnotData[{"TorusKnot",{3,4}}],KnotData[{"TorusKnot",{2,9}}],KnotData[{"TorusKnot",{3,5}}]]//Timing

(2,q) - Torus Knots
Here, we present pictures of torus knots with p=2 and q the coprime numbers to p up to 47.

GraphicsGrid3D[KnotData[{"TorusKnot",{2,3}}],KnotData[{"TorusKnot",{2,5}}],KnotData[{"TorusKnot",{2,7}}],KnotData[{"TorusKnot",{2,9}}],KnotData[{"TorusKnot",{2,11}}],KnotData[{"TorusKnot",{2,13}}],KnotData[{"TorusKnot",{2,15}}],KnotData[{"TorusKnot",{2,17}}],KnotData[{"TorusKnot",{2,19}}],KnotData[{"TorusKnot",{2,21}}],KnotData[{"TorusKnot",{2,23}}],KnotData[{"TorusKnot",{2,25}}],KnotData[{"TorusKnot",{2,27}}],KnotData[{"TorusKnot",{2,29}}],KnotData[{"TorusKnot",{2,31}}],KnotData[{"TorusKnot",{2,33}}],KnotData[{"TorusKnot",{2,35}}],KnotData[{"TorusKnot",{2,37}}],KnotData[{"TorusKnot",{2,39}}],KnotData[{"TorusKnot",{2,41}}],KnotData[{"TorusKnot",{2,43}}],KnotData[{"TorusKnot",{2,45}}],KnotData[{"TorusKnot",{2,47}}]]//Timing

(3, q) - Torus Knots
Here, we present pictures of torus knots with p = 3 and q the coprime numbers to p up to 32.

GraphicsGrid3D[KnotData[{"TorusKnot",{3,4}}],KnotData[{"TorusKnot",{3,5}}],KnotData[{"TorusKnot",{3,7}}],KnotData[{"TorusKnot",{3,8}}],KnotData[{"TorusKnot",{3,10}}],KnotData[{"TorusKnot",{3,11}}],KnotData[{"TorusKnot",{3,13}}],KnotData[{"TorusKnot",{3,14}}],KnotData[{"TorusKnot",{3,16}}],KnotData[{"TorusKnot",{3,17}}],KnotData[{"TorusKnot",{3,19}}],KnotData[{"TorusKnot",{3,20}}],KnotData[{"TorusKnot",{3,22}}],KnotData[{"TorusKnot",{3,23}}],KnotData[{"TorusKnot",{3,25}}],KnotData[{"TorusKnot",{3,26}}],KnotData[{"TorusKnot",{3,28}}],KnotData[{"TorusKnot",{3,29}}],KnotData[{"TorusKnot",{3,31}}],KnotData[{"TorusKnot",{3,32}}]]//Timing

(4, q) - Torus Knots
Here, we present pictures of torus knots with p = 4 and q the coprime numbers to p up to 31.

GraphicsGrid3D[KnotData[{"TorusKnot",{4,5}}],KnotData[{"TorusKnot",{4,7}}],KnotData[{"TorusKnot",{4,9}}],KnotData[{"TorusKnot",{4,11}}],KnotData[{"TorusKnot",{4,13}}],KnotData[{"TorusKnot",{4,15}}],KnotData[{"TorusKnot",{4,17}}],KnotData[{"TorusKnot",{4,19}}],KnotData[{"TorusKnot",{4,21}}],KnotData[{"TorusKnot",{4,23}}],KnotData[{"TorusKnot",{4,25}}],KnotData[{"TorusKnot",{4,27}}],KnotData[{"TorusKnot",{4,29}}],KnotData[{"TorusKnot",{4,31}}]]//Timing

(5, q) - Torus Knots
Here, we present pictures of torus knots with p = 5 and q the coprime numbers to p up to 34.

GraphicsGrid3D[KnotData[{"TorusKnot",{5,6}}],KnotData[{"TorusKnot",{5,7}}],KnotData[{"TorusKnot",{5,8}}],KnotData[{"TorusKnot",{5,9}}],KnotData[{"TorusKnot",{5,11}}],KnotData[{"TorusKnot",{5,12}}],KnotData[{"TorusKnot",{5,13}}],KnotData[{"TorusKnot",{5,14}}],KnotData[{"TorusKnot",{5,16}}],KnotData[{"TorusKnot",{5,17}}],KnotData[{"TorusKnot",{5,18}}],KnotData[{"TorusKnot",{5,19}}],KnotData[{"TorusKnot",{5,21}}],KnotData[{"TorusKnot",{5,22}}],KnotData[{"TorusKnot",{5,23}}],KnotData[{"TorusKnot",{5,24}}],KnotData[{"TorusKnot",{5,26}}],KnotData[{"TorusKnot",{5,27}}],KnotData[{"TorusKnot",{5,28}}],KnotData[{"TorusKnot",{5,29}}],KnotData[{"TorusKnot",{5,31}}],KnotData[{"TorusKnot",{5,32}}],KnotData[{"TorusKnot",{5,33}}],KnotData[{"TorusKnot",{5,34}}]]//Timing

Torus Knots using my own Codes
Here, I tried to present pictures of torus knots using different methods. I also compared the speed of each of them with the built-in one.

r=Cos[q t]+2;
x=r*Cos[p t];
y=r*Sin[p t];
z=-Sin[q t];
p=2;q=5;
Show[ParametricPlot3D[{x,y,z},{t,0,2π},ViewPoint->{0,0,100},Boxed->False,Axes->False]/.Line[a_]:>Tube[a,0.2],PlotRange->All,ImageSize->300]//Timing

torusKnot[p_,q_,t_]:=With[{r=Cos[q t]+2},{r Cos[p t],r Sin[p t],Sin[q t]}]
pts=Table[torusKnot[2,5,t],{t,0,2 π,π/100}];
Graphics3D[{CapForm[None],Lighter@Red,Tube[pts,0.2],FaceForm[None,Glow[White]],Tube[pts,0.15]},ViewPoint->{0,0,100},Boxed->False]//Timing

KnotData[{"TorusKnot",{2,5}}]//Timing

Trefoil Knots
Here, I present pictures of the trefoil knots using different methods. I also compare the speed of each one with the buit-in.

torusKnot[p_,q_,t_]:=With[{r=Cos[q t]+2},{r Cos[p t],r Sin[p t],Sin[q t]}]
pts=Table[torusKnot[2,3,t],{t,0,2 π,2 π/200}];
Graphics3D[{CapForm[None],Lighter@Orange,Tube[pts,0.2],FaceForm[None,Glow[White]],Tube[pts,0.15]},ViewPoint->{0,0,100},Boxed->False]//Timing

KnotData[{"TorusKnot",{2,3}}]//Timing

trefoil[t_]={Sin[3 t],Sin[t]+2 Sin[2 t],Cos[t]-2 Cos[2 t]};
Show[ParametricPlot3D[trefoil[t],{t,0,2π},ViewPoint->{25,0,0},Boxed->False,Axes->False]/.Line[pts_]:>Tube[pts,0.2],PlotRange->All,ImageSize->380]//Timing
KnotData["Trefoil"]//Timing

Trefoil Knots’ Planar Diagram
Mathematica has a buit-in code to present the knot in the planar diagram form.

KnotData["Trefoil","KnotDiagram"]//Timing

Coding the Planar Diagram of the Trefoil Knot
Here, I present pictures of the planar diagram of the trefoil knot. I also compare the speed of each one with the buit-in.

trefoil2[t_]={Sin[t]+2 Sin[2 t],Cos[t]-2 Cos[2 t]};
{diag,{s}}=Reap[ParametricPlot[{Sin[t]+2 Sin[2 t],Cos[t]-2 Cos[2 t]},{t,0,2 π},Axes->False,EvaluationMonitor:>Sow[t],ImageSize->380]];s=Sort[s];
diag//Timing

{xp[t_],yp[t_]}=trefoil2'[t];
n[t_]={yp[t],-xp[t]};
n[t_]=Simplify[n[t]/Norm[n[t]],Element[t,Reals]];
gap=0.15;
strip[{t1_,t2_}]:={{White,EdgeForm[White],Polygon[{trefoil2[t1]+gap*n[t1],trefoil2[t2]+gap*n[t2],trefoil2[t2]-gap*n[t2],trefoil2[t1]-gap*n[t1]}]},{Thickness[0.005],Line[{trefoil2[t1],trefoil2[t2]}]}};
ps=Table[{trefoil[s[[i]]],{s[[i]],s[[i+1]]}},{i,1,Length[s]-1}];
xsort=Last/@SortBy[ps,#[[1,1]]&];
Graphics[strip/@xsort,ImageSize->380]//Timing

Trefoil Knots using Arrow with BSplineCurve
Here, I present pictures of the trefoil knots using a curved arrow. Also notice the timings and compare them to the previous ones.

Graphics3D[{Arrow[BSplineCurve[{{0,0,0},{1,1,1},{2,-1,1},{3,0,2}}]]},Boxed->False]
Graphics3D[{Arrow[Tube[BSplineCurve[{{0,0,0},{2,.3,1},{1,-.5,2},{-1,.5,2},{-2,.3,1},{0,-1.5,0},{1,1,2},{0,0,4},{-1,-1,2},{0,0,0}}],.15]]},Boxed->False,ViewPoint->{0,-60,30},PlotRange->All,ImageSize->380]//Timing

tref={{0,0,0},{2,.3,1},{1,-.5,2},{-1,.5,2},{-2,.3,1},{0,-1.5,0},{1,1,2},{0,0,4},{-1,-1,2},{0,0,0}};
Graphics3D[{Arrow[Tube[BSplineCurve[tref],.15]]},Boxed->False,ViewPoint->{0,-60,30},PlotRange->All,ImageSize->380]//Timing

Future Plans
I am interested in producing more pictures of knots with higher number of crossings.





Thank You!