Question: Using python Consider the sum Sy = 2n + 1 = 1,2(n + 1)2 2.1 Write a function sum_s0) which takes 2 input arguments, a
Using python

Consider the sum Sy = 2n + 1 = 1,2(n + 1)2 2.1 Write a function sum_s0) which takes 2 input arguments, a positive integer N and a string direction, and computes the sum Sy iteratively (i.e. using a loop): in the direction of increasing n if direction is 'up', in the direction of decreasing n if direction is 'down'. For instance, to calculate Slo in the direction of decreasing n, you would call your function using sum_s(10, 'down'). [3 marks] In [ ]: We assume that we can compute Sy using this expression without significant loss of precision, i.e. that 2.2 The sum Sy has the closed-form expression Sn = 1- (N + 12 we can use this expression to obtain a "ground truth" value for Sn. Using your function sum_SO, compute Sy iteratively in both directions, for 10 different values of N, linearly spaced, between 103 and 106 (inclusive) For each value of N. compare the results in each direction with the closed-form expression. Present your results graphically, in a clear and understandable manner. [4 marks] In [ ]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
