% Script P1
% A sine-cosine table for 0,3,6,9,...87,90 degrees

% Using trig identies, compute the cosine and sine of 3 degrees...
c72 = 1/(1+sqrt(5));
c60 = 1/2;
s72 = sqrt(1-c72^2);
s60 = sqrt(1-c60^2);
c12 = c72*c60 + s72*s60;
c6 = sqrt((1+c12)/2);
s6 = sqrt((1-c12)/2);
c3 = sqrt((1+c6)/2);
s3 = sqrt((1-c6)/2);
% Generate the table
c = 1;
s = 0;
clc
fprintf(' x cos(x) sin(x) \n')
fprintf('------------------------------------------------\n')
for k=0:30
% Display the cosine and sine of 3*k degrees...
fprintf('% 3d %20.15f %20.15f\n',3*k,c,s)
% Compute the cosine and sine of 3(k+1) degrees...
ctemp = c3*c - s3*s;
s = c3*s + s3*c;
c = ctemp;
end