Write a program and estimate pi using 400, 4000, 40000, 4000

Consider a dartboard of radius 1. Since the area of the board will be  π r2 = π * 1 *1, it's clear the area of the dartboard is exactly π. The area of a square surrounding the board (circumscribing it) would be 2*2 = 4, since the diameter or the dartboard is 2 (twice the radius) and the diameter equals length of a side of the square. Now, if we introduce a set of darts, where the x and y range from -1 to +1, we simulate a random sampling of all positions on the square surrounding the dartboard, some on the board and some of the square surrounding it. You can determine whether the dart hit the board or not by simply calculating if its distance from the center of the dartboard is greater than 1 (off the board) or <=1 (on the board). If we toss 4 darts, corresponding to area of the square, we will expect π darts, on average, to hit inside the dartboard and the remainder to miss. By extension, if we toss 40000 darts, 10000*π  should hit the dartboard. We can use this largest set to give us a decent estimation.

 

   Related Questions in Programming Languages

  • Q : Define Certificates Define Certificates

    Define Certificates: They are digital documents attesting to the binding of a public key to an individual or another entity. They permit verification of the claim which a given public key does in fact fit in to a given individual. The certificates hel

  • Q : Differentiate overriding and

    Differentiate overriding and overloading method?

  • Q : How can you highlight several goodies

    How can you highlight several goodies or addons the Orbeon?

  • Q : Walk through the steps essential to

    How can you walk through the steps essential to parse XML documents?

  • Q : Java program to sort ten numbers using

    Q. Write a java program to sort ten numbers using bubble sort method. Ans. class Bubble sort

    Q : Define Swapping Swapping : An

    Swapping: An {operating system} is frequently able to run programs which need more memory than is physically accessible on the host system. In order to do this, the complete memory needed is broken down into smaller pieces that are swapped in whenever

  • Q : What is Dotted decimal notation Dotted

    Dotted decimal notation: The notation employed to symbolize the 4-byte values of an IP address. Each and every byte is symbolized as a value between 0 to 255, for instance 129.12.0.1. The most noteworthy byte is written at first.

  • Q : Define Continuous simulation Continuous

    Continuous simulation: In a continuous simulation, the time ticks past at a regular rate which is applicable to the specific simulation scenario. At each and every tick, all the objects in the simulation are informed of the passage of time and updated

  • Q : What is Datagram Datagram : It is a

    Datagram: It is a packet of information passed between the two communicating procedures across a network. Both the Transmission Control Protocol (abbreviated as TCP) and the User Datagram Protocol (abbreviated as UDP) are indirectly comprised in sendi

  • Q : What are tools require View XHTML

    What are tools require View XHTML Documents?

©TutorsGlobe All rights reserved 2022-2023.