Please write a C++ program 1. Pi (?) The mathematical constant Pi is an irrational number with
Question:
Please write a C++ program
1. Pi (?)
The mathematical constant Pi is an irrational number with valueapproximately 3.141592... The precise value of this constant can beobtained from the following infinite sum:
Pi2 = 8 + 8/32 + 8/52 + 8/72 + 8/92 + ...
(Pi is of course just the square root of this value.)
Although we cannot compute the entire infinite series, we get agood approximation of the value of Pi2 by computing the beginningof such a sum.
Please use both iterative way and recursive way in two differentfunctions to solve this problem. Write two functionsapproxPIsquared_iter() and approxPIsquared_recur() that takesnumbers included in the series as input and approximates constantPi2 .
Moreover, please use ctime to estimate how long does the processtake in both ways.
Notes:
1. The values returned by the functions are Pi2 , don?t forgetto find the square root.
2. Output the Pi to 12 decimal places.
Output :