Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Its should be done it python and i want the whole code (everything in this assig

ID: 3883466 • Letter: I

Question

Its should be done it python and i want the whole code (everything in this assignment) Its one lab problem so please please complete it and give it to me

1. Introduction In this exercise, we will complete several pieces of Python programs that calculate the value of and compare their performance. 2. Objectives The purpose of this assignment is to give you experience in: Using mathematical formulas in Python. Converting mathematical expressions into Python expressions Refreshing knowledge on function and loops in Python. Doing a little bit study on series based approximation * Note: Before you start, if you are not familiar with i/else statement, for loop, while loop or function in Python, you are recommended to review the sample codes we covered in lecture first 3. Background 3.1. Calculating using series is the ratio of a circle's circumference to its diameter. From the early old days, mathematicians have been trying different methods to calculate the value of . Calculating by using an infinite series is one popular category for approximation. In this lab assignment, we will be implementing two types of series for calculation, namely,

Explanation / Answer

def GregoryLeibniz(n): a = 0 for i in range(n): a = a + ((-1) ** (i)) * (1 / (2 * i + 1)) return a*4 def Nilakantha(n): a=0 k=0 for i in range(1,2*n,2): a=a+(-1)**(k)*4/((i+1)*(i+2)*(i+3)) k+=1 return a+3 ################################################################### #############################4.1################################### n=100 for i in range(n): print(i+1,GregoryLeibniz(i+1),Nilakantha(i+1)) #################################################################### ##################################################################### ###############################4.2################################### pi=3.1415927 accuracy=.001 i=0 diff=1 result=0 while diff>accuracy: i=i+1 result1=result result=GregoryLeibniz(i) diff=abs(result-result1) print("GregoryLeibniz",i,result) result=0 diff=1 i=0 while diff>accuracy: i=i+1 result1 = result result=Nilakantha(i) diff=abs(result-pi) diff = abs(result - result1) print("Nilakantha",i,result)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote