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

Determining ? Experimentally: Recall that ? is the ratio of a circle\'s circumfe

ID: 3550702 • Letter: D

Question

Determining ? Experimentally:

Recall that ? is the ratio of a circle's circumference to its
diameter and that we can calculate the area of a circle with the
formula A=?r2. Below is a circle enscribed within the unit
square.



What is the ratio of the areas of the enscribed circle to that of

the unit square?


If we pick a random point within the unit square what is the

probability that the point will also lie within the circle?


If we repeat this experiment an arbitrarily large number of times the

ratio of the number of points which lie within the circle to the number

of points within the unit square (all of them) will approach ?/4.


Using the language structures we have discussed write a program that

will do the above experiment an arbitary (determined at run-time)

number of times and report back the approximate value of ?.

Determining? Experimentally: Recall that ? is the ratio of a circle's circumference to its diameter and that we can calculate the area of a circle with the formula A = ?r2. Below is a circle enscribed within the unit square. What is the ratio of the areas of the enscribed circle to that of the unit square? If we pick a random point within the unit square what is the probability that the point will also lie within the circle? If we repeat this experiment an arbitrarily large number of times the ratio of the number of points which lie within the circle to the number of points within the unit square (all of them) will approach ?/4. Using the language structures we have discussed write a program that will do the above experiment an arbitary (determined at run - time) number of times and report back the approximate value of ?.

Explanation / Answer

#include <iostream>

#include<tgmath.h>

#include<stdlib.h>


using namespace std;



int main()

{

int num;

cout<<"enter number of times the experiment to be repeated"<<num;

cin>>num;


double x[num];

double y[num];


int i;

for(i=0;i<num;i++)

{

x[i]=rand() % 1000;


x[i]=x[i]/1000;

cout<<" "<<x[i]<<endl;

y[i]=rand() % 1000;


y[i]=y[i]/1000;

cout<<" "<<y[i]<<endl;


}


int count=0;


for(i=0;i<num;i++)

{

double val1,val2;

val1=pow((x[i]-0.5),2);

cout<<" "<<val1;

val2=pow((y[i]-0.5),2);


if(val1+val2-0.25>=0)

count=count+1;


}


cout<<" "<<count<<endl;

double val;

val=4*count/num;

cout<<"value of pi is approx. "<<val<<endl;






}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote