kyle_hw9 kyle_hw9 accepts a list of floating point numbers between 0 and 1 from standard input or by arguments. It calculates sines using the CORDIC algorithm, maclaurin approximation, and the library sine function. The results are sent to stdout. The first column shows the inputted value. The second column shows the CORDIC value. The third column shows the Maclaurin value. And the fourth column shows the C library sin() value. main.c contains a constant MAXINP that defines how many values can be entered into the program at a time. You can adjust this however you please, just keep in mind how much memory you have on your machine. EXAMPLE > ./kyle_hw9 .5 .832 .342 0.500000 0.479426 0.479426 0.479426 0.832000 0.735131 0.739279 0.739280 0.342000 0.335258 0.335372 0.335372 > ./kyle_hw9 < test 0.200000 0.198620 0.198669 0.198669 0.400000 0.389046 0.389418 0.389418 0.583000 0.550460 0.550531 0.550531 0.384000 0.374499 0.374632 0.374632 0.001400 0.001401 0.001400 0.001400 0.938000 0.796402 0.806375 0.806377 0.104800 0.104596 0.104608 0.104608 0.240000 0.237479 0.237703 0.237703 0.010000 0.009999 0.010000 0.010000 0.001000 0.001000 0.001000 0.001000 0.540000 0.514128 0.514136 0.514136 0.230000 0.227802 0.227978 0.227978 0.424000 0.410668 0.411410 0.411410 0.583400 0.550794 0.550865 0.550865 0.384100 0.374590 0.374725 0.374725 0.001500 0.001500 0.001500 0.001500 0.939000 0.796932 0.806966 0.806968 0.108800 0.108570 0.108585 0.108585 0.220000 0.218103 0.218230 0.218230 0.002000 0.002000 0.002000 0.002000 0.005000 0.005000 0.005000 0.005000 0.550000 0.522671 0.522687 0.522687 Elapsed Time: 0 seconds > VALIDATION The binary float values were tested by comparing strings of 1's and 0's created by the function with strings generated with a binary converter program located at: http://www.exploringbinary.com/binary-converter/ Sine values were compared to those calculated by Wolfram Alpha. EXECUTION SPEED Speed tests were done with the file 'test' containing 100,000 values. Method Time (seconds) -------------------------- CORDIC 0.34 Maclaurin 0.07 sin(x) 0.09 _all_ 0.37 _none_ 0.12 _all_+print 1.28 As you can see, both the C library sin() and the Maclaurin polynomial were computed so fast, that their computation time is virtually indistinguishable from the time it took to process the input. It makes sense that the maclaurin should be fast given that it only has to do 7 multiplications, 3 divisions, 2 additions, 1 subtraction and an assignment. I would estimate each computation took less than a microsecond. The CORDIC, on the other hand, had to do a lot more work. Nevertheless, to complete 100,000 computations in 0.34 seconds requires that each computation take 3.4 microseconds. ACCURACY The descrepancies between actual values and calculated values for CORDIC are probably primarily due to loss of precision in my precomputed values for sine and cosine. Error may have also cropped up as an effect of truncation in the conversion from double to binary array. The equivalent of a 32 bit binary number can only represent so many decimals. `sizeof(double)` returns 8 on my system, indicating double is 64 bits, twice the precision I am storing for my values.