CORDICbased approximation of sine and cosine
[
y
, x
]
= cordicsincos(theta,niters)
[
computes
the sine and cosine of y
, x
]
= cordicsincos(theta
,niters
)theta
using a CORDIC algorithm approximation. y
contains
the approximated sine result, and x
contains
the approximated cosine result.





CORDICbased approximated sine of 

CORDICbased approximated cosine of 
The following example illustrates the effect of the number of
iterations on the result of the cordicsincos
approximation.
wrdLn = 8; theta = fi(pi/2, 1, wrdLn); fprintf('\n\nNITERS\t\tY (SIN)\t ERROR\t LSBs\t\tX (COS)\t ERROR\t LSBs\n'); fprintf('\t\t\t \t \t\t\t \t \n'); for niters = 1:(wrdLn  1) [y, x] = cordicsincos(theta, niters); y_FL = y.FractionLength; y_dbl = double(y); x_dbl = double(x); y_err = abs(y_dbl  sin(double(theta))); x_err = abs(x_dbl  cos(double(theta))); fprintf(' %d\t\t%1.4f\t %1.4f\t %1.1f\t\t%1.4f\t %1.4f\t %1.1f\n', ... niters, y_dbl,y_err, (y_err * pow2(y_FL)), x_dbl,x_err, ... (x_err * pow2(y_FL))); end fprintf('\n'); 
The output table appears as follows:
NITERS Y (SIN) ERROR LSBs X (COS) ERROR LSBs        1 0.7031 0.2968 19.0 0.7031 0.7105 45.5 2 0.9375 0.0625 4.0 0.3125 0.3198 20.5 3 0.9844 0.0156 1.0 0.0938 0.1011 6.5 4 0.9844 0.0156 1.0 0.0156 0.0083 0.5 5 1.0000 0.0000 0.0 0.0312 0.0386 2.5 6 1.0000 0.0000 0.0 0.0000 0.0073 0.5 7 1.0000 0.0000 0.0 0.0156 0.0230 1.5
[1] Volder, JE. “The CORDIC Trigonometric Computing Technique.” IRE Transactions on Electronic Computers. Vol. EC8, September 1959, pp. 330–334.
[2] Andraka, R. “A survey of CORDIC algorithm for FPGA based computers.” Proceedings of the 1998 ACM/SIGDA sixth international symposium on Field programmable gate arrays. Feb. 22–24, 1998, pp. 191–200.
[3] Walther, J.S. “A Unified Algorithm for Elementary Functions.” HewlettPackard Company, Palo Alto. Spring Joint Computer Conference, 1971, pp. 379–386. (from the collection of the Computer History Museum). www.computer.org/csdl/proceedings/afips/1971/5077/00/50770379.pdf
[4] Schelin, Charles W. “Calculator Function Approximation.” The American Mathematical Monthly. Vol. 90, No. 5, May 1983, pp. 317–325.