Math 2248 Lab 7:
Parametric Surfaces and Their Animation

© Copyright by T.I. Lakoba
The animations in this Lab were produced with help from Larry Kost.
Last modified  2025-11-11

Clear["`*"]

The purpose of this Lab is to convince you that defining surfaces parametrically allows one to do many more useful and simply nice things with them than with surfaces defined as  z=f(x,y).

This Lab has 4 Bonus parts (BPs). 
BP3 is similar to BP1; so that if you did BP1, you can probably do BP3, and the converse is also true. 
BP4 essentially depends on BP2, so that if you didn’t do BP2, don’t attempt BP4. 
BP1&3 are independent of BP2&4.

Introduction

The next paragraph reminds you of the logical steps behind obtaining equations of a torus. These steps were first presented to you in an Example in the notes (not the textbook!) for Sec. 16.6. If you have any difficulty understanding the logical steps of this paragraph, you should review the topic on surfaces of revolution in the notes for Sec. 16.6. 

Consider a circle of radius  b  in the  xz-plane whose center is at the point  (a,0)  in that plane:
		(((x-a))^2) + (z^2) = (b^2) ,                 0 < b < a .
(On a piece of paper, draw the Cartesian axes and the above circle.) 
For future reference, we will call this circle the “generating circle”, since it will be used to generate the surface of the torus. 
The parametric equation of this circle in the Cartesian coordinates is:
		 x = a + b cos u,      y = 0,     z = b sin u .
When one rotates the generating circle around the  z-axis, one obtains a  torus  (the surface of a doughnut).  During this rotation, the  z-coordinate of any given point of the rotated circle does not change, while the  x-  and y-coordinates undergo a circular motion:
		x = p cos v,      y = p sin v,     z = q.
Here  p, q  are found from the previous equations for  x  and for  z :
		 p = a + b cos u ,      q = b sin u. 
Therefore, the parametric equations of the torus are:

 x = (a + b cos u) cos v ,      y =  (a + b cos u) sin v ,     z = b sin u ;
		 0  ≤ u < 2π ,      0  ≤ v <  2π .                           	(1)
		 
Thus, parameter u describes the generating circle in the  xz-plane, while parameter v describes the rotation of this circle about the  z-axis. 

Here is the plot of a torus:

a=2; b=1;
ParametricPlot3D[{(a+b*Cos[u])*Cos[v],(a+b*Cos[u])*Sin[v],b*Sin[u]},{u,0,2*Pi},{v,0,2*Pi}]

The constant  b  determines how “fat” the “tube” that makes up the torus is. Then, for a fixed  b, the constant  a  determines the “overall” size of the torus. 
Let us paraphrase this. Suppose the torus is a donut and the figure frame is the box where you put the donut. Then  b  determines how tall your box should be, and for a fixed  b,   a  determines how wide the box should be.

Now let us redefine the above plot in order to see the effect of changing the limits of  u  and  v  as well as the parameters  a  and  b :

torus[a_,b_,umin_,umax_,vmin_,vmax_]:=ParametricPlot3D[{(a+b*Cos[u])*Cos[v],(a+b*Cos[u])*Sin[v],b*Sin[u]},{u,umin,umax},{v,vmin,vmax},PlotPoints->30,AxesLabel->{"X","Y","Z"}]

(* MAKE SURE TO READ THE COMMENTS IN THIS BOX AND BELOW. 
THEY EXPLAIN THE ROLE OF VARIOUS PARTS OF THE COMMAND.
WITHOUT UNDERSTANDING THOSE EXPLANATIONS, 
  YOU WILL NOT BE ABLE TO DO EXERCISES 1(a) AND 2.  *)

(*
 The command  torus  produces no output (as is common for all commands having ":="). What it does is it defines a graph of a torus, making this graph dependent on the parameters supplied by the user. See the results below.

The option PlotPoints is used to control the smoothness of the surface. You may use more than 30 PlotPoints, but the graphics will run slower.
*)

We can use this command to plot “pieces” of a torus.

torus[2,1,0 ,3*Pi/4,0, 2*Pi]
(* This "piece" is obtained by full rotation about the z-axis of an arc comprising 3/8-th of the generating circle. *)

Practice on your own - 1:
Inspect the above plot by rotating the figure box to get a good view of the surface. Make sure that you understand how the arguments of the command torus correspond to what you see in the plot. 
You will not be able to complete Exercise 1(a) if you skip the inspection of this and later plots.

Practice on your own - 2:
Here are questions that you need to answer to check your understanding.
1) if you view it from the top, what is the outer radius of the ring that you see, and why?
2) What is the inner radius of the same ring, and why?
3) If you view this shape from the side, what is its height (along z), and why?

Answers

1)  2 (radius of the “big” circle) + 1 (radius of the “small” circle) * cos(0); here “0” is the 3rd argument of the torus  command. 
2)  2 (radius of the “big” circle) + 1 (radius of the “small” circle) * cos(3Pi/4) ) ≈ 1.3.
3)  1 (radius of the “small” circle).

Here is another piece of the torus, similarly constructed:

torus[2,1,-Pi/2,Pi/4,0, 2*Pi]
(* This "piece" is obtained by full rotation about the z-axis of another 3/8-th arc of the generating circle. *)

Practice on your own:
Answer similar questions about this new picture:
1) What is the radius of the upper rim, and why?
2) What is the radius of the lower rim, and why?
3) If you view this shape from the side, what is its height (along z), and why?

Answers

1)  2 (radius of the “big” circle) + 1 (radius of the “small” circle) * cos(Pi/4) ≈ 2.7. 
2)  2 (radius of the “big” circle) + 1 (radius of the “small” circle) * cos(-Pi/2) ) 2 .
3)  1 (radius of the “small” circle) * sin(Pi/4) - 1 (radius of the “small” circle) * sin(-Pi/2) ≈ 1.7.

Here are two more “pieces” obtained by two different rotation of the same arc of the generating circle as in the last plot, but by 4*Pi/3 radians instead of 2*Pi radians about the  z-axis:

Show[torus[2,1,-Pi/2,Pi/4,0, 4*Pi/3], PlotRange->{{-3,3},{-3,3},{-1,1}},AxesLabel->{"X","Y","Z"}]
Show[torus[2,1,-Pi/2,Pi/4, Pi/3, 5*Pi/3], PlotRange->{{-3,3},{-3,3},{-1,1}},AxesLabel->{"X","Y","Z"}]

Here is a “piece” obtained by the same rotation of the same arc as in the last plot, but of another generating circle:

Show[torus[3,1,-Pi/2,Pi/4, Pi/3, 5*Pi/3], PlotRange->{{-4,4},{-4,4},{-1,1}},AxesLabel->{"X","Y","Z"}]

Practice on your own:
What is different about the generating circles in the last two plots?

Answer

The generating circle in the latter plot is shifted from the origin by 3 units instead of 2. This makes the resulting torus larger.

Here is our last example of "pieces" of tori. We take a different arc of generating circles that differ only in their radii and  rotate that arc about the  z-axis between the same limits of angle  v:

Show[torus[2,1,-Pi/2,3*Pi/4,Pi/3,Pi],torus[2,0.7,-Pi/2,3*Pi/4,Pi/3,Pi],
torus[2,0.45,-Pi/2,3*Pi/4,Pi/3,Pi],
torus[2,0.2,-Pi/2,3*Pi/4,Pi/3,Pi],PlotRange->All]

Practice on your own:
1) What are the limits for angle  u ?
2) What are the limits for angle  v ?
3) What is different about these four generating circles in the last plot? 
4) What characteristic of a torus does the 2nd parameter of command torus control?

Answers

1)  -Pi/2 to 3Pi/4.
2)  Pi/3 to Pi.
3)  They have different fatness.
4)  Fatness.

Remember:
You will not be able to do Exercise 1(a) without thoroughly understanding Answers to this and previous “Practice on your own” snippets.

Let us now make a movie showing creation of the torus out of the generating circle, as described at the beginning of this Introduction.

(*
This input cell produces an animation "creation1" which will show a "movie" of creation of a torus by rotating a circle around the z-axis. 

The comments below explain what each step of it does. When you make your own "creation" commands later in this Lab, you do not have to write the comments.
 *)

creation1[FromV_,ToV_]:=
(* The arguments of this command are the minimum and maximum values of the parameter v.
The delayed evaluation sign ":=" suppresses the output. 
The output will be generated when some specific values for FromV and ToV are used; see below *)
Animate[Show[torus[2,1,0,2*Pi,FromV,V],PlotRange->{{-3.5 ,3.5},{-3.5,3.5},{-1.5,1.5}}],{V,FromV+0.01,ToV},AnimationRunning->False]

(* 
MAKE SURE THAT YOU READ THE EXPLANATION BELOW AND UNDERSTAND EVERY DETAIL OF IT. IF YOU DO NOT, THEN YOU WILL LIKELY HAVE GREAT DIFFICULTY CREATING SIMILAR COMMANDS IN THE EXERCISE THAT FOLLOWS.

The way that this command works is as follows. 
1) The inner command, i.e., torus[2,1,0,2*Pi,FromV,V],  creates a "piece" of the torus obtained by rotating the generating circle around the z-axis from v-angle FromV to v-angle V.
Note that this "V" is part of the command torus but is NOT part of the overall command creation1. 
2) Command Show simply displays the torus within a desired plotting range.
3) Command Animate plays a movie of the pieces of the torus created in item 1) for continuously increasing "V", whose minimum value is "FromV+0.01" (see below) and maximum value is "ToV". 
For illustration purposes, suppose that Animate increases "V" with a step 0.005. Then the first snapshot of this movie displays the piece with FromV+0.01 ≤ v ≤ "V"=FromV+0.015, the second - with FromV+0.01 ≤ v ≤ "V"=FromV+0.020, the third - with FromV+0.01 ≤ v ≤ "V"=FromV+0.025, etc. (Note that the  v  in the middle of each inequality is not the same as the "V" on the right of that inequality; we use the quotes to make this distinction clearer.) The last snapshot of the movie is for  FromV+0.01 ≤ v ≤ "V"=ToV.
4) Finally, a minor comment: The "+0.01" after "FromV" needs to be there to prevent Mathematica from being "unhappy". (That is, if you remove it,  Mathematica may complain about some error.)
 *)

Execute the next command; the result will be a cell with a slider and four buttons at the top and a figure box. Place the cursor over the slider (the rectangle on the left next to the letter “v”), click and hold the left mouse key,  move the cursor, and observe the result.

creation1[Pi/2,2*Pi]
(* This creates three quarters of a torus, with a slice between v=0 and v=Pi/2 missing. *)

You may now experiment with the buttons on the right of the slider.

Notice that in the above animation, the rotation of the generating circle starts at a plane different from the xz-plane (review the very beginning of the Introduction if you didn’t understand this statement).  
In what plane does it start?  
If you have difficulty answering this question based on the theory of surfaces of revolution, answer it based on inspection of the plot. After that, you should still reflect on how your observed answer agrees with the theory.

Practice on your own:
Use the command creation1 to make an animation showing creation of one half of a torus.  There is more than one way to do it, depending on what you choose as the value for FromV.  Experiment with this, too, and make sure that you understand what difference to your plots the FromV value makes.  Can you produce an animation where the “starting” cross-section of the torus lies in the  xz-plane?

Answer

FromV must be set to 0.

Next, consider a modified version of creation1:

creation1mod[FromVmod_,ToVmod_]:=
Animate[Show[torus[2,1,0,2*Pi,0,V],PlotRange->{{-3.5 ,3.5},{-3.5,3.5},{-1.5,1.5}}],{V,FromVmod+0.01,ToVmod},AnimationRunning->False]

creation1mod[Pi/2, 2Pi]

There is only one difference between creation1 and creation1mod commands, but it leads to a significant difference in the animation produced. 
First, recognize the difference in the animations. 
Then, find the difference in the commands. 
Finally, understand how the difference in the commands leads to the difference in the animations. (If you have difficulty with this step, review the comments made in the Input box where the  creation1  command was defined.) 
Do anticipate that doing this comparison will take you a few minutes. Be patient: this will pay off. In fact, you will not be able to proceed successfully unless you perform the above comparison. 

Practice on your own:
Use the command creation1mod to make an animation showing creation of a full torus starting with the generating circle at the xz-plane.

Here is a command that shows a different manner in which a torus can be created.

creation2[FromU_,ToU_]:=
Animate[Show[torus[2,1,FromU,U,0,2*Pi],PlotRange->{{-3.5 ,3.5},{-3.5,3.5},{-1.5,1.5}}],{U,FromU+0.01,ToU},   AnimationRunning->False];

creation2[Pi/2, 2*Pi]
(* This command shows a "rolling" creation of 3 quarters of a torus. 
 Specifically, one starts at the highest point of the torus 
and ends up at the xy-plane. *)

Here is how the same command can be used to show the creation of the same 3 quarters of a torus by rolling its surface in the opposite direction:

creation2[2*Pi, Pi/2]

Practice on your own - 1:
Using the same command creation2 to produce an animation showing the “rolling” creation of the bottom half of a torus.

Answer

creation2[Pi, 2*Pi].

Practice on your own - 2:
Mimic the manner in which command  creation1mod  differs from  creation1  to make a command  creation2mod  which accomplishes the following: 
Starting with some existing part of a torus, it can append another part of it by producing a rolling motion “along” variable u. 

Use this new command to start with the top half of a torus and complete it to a full torus. 
Note that there will be very little difference between the command producing this animation and the one which you were asked to do in “Practice on your own - 1”; however, the two animations will look quite different.

Answer

creation2mod[FromU_,ToU_]:=
Animate[Show[torus[2,1,0,U,0,2*Pi],PlotRange->{{-3.5 ,3.5},{-3.5,3.5},{-1.5,1.5}}],{U,FromU+0.01,ToU},   AnimationRunning->False];
creation2mod[Pi, 2*Pi].

Exercise 1

In this Exercise, you will continue to explore and exploit the parametric representation of the torus.

(a)   Make a movie that shows creation of the torus in yet another manner. Namely, imagine a thin "inflatable" wire that runs inside the torus along the circle
			(x^2) + (y^2) = (a^2),              z=0 .
Use any value for  a; e.g., it may be the easiest to use the same value  a=2  as above. (Notice that this circle is different from the generating circle in the Introduction.)

Define a new command, creation3, that can "inflate" this wire into the torus. 

Here are some suggestions and hints that you are strongly advised to follow. 

Suggestions / Hints:  

	1.  As in my commands creation1 and creation2, in your command creation3 you should use the command torus  that I have defined, as opposed to writing a new command for that shape. If you write a new command that defines a torus, I will reduce your score. (Reason: The whole idea behind writing a command is to be able to use it for different tasks. So, writing a new command for each new task where an old command can be used, is a waste of time.) 
	
	2.  Make sure to read the theory in the Introduction and understand the role of each of the four parameters of a torus. These roles were illustrated by the several snapshots of tori shown before creation1 command. One of these parameters controls the “fatness” of a torus. It is the same parameter that is “responsible” for the required inflation.
	
	3.  Decide which of the commands: creation1, creation1mod, creation2, or creation2mod, you should mimic creation3 on.  It is critically important that you make the right decision here; otherwise, you will be agonizing for hours over this simple task. 
	Making the right decision should be based on your understanding of the differences between these commands, which requires that you do the “Practice on your own” assignments in the Introduction. If you are uncertain about which of the above four commands you should mimic creation3 on, experiment: try using creation1; if it works - great, if it doesn’t work after trying for some 10 minutes - move on to creation1mod, etc. 

If you are still having difficulty with creation3,  go back to the Introduction and redo all of the “Practice on your own” assignments, as well as answer the questions typed in green after command  creation1mod  was defined.
If doing so twice still doesn’t help, contact me.

Use  creation3  to inflate a torus from the thin wire to some reasonable radius (=”fatness”).

Now use your creation3 command to show a movie of deflation of the torus. (If you have difficulty doing so, return to the Introduction and find a related example there.)

Let me repeat: Use the existing creation3; do NOT write even a slight variation of it. Change only its argument(s). To emphasize my point: 
 	No credit will be given if you perform the deflation 
 		by writing a new creation command.

Clear[a,b,u,v]
(* This clears the above four variables from whatever values have been assigned to them before. They should remain as "free" variables not having any specific values in part (b) below. *)

(b)   Use the theory of Sec. 16.6 to find the surface area of the torus with the arbitrary values of   a  and  b,  where the meanings of parameters  a  and  b  have been defined at the beginning of the Introduction. (Once again: In this part you should not set  a  and  b  to particular values but instead treat them as arbitrary parameters.)

One of the ingredients you will need is the vector   ∂(Overscript[r, ->])/∂u . A convenient way to calculate it in Mathematica is to define  (Overscript[r, ->])  as

r[u_,v_]={(a+b*Cos[u])*Cos[v],(a+b*Cos[u])*Sin[v],b*Sin[u]}

and then take its derivative with respect to  u.  (The notation {...} in Mathematica creates a list of quantities, and a vector is nothing but a list of its own components. This was explained in Lab 2.)

Note that since   ∂(Overscript[r, ->])/∂u   and all the other vectors will be eventually used in a double integral with respect to  u  and  v,  you need to keep defining these vectors as being functions of   u  and  v .

ru[u_,v_]=D[r[u,v],u]
(* If you forgot what "D" stands for, review Lab 4 or 5. *)

rv[u_,v_]=  (write the command here)  

(* Also recall that when you use these partial derivatives (and other functions) below, you should refer to them with their arguments; e.g., as  ru[u,v]^2, not just as  ru^2. Mathematica will be confused if you do the latter and may require clearing all variables before being able to work again. *)

You will now need to find a cross product of certain vectors and then find its length. 
   If you forgot how to do this in Mathematica, consult the Introduction to Lab 2.  
Again, define this cross product to be a function of  u  and  v.  Note that your score will be reduced if at any point in this derivation you use copying/pasting of expressions instead of defining and working with functions. See a comment in Exercise 2 of Lab 4 about that.

At this point, you should obtain an expression that you will need to integrate. 
If you have done everything correctly, then this expression looks like
(Sqrt[(((f(u,v)))^( 2))]), where the  f(u,v)  has a rather simple form. (If it does not, try applying the command  Simplify  to your expression.) 

You may wonder why Mathematica does not take the square root. The reason is that it does not know that   a > b ,  without which taking the square root is ambiguous. For example, try the following command and see what happens:

Simplify[Sqrt[(a-b)^2]]

A way to tell Mathematica what you know about  a  and  b  is by using the option Assumptions, as illustrated below:

Simplify[Sqrt[(a-b)^2],Assumptions->{a>b>0}]

Note that in your case, you will also need to tell Mathematica that  u  is a real number. The corresponding syntax is
	Assumptions  -> { a > b > 0,  Im[u] == 0} .
Note the double equal sign above. 
In some rare cases, I have seen Mathematica needing the condition  Im[v] == 0  to be included within the Assumptions above. You may try to do it if the resulting expression without that condition looks intimidating.

Use the above instructions to obtain the simplified expression for the function that you will integrate, and integrate it to find the surface area of the torus.

Note (which hopefully you will not need):  It may happen that for some reason (e.g., because you made a syntax error), Mathematica "refuses" to give a simple expression for the absolute value that you are about to integrate. I still expect you to produce by hand and use the expression for the absolute value that Mathematica is able to integrate. The issue here should be no more complicated than deciding whether (Sqrt[(((f(u,v)))^( 2))])= +f(u,v)  or  -f(u,v). That is, you have to justify (in writing) whether the  f(u,v)  in your particular case is positive or negative.

Check your answer against one found online. Note that the answer has the dimensions of the area (e.g., feet squared), as a surface area should.

Clear[a,b,u,v]

Note:
Please do not do the “Global” Clearing of variables (i.e., do not execute the Clear[“`*”] command) here or anywhere else in the notebook (except at the very beginning, where it is done already)!
If you do so, all variables, including torus and all creations, will be cleared everywhere in the notebook. This will make the automatic Evaluation of Notebook, which I do to grade your work, stall.

(Bonus 1,  
 25%; credit will be given only for a mostly correct work)    
Use the theory found on the last page of Sec. 15.9 and in the notes for that section to find the volume of the torus with the parameters  a  and  b. 

To begin, you need three coordinates which conveniently parametrize a torus and its inside (similarly to how the angles  θ  and   ϕ  and the distance   ρ  from the center conveniently parametrize a sphere and its inside, i.e. the ball contained inside the sphere). 

In fact, two of such coordinates for the torus are the  u  and  v.  They are the analogs of the angles  θ  and   ϕ  for the sphere.  The third coordinate must then be the analog of  ρ,  and it is the distance from the circle in the xy-plane: 
		(x^2) + (y^2) = (a^2),              z=0 .
to any point inside the torus. In fact, you varied that coordinate in order to make a movie in part (a) of this Exercise. Therefore, if you have difficulty completing this step, review what you did in part (a). A 3D-sketch of the aforementioned circle and the torus around it should also help.

Let us call the coordinate mentioned in the previous paragraph a  w.

Use the answer to the last question above to define the radius vector   (Overscript[r, ->])  as a function of these three coordinates, similarly to how this was done at the beginning of part (b).

Construct the corresponding  3-by-3 Jacobian matrix and name it MyJacobianMatrix  (you should not name it simply a "JacobianMatrix", since that name is already used in Mathematica for related purposes). The following suggestions will help you to complete this step.

A matrix in Mathematica is defined as a "list of vectors", each vector making a row of the matrix. For example, the command

m={{1,2},{3,4}}

defines a 2-by-2 matrix    m = (({{1, 2}, {3, 4}})).
For your purposes, this is very convenient, because the first row of your Jacobian matrix is   ∂(Overscript[r, ->])/∂u ,  the second row is  ∂(Overscript[r, ->])/∂v  , and the third row is  ∂(Overscript[r, ->])/∂w.   Thus, you syntax should be

MyJacobianMatrix[u_,v_,w_]= { ∂(Overscript[r, ->])/∂u ,  ∂(Overscript[r, ->])/∂v , ∂(Overscript[r, ->])/∂w }

where instead of  ∂(Overscript[r, ->])/∂u  etc. you should type their proper Mathematica notations.

Note that you need to define  MyJacobianMatrix  to be a function of those three variables which you have found, because later on you will have to integrate it.

Once you have defined the Jacobian matrix, you need to calculate its determinant. The command is simply

Det[m]

Calculate the determinant of your Jacobian matrix and name it  MyJacobian.  It should also be a function of the three coordinates!

Your Jacobian should be a rather simple function. If it is not, apply the command Simplify to the previous expression.

Finally, find the volume of the torus as the triple integral of the absolute value of the Jacobian. The limits of the integration are just the limits for your coordinates (see the last Answer box above and Equation (1) in the Introduction). You found the volume of another parametric surface in # 21(a) for Sec. 15.9. 
 
To interpret the absolute value of your Jacobian unambiguously, Mathematica needs to know that  a > b > 0.  Supply this information by typing 
	Assumptions  ->  a > b > 0
as the option in the Integrate command (see part (b) or examples in the Help Browser).

If, for any strange reason, Mathematica does not give you a reasonable answer, then obtain this answer by hand: the integration is rather simple.

The answer for the volume of the torus can be found online.

Clear[a,b,u,v]

Exercise 2

In this Exercise, you will deal with a “helical tube”, which is a slightly more complicated object than the torus. The helical tube is, basically, an “inflated helix”. Therefore, before you begin this Exercise, review notes on the equations and graphs of a helix and a helical tube. The material on the helix can be found in Example 4 for Sec. 13.1 in the textbook. The material about the helical tube can be found in an Example in the notes for Sec. 16.6. For reference as to what a helical tube should look like, see the figure next to Example 2 in Sec. 16.6 of the textbook.

(a)    This theoretical introduction is to give the logical steps behind obtaining a helical tube, even though these steps were briefly outlined in the aforementioned Example in the notes (not the textbook!) for Sec. 16.6. 

Consider the same circle in the  xz-plane as was considered at the beginning of the Introduction to this Lab:
	 x = a + b cos u,      y = 0,     z = b sin u; 		0 ≤ u < 2π .
The helical tube is obtained if instead of rotating this circle around the  z-axis, one moves it along a helix, with the helix's axis being the z-axis. 

The parametric equations of such a helix are (see Sec. 13.1):
 	x = p cos v,      y = p sin v,     z = q + c v , 
where the limits
	0 ≤ v < 2π 
yield one coil of the helix,  and the limits
	-∞ < v < ∞
yield the infinite helix.  The parameter  q  determines the z-coordinate of the point at  v=0,  while the parameter  c  determines how fast a point on the helix will move along the  z-axis. 

Combine these two pieces of information (about the circle and the helix), as shown in the notes for Sec. 16.6, and write the parametric equations of the surface of the helical tube.

Plot two coils (i.e., turns) of a helical tube for some values of its parameters:

Note that while the torus has two fixed parameters  a  and  b,  the helical tube has three fixed parameters. The extra parameter, which equals the parameter c  defined above, determines the separation between adjacent coils of the helical tube. 

Assuming that the parameters  a  and  b  are given, find such a value of the parameter  c  that the coils "lie on top" of each other, as in a compressed spring. 

Hint:  If you are not sure were to start, answer the following three questions. Write your answers on a piece of paper!
1) Consider a helix (not a helical tube!) whose equations are stated above. What is the vertical distance between its coils? That is, as you make one full turn around the z-axis, by how much does your z-coordinate change? (Have you recorded your answer?)
2) Now “go back” to the helical tube (with parameters  a  and  b). How “fat” is the tube? That is, what is the distance between the “top” and “bottom” of the cross-section of the tube? (If you have difficulty answering this question, review the role of parameters   a  and  b).
3) Finally, imagine a helix that runs along the centerline inside a tube whose coils “lie on top” of each other. What should the distance between the coils of this helix be in terms of  a  and  b ?  From one of your earlier answers, what is it in terms of  c?
 
Combine your answers to the above questions to answer the original question about the value of  c.

Confirm your answer by making a plot of a helical tube having the parameter  c  you have just found.

(b)    If you have not done so already, make a command analogous to the command torus in the Introduction that can create a helical tube with parameters  a, b and c  and a given number of coils. Name this new command something descriptive, like helicaltube. 

Consider a helical tube with the parameters  
		a=6   and   b=1.
With this choice of parameters, the helical tube looks like a spring. 

Make an animation that shows expansion (i.e., stretching) of 4 coils of this spring along the z-axis, such that:
 (i)  Initially, the centers of the coils are separated by the distance  3 b; and 
 (ii)  At the point of maximum expansion, the centers of the coils are separated by  8 b.  
 Hint:   You will need to use the result that you have derived in part (a). 
 
 Technical notes: 
 1.  Set constant values for the PlotRange so that the entire spring could be seen at all times.
 2.  Set  PlotPoints to 50 inside the command helicaltube (or whatever you have named it), but not inside the Animate command. If you accidentally forget about this, your spring will look jagged during its expansion.

Clear[a,b,c,u,v]

(Bonus 2,
 20%; credit will be given only for a mostly correct work)   
Modify the animation command in part (b) to make a movie that shows sinusoidal (in time) compression and expansion of the same spring. The extents of maximum compression and expansion should be the same as above. The movie should run automatically, without your moving the cursor.  

Hint:  The essential difference between this part and part (b) is the manner in which the parameter controlling the height of the tube varies. For example, in the code  creation1,  the parameter  V  was varied linearly as you moved the cursor, because it is the way the command Animate works.  In this part, your parameter should vary sinusoidally. This means that you need to introduce an auxiliary parameter, say,  t,  so that:
 (i) t  is varied linearly by Animate, and
 (ii) your height-controlling parameter depends on t sinusoidally. To practice, first write down, on a piece of paper, the equation of a sinusoid that oscillates between some given values, say 2 and 7.
    
As far as making your movie run automatically, simply look at the last option of Animate.

(Bonus 3,
20%, no partial credit)
Unfortunately (or, perhaps, fortunately for you :-) ), one cannot obtain an analytical formula in elementary functions for the surface area of one coil of the helical tube. However, one can find the volume of such a coil. Follow the steps of Bonus 1 (see Exercise 1) to find the volume of one coil of the helical tube with parameters  a,  b,  and  c.

This answer, when compared to the corresponding answer for the torus, does look very counterintuitive. Nonetheless, it is true. You may watch the animation you made in part (b), where you can limit your view to just one coil, and try to see why the above answer makes sense. If you are still puzzled, feel free to ask me about it.

Exercise 3 = Bonus 4
(i.e., you don’t have to do it if you don’t want to)
 part (a):  20%;
 part (b):  15%;
for each part, credit will be given only for a mostly correct work.

This is the last Mathematica Exercise in this course, so I tried to make it a little more fun. You will create a baby version of a screen saver that used to be popular with Windows 95 and 98 (if you know what these were :-) ).

(a)     As you remember, the parametric representation of a sphere
			(x^2) + (y^2) + (z^2) = a2 
in spherical coordinates is
	 x = a sin ϕ cos θ ,      y = a sin ϕ sin θ ,       z = a cos ϕ ;
		 0  ≤  ϕ  < π ,      0  ≤ θ  <  2π,      a=const . 
 
Consider a related surface whose Cartesian equation is
 			(x^(2m/k)) + (y^(2m/k)) + (z^(2m/k)) = 1,		(2)
where  m  and  k  are  odd  integer numbers. A member of this family of surfaces is depicted in Fig. III  in the Exercises for Sec. 16.6 in the textbook. 
 
Find parametric equations of this surface. If you have difficulty doing so, consult homework problems 58(a,b), 59, and 60(a,c) for Sec. 16.6.

Write a command that can create such a surface with any  m  and  k  and then plot a member of this family with  m=1  and  k=5.  Make sure that Mathematica plots the entire surface. Set PlotPoints to 30.

Next, try plotting a member of that family that has   m=3  and  k=5.

Instead of a start-like surface obtained in the previous case, you should now see some “triangularish” patch. The reason for this is that Mathematica takes raising negative numbers into fractional powers "too seriously" and obtains complex numbers, which it cannot plot, where you would expect real numbers. For example, you may think that 
		
		(((-(8/27)))^(5/3)) = -(32/243)≈ -0.13,
but Mathematica gives a different answer:

(-8.0/27.0)^(5/3)

Without going into the details as to why Mathematica does this, I simply state the remedy for this problem:

a=-8.0/27.0;
b=Sign[a]*Abs[a^(5/3)]

Clear[a,b]

Modify your plotting command using the above trick and then plot the surface with   m=3  and  k=5.

Now plot the surface with  m=9  and  k=5.  Give a name to this plot.

You may see “cuts” along the equator and a couple of meridians of this surface; just ignore this artifact. It can be fixed by increasing the number of PlotPoints, but at the expense of making Mathematica run slower.

Your last assignment for this part is to modify your command so that it can plot the surface with a shifted center. That is, the coordinates of the center must also become parameters of this command (in addition to  m  and  k). You will need this command in the next part of this Exercise.

Re-plot the previous surface (with   m=9  and  k=5)  with its center being shifted to the point with  (x0=1, y0=2, z0=3), and give a name to this plot.

Plot the last two plots together, so as to see that the second surface is properly shifted relative to the first one.

(b)    Make a parametric plot of the following 3D curve:

	 x = 3 sin t ,    y = 2 cos t + cos(2t) ,     z = 3 cos(3t);
			 0 ≤ t < 2 π .

Based on the concept used in Bonus 2 (see Exercise 2), make a movie that shows a surface given by Equation (2) whose center moves along this curve.   Moreover, as the surface moves, its parameters  m  and  k  must change in the following way:
		m = 11,      k = 7 + 2*Round[7*(1+sin t ) ],
where  Round  is a Mathematica command that rounds a number to the nearest integer.  This will be the "baby screensaver" announced at the beginning of this Exercise.  

Note 1:  Unlike in the previous cases, your screensaver-making command will not have any arguments. 
Note 2:  As the “screensaver” runs, you cannot change the view point of this 3D plot. To change it, stop the animation with a button (see the Introduction), change the view point, and resume the animation.