lecture3.mw

> with(plottools):   # if you type : in the end
# then there will be no/less text output

> with(plots):

Warning, the name changecoords has been redefined

Warning, the previous binding of the name arrow has been removed and it now has an assigned value

> cylinderplot(1,theta=0..2*Pi,z=-1..1);

[Plot]

> # OK, let's do the math first,
# if x^2 + y^2 = 1+z^2

# and for a given z we have an x/y plane

# where the ray with angle theta and length r

# projects onto the x and y axis with x and y, respectively,

# by Pythagoras, we have x^2 + y^2 = r^2, i.e.

# r = sqrt(x^2+y^2) = sqrt(1 + z^2) by the above.

# hence

cylinderplot(sqrt(1+z^2),theta=0..2*Pi,z=-1..1);


[Plot]

> # we can give the plot a name, i.e. assign it to
# a variable:

> H := cylinderplot(sqrt(1+z^2),theta=0..2*Pi,z=-2..2);

H := INTERFACE_PLOT3D(MESH(Array( 1..25,1..25,1..3,[ ... ], [ ... ], [ ... ], datatype = float[8], storage = rectangular, order = Fortran_order )), AXESLABELS(x, y, z))H := INTERFACE_PLOT3D(MESH(Array( 1..25,1..25,1..3,[ ... ], [ ... ], [ ... ], datatype = float[8], storage = rectangular, order = Fortran_order )), AXESLABELS(x, y, z))

> display(H); # here it is:

[Plot]

> # let's intersect the Hyperboloid with a plane
# at first, a plane:

> plot3d(1,x=-2..2,y=-2..2);

[Plot]

> P := plot3d(1,x=-2..2,y=-2..2);

P := INTERFACE_PLOT3D(GRID(-2. .. 2., -2. .. 2., Array( 1..25,1..25,[ ... ], [ ... ], datatype = float[8], storage = rectangular, order = Fortran_order )), AXESLABELS(x, y, P := INTERFACE_PLOT3D(GRID(-2. .. 2., -2. .. 2., Array( 1..25,1..25,[ ... ], [ ... ], datatype = float[8], storage = rectangular, order = Fortran_order )), AXESLABELS(x, y, P := INTERFACE_PLOT3D(GRID(-2. .. 2., -2. .. 2., Array( 1..25,1..25,[ ... ], [ ... ], datatype = float[8], storage = rectangular, order = Fortran_order )), AXESLABELS(x, y,

> display(H,P);

[Plot]

> # we need labels for the corrdinate axes,
# let's replot with labels:

> H := cylinderplot(sqrt(1+z^2),theta=0..2*Pi,z=-2..2,axes=BOXED,labels=[x,y,z]);

H := INTERFACE_PLOT3D(MESH(Array( 1..25,1..25,1..3,[ ... ], [ ... ], [ ... ], datatype = float[8], storage = rectangular, order = Fortran_order )), AXESSTYLE(BOX), AXESLABELS(x, y, z))H := INTERFACE_PLOT3D(MESH(Array( 1..25,1..25,1..3,[ ... ], [ ... ], [ ... ], datatype = float[8], storage = rectangular, order = Fortran_order )), AXESSTYLE(BOX), AXESLABELS(x, y, z))

> display(H);

[Plot]

> display(H,P);

[Plot]

> # we need to rotate the plane around the y axis

> # by 90 degrees = 9*Pi/18 (or x-axis)
# the rotate command can do that

# it is called

# rotate(object to rotate, alpha, beta, gamma)

# where alpha, beta, gamma are the angles

# of rotation around the x, y, z axes, resp.

> R := rotate(P,0,9*Pi/18,9*Pi/18):  # beware of the output !

> display(H,R);

[Plot]

> display(H,R);

[Plot]

> # we can see the plane at distance 1
# from the z-axis. It intersects the Hyperboloid

# in two lines.

# Let's see if we can get hold of those two lines:

# the right thing to do is to define a spacecurve,

# which is just a parametrized curve in 3 space.

# The function is

# spacecurve([x(t),y(t),z(t)],t=-...);

> # lets do the math first.
# the curve is in the plane y=1, i.e.

# we substitute y=1 into the equation x^2+y^2-z^2=1

# an get

# x^2=z^2

# i.e.

# x=+z and x=-z

# so, we may parametrize x(t)=t,y(t)=1,z(t)=+-t

> C1 := spacecurve([t,1,t],t=-2..2,color=red,thickness=3): # beware of too much output!

> C2 := spacecurve([t,1,-t],t=-2..2,color=red,thickness=3):

> display(H,R,C1,C2);

[Plot]

> # let's see the hyperbolas.
# no we cut with a plane x=0 to get from

# the equation x^2+y^2-z^2=1

# y^2=z^2+1

# i.e. y = +- sqrt(1+z^2)

# i.e. x(t)=0,y(t) =sqrt(1+z^2),z(t) = t

> C3 := spacecurve([0,sqrt(1+t^2),t],t=-2..2,color=red,thickness=3):

> display(H,C3);

[Plot]

> # let's draw 4 hyperbolas, one in each direction.
# we do that using a list (recall how we

# handled lists in the first lecture?)

> L := []: for i from 0 to 4 do
 L := [ op(L), rotate(C3,0,0,i*9*Pi/18)]:

end:

> display(H,L);

[Plot]

>

> # irem(a, b) gives the remainder r of a upon division by b,
# i.e. the r in a = q * b + r with 0 <= r < b.

# For example,

> irem(17,5);

2

> irem(18,5);

3

> irem(19,5);

4

> irem(20,5);

0

> #however:

> irem(-1,5);


-1

> # so for negative inputs we get a negative remainder
# we need to be aware of that fact.

>

> # this is how we make an if construct:

> if 3 > 2 then print("hello"); end;

> if 2 > 3 then print("hello"); end;

> if 2 > 3 then print("hello"); else print("good-bye"); end;

> # the igcd function computes the greates common divisor (gcd) for integers

> igcd(6,30);

6

> igcd(176654,675364);

2

> igcd(8!,9!+7!);

5040

> # is that correct?
# let us check it:

# 9! + 7! = 7! * (1 + 9 * 8)

# 8! = 8 * 7!

> 1 + 9 * 8;

73

> 7!;

5040

> # since 8 and 73 are relatively prime we have that the gcd is 7!= 5040

>

>

>

>

> HOMEWORK PROBLEMS:

> # hw 1
# the hyperboloid of one sheet admits two sets of

# disjoint lines on it (called rulings).

# They can be obtained from the two lines we

# have drawn above by rotation.

# Plot these lines, but don't plot the

# hyperboloid any more.

# use a list of objects to draw

# as in the last example.

>

> # hw 2
# Plot the Hyperbolic paraboloid x^2-y^2+z = 0

# Using the command spacecurve,

# show that one parabola and one hyperbola

# on the surface.

#

>

> # hw 3
# a) Make a 10 by 10 matrix and fill the entry in row i column j

#    with the gcd of i and j.

# b) Do the same, but this time let the entry (i,j) be the gcd of

#    i! and j!

>

>

>

>

>