## How to manipulate a knot with Maple

#### Getting started (specific to ucdavis)

Start with any computer that has Maple. For instance, go to the math
department computers. Log in to the machine called "point" (for
instance, by double clicking on the terminal icon whose name is "point"
or else by typing "`ssh -X point`" from any terminal window).
Now launch Maple with the command "`xmaple &`". This should open
two new
windows: one has a place for you to enter text, and the other is a help
window.

#### Rudiments of Maple

If you want to enter a command and have a
response returned, you must end with the character "`;`". For
instance,
if you are asking Maple to evaluate 4 pi, you would enter
"`evalf(4*Pi);`". (The evalf tells it to give a decimal answer.)
On the other hand, if you are merely defining something for later use,
or entering some other command to which you don't need a response, you
can finish with the character "`:`".
For instance, you can define a vector with a command like
"`v:=<1,3,4>:`". To check that this worked, on the next line,
type "`v;`"-- you should see the vector as output.

#### On to the knot

First let's load all the packages we will need.
`with(LinearAlgebra,linalg,plots,spacecurve):`
(You may get some warning messages. Don't worry about it.)
Next we define the knot.

`G:=[4*cos(2*t)+2*cos(t),4*sin(2*t)-2*sin(t),sin(3*t),t=0..2*Pi]:
`
Now it's a simple matter to plot it.

`spacecurve(G);`
After a few seconds, the graphics will appear in the window. You can
use your mouse to click and drag, which will rotate your vantage point
and give you a better sense of the knot. Here's one vantage point:

On the homework, you were also asked to estimate the total curvature.
To that end, let's define the position at time t on the curve.

`
g:=< 4*cos(2*t)+2*cos(t),4*sin(2*t)-2*sin(t),sin(3*t)>:
`
Next, since we're going to integrate the curvature, we need to compute
it, and that means knowing the velocity and acceleration.

`
g1:=map(diff,g,t):`

g2:=map(diff,g1,t):
(Here, the command `map` tells Maple to do `diff` to the
whole vector, componentwise.)
Knowing the formula for curvature of a regular curve, we can set

`
h:=CrossProduct(g1,g2):`

numerator:=norm(h,2):

denominator:=(norm(g1,2))^3:

curvature:=numerator/denominator:
(Here, note that "`norm(v,2)`" gives the 2-norm of a vector; that
is, the square root of the sums of the squares. As you might guess,
"`norm(v,3)`" would give the 3-norm.)
Next, to get the total curvature, we integrate curvature at t
times (ds/dt) dt. Don't forget the ds/dt term-- you need it to do the
change of variables. And of course ds/dt is the speed at time t.

`
totalK:= int(curvature*norm(g1,2),t=0..2*Pi):
`
That's it! Now we can just ask for a decimal expansion of that value
and we have our numerical estimate of the total curvature:

`
evalf(totalK);
`
Compare that to 4 pi. You can consider other topologically equivalent
knots (these knots are called *trefoil* knots) and see if you can
get closer to 4 pi....