Laboratory 3

1. Plot3d sin(x)*cos(y), sin(x)/cos(y), sin(y)*cos(x) and all other combinations possible.

2. Plot3d sin(x)/y, sin(y)/x , sin(x)*y and all other possible trigonometric functions.

3. Try to experiment with all the menu options in the plot3d command.

4. Draw a cube, sphere, cylinder, cusp paraboloid and other surfaces of revolution.

5. Plot a circle with center at (3,3).

6. Generate 100 random points in the range with x co-ordinates between (0,6) and y co-ordinates. Plot these points.

7. Plot the points as well as the circle. How many points lie inside the circle? count them or write a statement to compute it.

8. Repeat this with 1000 points. The ratio of the number of points inside the circle to the total number of points is a good approximation for the area of the circle. (This is also known as Monte Carlo method.)

#Hint for the generation of random Points
#and for finding area
#This does for calculating the area of a circle centered at (2,2) with
# radius 1.

randnum := rand(1..100000);
# r generates random numbers between 1 and 3
 r := proc()
    x := randnum();
     evalf(x/50000 + 1);
 end;
generate:= proc(n)
           x:= array(1..2*n);
           icount:=0;
           inside := 0;

for i from 1 by 1 to n do
icount:=icount+1;
y := r();
x[icount] := y;
temp:=(x[icount]-2)^2;
icount:=icount+1;
y := r();
x[icount] := y;
temp:= temp +(x[icount]-2)^2;
#
# temp calculates the sum of x^2+y^2 for the generated random point
#
if (temp <=1) then inside:=inside+1;
fi;
od;
print(evalf(inside/n));
end;

9. Repeat this by drawing an ellipse with the center (3,3), the major axis is of 6 units and the minor axis is 2 units long.