LAB 1 - HOANG HAI YEN TRAN (SAMMY) - MAT 275
EXERCISE 1
theta = [0,pi/8,pi/6,pi/5,6*pi/5,7*pi/6,8*pi/7];
r = 4;
x = r*cos(theta);
y = r*sin(theta);
plot(x,y);
radius = (x.^2 + y.^2).^(1/2);
Using the Pythagorean Theorem to solve the triangle, we get the more common form of the
equation of a circle such as x2 + y2 = r2. To demonstrate that these forms are equivalent,
consider the triangle on the right of a circle. In the right triangle, we can see that
sin θ=y
r
and
cosθ=x
r
. Recall the trig identity, we have
si n2θ+co s2θ=1
. Substitute
x
r
and
y
r
into the identity, we have
x
r
¿
¿
y
r¿2=1
¿
. Remove the parentheses, we have
x2
r2+y2
r2=1
.
Multiply through by r2, we have x2 + y2 = r2. Therefore, x and y satisfy the equation of a
circle.
EXERCISE 2
t = linspace (1,5,100);
y = (exp(t./5).*cos(2*t))./(0.2*t.^2+18);
figure;
plot(t,y,'b+:')
hold on
title('Plot for y=(e^(t/5)*cos(2t))/(0.2*t.^2+1)');
plot(t,y,'o-')
hold off
EXERCISE 3
t = linspace (0,5,5);
x = 5*cos(6*t);
y = 5*sin(6*t);
z = 7*t;
figure;
plot3 (x,y,z)
grid on
EXERCISE 4
x = linspace(-pi/4,pi/4,4);
y = sin(4*x);
z = (4*x)-((32/3)*x.^3);
figure;
plot (x,y,'r',x,z,'--')
axis tight;
grid on;
hold on
title('Problem #4 Plot');
hold off
EXERCISE 5
x = linspace (0,4,100);
y1 = f (x,100);
y2 = f (x,170);
y3 = f (x,250);
plot (x,y1,'r',x,y2,'--',x,y3,'o-');
title ('The general solutions to dy/dx = -5x-22x^{2}+17cos(x)');
legend ('C=100','C=170','C=250');
function y = f(x,C)
y = (-5/2*x.^2-22/3*x.^3+17*sin(x)+C);
end
EXERCISE 6
a) g = @(x,y) ((x.^2)/(y.^6))+(cos(8*x*exp(9*y)))/(x.^7+5);
g(8,-5)
b) function ghh = g(x,y)
ghh = ((x.^2)/(y.^6))+(cos(8*x*exp(9.*y)))/(x.^7+5);
end
type g.m
g(8,-5)