Question: function NeumaierSum ( input ) var sum = 0 . 0 varc = 0 . 0 , ? ? A running compensation for lost low

function NeumaierSum (input)
var sum =0.0
varc=0.0,??A running compensation for lost low-order bits.
for i=1 to input.length do
vart= sum + input[i]
if | sum || input[i]| then
c sum - t)+ input[i]// If sum bigger, tracks low-order digits of input[i]
else
c +=(input[i]- t)+ sum // Else tracks low-order digits of sum.
endif
sum =t
return sum + c // Correction only applied once in the very end.
It maintains a running sum and also a compensator c that keeps track of things lost to rounding error.
This pseudocode uses modifiable state (the vars).
Question 11. Modify the NeumaierSum pseudocode so that it does not use any modifiable state. In the HW
object, create the function q11() whose input is a Seq[Double] to do this summation. Use the case class
Neumaier (defined at the top in scalahw.scala) to keep track of the state (sum and compensator c). Use
foldLeft (no indexing) to implement the summation algorithm without any loops (if you are stuck, examine
how we used foldLeft in class). The state that foldLeft uses should be a case class Neumaier (so you should
know how to create this thing and how to pull information out of it). Remember Do not use vars!!!. Do not
use the return keyword. You must update the function definition to specify its return type.
 function NeumaierSum (input) var sum =0.0 varc=0.0,??A running compensation for lost

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!