Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database In Depth Relational Theory For Practitioners

Authors: C.J. Date

1st Edition

0596100124, 978-0596100124

More Books

Students also viewed these Databases questions

Question

Define Benfords Law.

Answered: 1 week ago

Question

What do Dimensions represent in OLAP Cubes?

Answered: 1 week ago