Professional Documents
Culture Documents
1. Calculate the value of the functions sine(x) and cosine(x) for the range 0 < x < 2p.
% Homework #1 Problem 1
%
clear all; clc
xx = [0:2*pi/100:2*pi];
yy = sin(xx); vv = cos(xx);
disp(' xx sine(xx) cosine(xx)')
for I=1:10:length(xx);
fprintf(' %6.3f %6.3f %6.3f \n', xx(I), yy(I), vv(I));
end
plot(xx,yy, xx,vv); xlabel('xx'); ylabel('sin(xx) & cos(xx)');
title('Plot of sine and cosine of xx')
disp(' ')
xx sine(xx) cosine(xx)
0.000 0.000 1.000
0.628 0.588 0.809
1.257 0.951 0.309
1.885 0.951 -0.309
2.513 0.588 -0.809
3.142 0.000 -1.000
3.770 -0.588 -0.809
4.398 -0.951 -0.309
5.027 -0.951 0.309
5.655 -0.588 0.809
6.283 -0.000 1.000
0.8
0.6
0.4
0.2
sin(xx) &cos(xx)
-0.2
-0.4
-0.6
-0.8
-1
0 1 2 3 4 5 6 7
xx
2.
From these results we conclude that Option A is better than Option B, because the total present worth of the
annuity (Option B) is lower than $1 million.
3. Use the command SOLVE:
All the solutions give a zero for the equation (note that 1.0e-015 is the multiplier for all
the roots).
Verify:
>> diff(y1)+5*y2-y1
ans =
1/exp(t)
>> diff(y2)+y2-y1
ans =
0
0
y
-1
-2
-3
-4
-5
0 1 2 3 4 5 6 7 8 9 10
t