代写 math PIC 10A 3 Homework 4 Due 5 PM, Friday, Nov 1

PIC 10A 3 Homework 4 Due 5 PM, Friday, Nov 1
Problem 1: Monte Carlo Experiments
The Monte Carlo method is used in modeling a widerange of physical systems at the forefront of scientific research today. Lets consider the problem of estimating the area of the region x2 2y2 1 by utilizing the Monte Carlo method. This region is enclosed by a blue ellipse, which is inscribed in a 2 2 red square shown in the figure.
The experiment simply consists of throwing darts on this figure completely at random mean ing that every point in the red square has an equal chance of being hit by the dart. You keep throwing darts at random. All of the darts fall within the square, but not all of them fall within the ellipse. If you throw darts completely at random, this experiment estimates the ratio of the area of the ellipse to the area of the square, by counting the number of darts within each area.
Program this Monte Carlo method to compute the area of the blue ellipse using dierent numbers of darts. For each experiment, use N darts where N 10, 102, , 106, and output the estimated area and the corresponding numerical error estimated areaexact area. The exact area for the ellipse is given by p2 2.22144146907918.
2
A successful run of your code may look like:
Instructions: This program is to give you practice using loops, the random number gen erator, math library, and output formatting. You may not use stdafx.h. Include header comments. Include iomanip to format your output. Name your file monteCarlo.cpp and submit it on CCLE.
estimated area 2.40000
estimated area 2.16000
estimated area 2.18000
estimated area 2.23680
estimated area 2.21072
darts: 10
darts: 100
darts: 1000
darts: 10000
darts: 100000
darts: 1000000 estimated area 2.22037 error 0.00107
error 0.17856
error 0.06144
error 0.04144
error 0.01536
error 0.01072

Due 5 PM, Friday, Nov 1 Homework 4 PIC 10A 3 Problem 2: Random Walk Robot
A robot is initially located at position 0, 0 in a grid 5, 5 5, 5. The robot can move randomly in any of the directions: up, down, left, right. The robot can only move one step at a time. For each move, print the direction of the move and the current position of the robot. If the robot makes a circle, which means it moves back to the original place, print Back to the origin! to the console and stop the program. If it reaches the boundary of the grid, print Hit the boundary! to the console and stop the program.
A successful run of your code may look like:
Down 0,1
Down 0,2
Up 0,1
Left 1,1
Left 2,1
Up 2,0
Left 3,0
Left 4,0
Left 5,0
Hit the boundary!
or
Left 1,0
Down 1,1
Right 0,1
Up 0,0
Back to the origin!
Instructions: This program is to give you practice using the control flow, the random number generator, and output formatting. You may not use stdafx.h. Include header comments. Include iomanip to format your output. Name your file randomWalk.cpp and submit it on CCLE.