2. Besides the Monte Carlo method, the Tr value can also be approximated in the following way: 1.1 (1) /4 1 +... 357 2n 1 Using Python, implement the following: 1) Define a function to calculate the TT value as shown in the formula. The function takes one argument which represents the sequence upper bound. For example,set = 4000 and calculate T.Also,use the time module and insert code to the program to measure the running time of the function, i.e., measure the system time once before and another after the function call. 2 Using the threading module, generate 4 threads to concurrently call the function to calculate the value. Similarly, use the time module and insert code to measure the running time of the threads. Note: to have each thread calculate part of the TT value, you need to modify the function and pass two arguments i and j. For example, in the 1st thread, i =1 andj = 1000, and the t1) -1 -12 function calculates -- in the 2nd thread,i=1001 2x1=1 22- 21.00-1 (- (1j20e2 and j=2000,and the function calculates- 2x101= 2x1202 1 2x2000-1
; etc.
(3) Using the concurrent fufures module, generate 4 threads to do the same and measure the program running time as above. (4) Using the umpy module to define the array of the same size (e.g., 4000) and calculate the IT value, and measure the running time.