Sale!

# Scientific Programming Assignment 2

\$35.00

Category:

CSc 30100 – Scientific Programming

CSc 30100

1
Calculate 19 .
You should use math.sqrt(19.0) for the value of 19.
Calculate using the two methods we discussed in class,
naive summation and compensated summation. Perform the
summation
N
N
i
N
S
S
=
=   ∑ 
34567 8
8
s for N = 10 ,10 ,10 ,10 ,10 , and 10 . If the
summations for 10 take more than an hour, you can skip
those.
2

Calculate the time of each summation using code such as
start_time = time.time()
end_time = time.time()
elapsed_time = end_time start_time −
3

Calculate the “exact” value of the sum using the expression
*math.sqrt(19.0)
For each of the that you calculate, determine the absolute
and relative errors of the results. Present your resu
N
N
S N
S
= 
lts (including
the timing of your calculations) in a table.
Analyse you results as thoroughtly as you can and discuss them.
Are these errors consistent with the expressions for errors that we
discussed in class and that are in the posted classroom
presentations? How do the speeds of the two methods compare?
4

5 Scientific Programming Assignment 2