Suppose we toss darts randomly at a square dartboard, whose bullseye is at the origin, and...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Suppose we toss darts randomly at a square dartboard, whose bullseye is at the origin, and whose sides are 2 feet in length. Suppose also that there's a circle inscribed in the square dartboard. The radius of the circle is 1 foot, and it's area is square feet. If the points that are hit by the darts are uniformly distributed (and we always hit the square), then the number of darts that hit inside the circle should approximately satisfy the equation number in circle total number of tosses л since the ratio of the area of the circle to the area of the square is 7/4. We can use this formula to estimate the value of with a random number generator: number_in_circle = 0; for (toss = 0: toss x = random double between -1 and 1: y number_of_tosses: toss++) { random double between 1 and 1: distance_squared=x*x + y*y: if (distance_squared <= 1) number_in_circle++: } pi_estimate 4*number_in_circle/((double) number_of_tosses): This is called a "Monte Carlo" method, since it uses randomness (the dart tosses). Write an OpenMP program that uses a Monte Carlo method to estimate . Read in the total number of tosses before forking any threads. Use a reduction clause to find the total number of darts hitting inside the circle. Print the result after joining all the threads. You may want to use long long ints for the number of hits in the circle and the number of tosses, since both may have to be very large to get a reasonable estimate of 7. Suppose we toss darts randomly at a square dartboard, whose bullseye is at the origin, and whose sides are 2 feet in length. Suppose also that there's a circle inscribed in the square dartboard. The radius of the circle is 1 foot, and it's area is square feet. If the points that are hit by the darts are uniformly distributed (and we always hit the square), then the number of darts that hit inside the circle should approximately satisfy the equation number in circle total number of tosses л since the ratio of the area of the circle to the area of the square is 7/4. We can use this formula to estimate the value of with a random number generator: number_in_circle = 0; for (toss = 0: toss x = random double between -1 and 1: y number_of_tosses: toss++) { random double between 1 and 1: distance_squared=x*x + y*y: if (distance_squared <= 1) number_in_circle++: } pi_estimate 4*number_in_circle/((double) number_of_tosses): This is called a "Monte Carlo" method, since it uses randomness (the dart tosses). Write an OpenMP program that uses a Monte Carlo method to estimate . Read in the total number of tosses before forking any threads. Use a reduction clause to find the total number of darts hitting inside the circle. Print the result after joining all the threads. You may want to use long long ints for the number of hits in the circle and the number of tosses, since both may have to be very large to get a reasonable estimate of 7.
Expert Answer:
Answer rating: 100% (QA)
include include int main long long numtosses numhits Read in t... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
Explain the principles underlying the design of catalytic reactors for heterogeneous reactions, considering mass transfer limitations and reaction kinetics.
-
Managing Scope Changes Case Study Scope changes on a project can occur regardless of how well the project is planned or executed. Scope changes can be the result of something that was omitted during...
-
KYC's stock price can go up by 15 percent every year, or down by 10 percent. Both outcomes are equally likely. The risk free rate is 5 percent, and the current stock price of KYC is 100. (a) Price a...
-
George bought the following amounts of Stock A over the years: (Loss amounts should be indicated with a minus sign.) Number of Adjusted Basis $ 7,200 6,270 Date Purchased Shares Stock A 11/21/1993...
-
During 2015, a manufacturer produced 50,000 items that sold for $100 each. The manufacturer had fixed costs of $600,000 and made a profit before income taxes of $400,000. In 2016, rent and insurance...
-
Kinkaid Co. is incorporated at the beginning of this year and engages in a number of transactions. The following journal entries impacted its stockholders equity during its first year of operations....
-
Derive the finite difference equations governing the forced longitudinal vibration of a fixedfree uniform bar, using a total of \(n\) mesh points. Find the natural frequencies of the bar, using...
-
Fox, Dodge, and Gilbey agreed to become limited partners in Palatine Ventures, a limited partnership. In a signed writing each agreed to contribute $20,000. Foxs contribution consisted entirely of...
-
Write a C++ program that calculates the total number of days between two dates (inclusive), which are input by the user, in a format of day month year. For example, if the input is 1 1 2022 and 11 4...
-
Martin Editing Company is a small editorial services company owned and operated by Andrew Martin. On August 31, 20Y1, the end of the current year, Martin Editing Companys accounting clerk prepared...
-
Describe the disparity between anabolic and catabolic reactions and elucidate their common integration within metabolic pathways.
-
An analyst gathered the following information about a company and the market: Using the discounted cash flow (DCF) approach, the cost of retained earnings for the company is closest to: A. 15.7%. B....
-
Which of the following best describes the objectives of Zeros board that the consultant has not yet reviewed? The board should ensure: A. that the assets of the company are used efficiently and...
-
Sandell is interested in the weighted average cost of capital of Kruspa AB prior to its investing in the China project. This weighted average cost of capital (WACC) is closest to: A. 7.65%. B. 9.23%....
-
Refer to Problem 8.6. Chelsea Clinics actual results for 2015 are shown in the table below. a. Construct Chelsea Clinics flexible budget and actual operating results for 2015. b. What are the profit...
-
Which of the following is the most critical activity that an analyst can engage in to assess the quality of the corporate governance system at Zero, among those that the consultant did not review? A....
-
Let f be a non-negative real-valued Lebesgue measurable on R. 1 f(x+n) is Lebesgue integrable on R, then f = 0 a.e. on R. =1 Show that if
-
Find the volume of the described solid S. A frustum of a right circular cone with height h, lower base radius R, and top radius r -r- --R
-
In a lot of 10 components, 2 are sampled at random for inspection. Assume that in fact exactly 2 of the 10 components in the lot are defective. Let X be the number of sampled components that are...
-
The article Effects of Aerosol Species on Atmospheric Visibility in Kaohsiung City, Taiwan (C. Lee, C. Yuan, and J. Chang, Journal of Air and Waste Management, 2005:10311041) reported that for a...
-
Each of three samples has been plotted on a normal probability plot. For each, say whether the sample appears to have come from an approximately normal population. (a) (b) (c) 0.999 0.99 0.95 0.9...
-
Stevenson Company's trial balance as of December 31, 2022 shows \($35,000\) for inventory; but the balance sheet shows \($33,000.\) Assuming no inventory shrinkage, what is the most likely reason for...
-
Amanda Company started business at the beginning of 2022. The company applies the lower-of-cost- or-net-realizable-value rule to its inventory as a whole. Inventory cost and market value as of the...
-
Which one of the following costs is not included in inventory for manufacturing firms? a. Raw materials used in production b. Raw materials unused and stored in the warehouse c. Salary paid to the...
Study smarter with the SolutionInn App