Question: Prepare a MATLAB/Octave script that sums n random, single-precision floating-point numbers xi, uniformly distributed in the interval [0, 1]. Sum the numbers in each of

 Prepare a MATLAB/Octave script that sums n random, single-precision floating-point numbers

Prepare a MATLAB/Octave script that sums n random, single-precision floating-point numbers xi, uniformly distributed in the interval [0, 1]. Sum the numbers in each of the following ways (using single-precision variables unless specifically indicated otherwise) (a) Sum the numbers in the order in which they were generated, using a double-precision variable to accumulate the sum. Use a loop to do the summation and not the builtin functiorn accumulator. Use a loop to do the summation and not the builtin function. the numbers in the order in which they were generated (b) Sum the numbers in the order in which they were generated, this time using a single-precision (c) Use the following compensated summation algorithm, again using only single precision, to sum for i = 1 to n do =s s= end for (d) Sum the numbers in order of increasing magnitude (using the builtin sort function). Use a loop to do the summation (after sorting the numbers) and not the builtin function. (e) Sum the numbers in decreasing magnitude (reversing the order obtained in the previous part) Use a loop to do the summation and not the builtin function. Once you check for correctness, extend the previous program to answer the following: (i) Experiment with different values of n and chart your results. Note that you may need to use (i) How do the methods rank in terms of accuracy, and why? You can use the result of the (iii) How do the methods compare in cost? Time the routines for a large n and provide a com- fairly large values of n to see substantial differences. builtin function sum as the true value. Do not use the builtin function for parison (iv) Briefly explain how/why the compensated summation algorithm works

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!