Use the CTimer class test two methods for computing powers outlined in Section XXXXXXXXXXThe first method outlined there makes n multiplications to compute xn; the second method makes roughly log2(n)...


Use the CTimer class test two methods for computing powers outlined in Section 5.1.7. The first method outlined there makes n multiplications to compute xn; the second method makes roughly log2(n) multiplications, that is, 10 multiplications to compute x1024 (here x is a double value but n is an int.)


Write two functions, with different names but the same parameter lists, for computing xn based on the two methods. Call these functions thousands of times each with different values of n. For example, you might calculate 3.050, 3.0100, 3.0150 and so on. You’ll need to do several calculations for a fixed n to make a CTimer object register. Plot the values with values of n on the x-axis and time (in seconds) on the y-axis. If you have access to a spreadsheet program you can make the plots automatically by writing the data to an output file.


You should also compare the time required by these two methods, with the time using the function pow from . Finally, you should test both methods of exponentiation using BigInt values rather than double values for the base (the exponent can still be an integer.) You should try to explain the timings you observe with BigInt values which should be different from the timings observed for double values.

Nov 25, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here