Write a program that demonstrates the correct operation of the described sin_() function. float sin_ (float input_angle) The calculation of this trigonometric value will be performed in a multi-stage process; first a look up table (array) will be built storing the sin() for all values between 0 degrees and 359 degrees using a taylor series. (see https://en.wikipedia.org/wiki/Taylor_series for background and the algorithm to be used). This lookup table is created once and then used when the function is called for the life of the program. The sin_() function will use the lookup table to linearly interpolate between two values of the lookup table to return the answer. (see https://en.wikipedia.org/wiki/Linear_interpolation for background and the equation to be used for linear interpolation). The advantage to this design is the function call is very fast, requiring only some addition and division. Slower calculations, like the calculation of the sin in the lookup table is done only one time during initialization. An example of using a look up table and interpolation: To solve for X = 7 Y = (25(10-7) +100(7-5) ) / (10-5)Y = (75 +200) / 5Y = 55 In this example, the function we are interpolating is Y=X*X. An X value of 7 would give 49, so the Error in using the lookup table and interpolation is: Error = Correct – Measured Error = 49 – 55 = -6 You will find the sin() function calculated as described above with be much closer to actual value. Specific Requirements for the sin_() function: Specific Requirements for the program: Grading Criteria: Example Output. (Note the numerical accuracy may differ depending on your code, the specific compiler used, and the size of operands used) Note. These examples are not exhaustive and do not test all of the functionality described for this homework assignment. [bdavis@localhost hw2]$ ./a.out
-1 [bdavis@localhost hw2]$ ./a.out
0
0.000000 0.000000 0.000000 0.000000
90
90.000000 1.000004 1.000000 -0.000004
180
180.000000 -0.006925 -0.000000 0.006925
270
270.000000 -1.000004 -1.000000 0.000004
359
359.000000 -0.017453 -0.017453 -0.000000
-1 [bdavis@localhost hw2]$ ./a.out <hw2_test_data_1.dat >ofile
[bdavis@localhost hw2]$ gnuplot
gnuplot> plot “ofile” using 1,”ofile” using 2,”ofile” using 3,”ofile” using 4
gnuplot> quit
Arrays, CSE1320, Experience, functions., Numeric, Purpose:, solved, using
[SOLVED] Cse1320 hw2 purpose: experience using arrays and numeric functions.
$25
File Name: Cse1320_hw2_purpose:__experience_using_arrays_and_numeric_functions..zip
File Size: 640.56 KB
Only logged in customers who have purchased this product may leave a review.
Reviews
There are no reviews yet.