% 1(a)
format long
z = 2 - 3i;
x = 2;
y = -3;

m = e^x * ( cos(y) + i * sin(y) );
n = exp(x) * ( cos(y) + i * sin(y) ); 
m - n


% 1(b)
function (r, t)=f1( z )
endfunction


% 1(c)
log(-1)

% 3
%Write a function that calculates the angle between 2
% vectors in R^3 according to:
% cos(Theta)=(x dot y) / Norm(X)_2 times Norm(Y)_2

function [a]=hw1prob3(V1, V2)
format rat
a = acos( dot( V1, V2 ) / (norm( V1 ) * norm( V2 )) );
endfunction

% 7
%The _hypotrochoids_ are curves given by the following parametric equations:
% x= (R-r) * cos(t)  + d * cos( (( R - r )/r) * t )
% y= (R-r) * sin(t)  + d * sin( (( R - r )/r) * t )
% for 0<=t<=Kpi.  Write a MATLAB function that plots a
% hypotrochoid with parameters R, r, d, and K.  Let R=1,
% d=1.2, and K=18 and plot the hypotrochoids corresponding
% to r=0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1, and 0.05.
% Describe a mechanical way to trace a hypotrochoid with
% pen and paper and give a geometrical interpretation to the
% parameters R, r, d, and K.
function hw1prob7( R, r, d, K )
  z=K*pi;
  t=[0:0.1:K * pi ];
  x= (( R - r ) * cos(t)) + ( d * cos( (( R - r )/r) * t ));
  y= (( R - r ) * sin(t)) + ( d * sin( (( R - r )/r) * t ));
  plot( x, y, "-;Hypotrochoid;" );
endfunction
R=1; d=1.2; K=18;
hw1prob7( R, 0.9, d, K );
%print -djpeg "HW1P7-Surface-0.9.jpg"
hw1prob7( R, 0.8, d, K );
%print -djpeg "HW1P7-Surface-0.8.jpg"
hw1prob7( R, 0.7, d, K );
%print -djpeg "HW1P7-Surface-0.7.jpg"
hw1prob7( R, 0.6, d, K );
%print -djpeg "HW1P7-Surface-0.6.jpg"
hw1prob7( R, 0.5, d, K );
%print -djpeg "HW1P7-Surface-0.5.jpg"
hw1prob7( R, 0.4, d, K );
%print -djpeg "HW1P7-Surface-0.4.jpg"
hw1prob7( R, 0.3, d, K );
%print -djpeg "HW1P7-Surface-0.3.jpg"
hw1prob7( R, 0.2, d, K );
%print -djpeg "HW1P7-Surface-0.2.jpg"
hw1prob7( R, 0.1, d, K );
%print -djpeg "HW1P7-Surface-0.1.jpg"
hw1prob7( R, 0.05, d, K );
%print -djpeg "HW1P7-Surface-0.05.jpg"


% 9(a)
x = -3:0.1:3;
y = -3:0.1:3;
[X,Y]=meshgrid( x, y );
z = abs( X ) + abs( Y );
surf( x, y, z );
%print -djpeg "HW1P9a-Surface.jpg"

% 9(b)
x = -3:0.1:3;
y = -3:0.1:3;
[X,Y]=meshgrid(x, y);
z = abs( X .* Y );
surf( x, y, z );
%print -djpeg "HW1P9b-Surface.jpg"

% 9(c)
x = -3:0.1:3;
y = -3:0.1:3;
[X,Y]=meshgrid(x, y);
z = X .* (Y .^2) - X .^3;
surf( x, y, z );
%print -djpeg "HW1P9c-Surface.jpg"

% 9(d)
x = -3:0.1:3;
y = -3:0.1:3;
[X,Y]=meshgrid(x, y);
z = ((X) .* (Y .^3)) - ((Y) .* (X .^3));
surf( x, y, z );
%print -djpeg "HW1P9d-Surface.jpg"

% 9(e)
x = -3:0.1:3;
y = -3:0.1:3;
[X,Y]=meshgrid(x, y);
z = ( X .^2 ) .* ( Y .^2 ) .* ( e^((-(X .^2))-(Y .^2)));
surf( x, y, z );
%print -djpeg "HW1P9e-Surface.jpg"

% 9(f)
axis( [-3, 3, -3, 3, -3, 3] );
x = -3:0.1:3;
y = -3:0.1:3;
[X,Y]=meshgrid(x, y);
z = sin( X .^2 + Y .^2 );
surf( x, y, z );
%print -djpeg "HW1P9f-Surface.jpg"

