Question
Exercise 2a [PLEASE using like ATOPM editor or Using like this webpage https://paste.ee/p/9QcVt because I cannot recognize your answer correctly! Thank you!] Consider a circle
Exercise 2a [PLEASE using like ATOPM editor or Using like this webpage https://paste.ee/p/9QcVt because I cannot recognize your answer correctly! Thank you!]
Consider a circle enclosed by a square. The ratio of their areas is pi / 4. In this six-part exercise, we will find a way to approximate this value. #Using the math library, calculate and print the value of pi / 4.
Exercise 2b
Consider a circle enclosed by a square. The ratio of their areas is pi / 4. In this six-part exercise, we will find a way to approximate this value. #Using random.uniform(), create a function rand() that generates a single float between -1 and 1. #Call rand() once. So we can check your solution, we will use random.seed() to fix the value called by your function.
Exercise 2c
Consider a circle enclosed by a square. The ratio of their areas is pi / 4. In this six-part exercise, we will find a way to approximate this value. #The distance between two points x and y is the square root of the sum of squared differences along each dimension of x and y. Create a function distance(x, y) that takes two vectors and outputs the distance between them. Use your function to find the distance between x=(0,0) and y=(1,1). #Print your answer.
Exercise 2d
Consider a circle enclosed by a square. The ratio of their areas is pi / 4. In this six-part exercise, we will find a way to approximate this value. #Write a function in_circle(x, origin) that determines whether a two-dimensional point falls within a unit circle surrounding a given origin. #Your function should return a boolean that is True if the distance between x and origin is less than 1, and False otherwise. #distance(x, y) as defined in 2c is pre-loaded. #Use your function to determine whether the point (1,1) lies within the unit circle centered at (0,0). #Print your answer.
Exercise 2e
Consider a circle enclosed by a square. The ratio of their areas is pi / 4. In this six-part exercise, we will find a way to approximate this value. #Create a list of R=10000 booleans called inside that determines whether each point in x falls within the unit circle centered at (0,0). Make sure to use in_circle. #Find the proportion of points within the circle by summing the count of True in inside, and dividing by R. #Print your answer. This proportion is an estimate of the ratio of the two areas!
Exercise 2f
Consider a circle enclosed by a square. The ratio of their areas is pi / 4. In this six-part exercise, we will find a way to approximate this value. #Find the difference between your estimate from part 2e and math.pi / 4. Note: inside and R are defined as in Exercise 2e. #Print your answer.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started