## CS8 Programming Assignment 2In this Programming Assignment you will write two functions which take an integer argumentm and compute
an approximate value of π and returns it.
The accuracy of the computed π for each function will depend
on the value of the integer n which is the number of
terms in the formula for π. If we take infinitely many
terms, we can compute π exactly.
- The first function will be based on Leibniz formula:
Since taking infinitely many terms is outside our ability, we can take finitely many terms, which is determined by the integer argument `m`. The function will be named as`LeibnizPi(m)`and will compute π as accurately as needed by selecting a larger value of`m`For example, if we take `m=4`, we will have the following approximation for πwhich is a bad approximation. If we need better approximations, we will need to take larger values of `m`. You are required to write the Python function`LeibnizPi(m)`that computes and returns π by taking`m`as the parameter. - The second function will be named as
`BaselPi(m)`and will be based on the Basel formulaBy taking `m`terms we compute an approximate value of π using the`BaselPi(m)`function as follows:You are required to write the Python function `BaselPi(m)`that computes and returns π by taking`m`as the parameter.
LeibnizPi(m) and BaselPi(m)
inside the Python file pa2.py and submit your file using the
Dropbox link. Your functions will be tested using random values of m.
Do not use any modules, including math in your programs.
cs8 web page |