Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started