r Problem 2 (bonus/optional): (10 points) Recall that the circumference of a circle of radius r is given by the formula

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

r Problem 2 (bonus/optional): (10 points) Recall that the circumference of a circle of radius r is given by the formula

Post by answerhappygod »

R Problem 2 Bonus Optional 10 Points Recall That The Circumference Of A Circle Of Radius R Is Given By The Formula 1
R Problem 2 Bonus Optional 10 Points Recall That The Circumference Of A Circle Of Radius R Is Given By The Formula 1 (202.91 KiB) Viewed 33 times
r Problem 2 (bonus/optional): (10 points) Recall that the circumference of a circle of radius r is given by the formula C(r) = 2nr, (4) which in turn implies that is exactly the circumference of a circle defined by r=0.5: T=C(0.5). We will turn this insight into a program for numerically computing . Our strategy will be to (i) generate a set of equally spaced points on the circle's boundary, (ii) recognize that these points define a polygon enclosed by the circle, and finally (iii) compute the polygon's perimeter. From the figure, we see that these polygons "approach” the circle as more points are added. Likewise, the perimeter of an N-point polygon will converge to the circle's circumference as N +. Why would we use this strategy? Its easier to measure the perimeter of a polygon than the circumference of a circle. Remember, we are trying to measure , but using the formula (4) (very easy!) is cheating since it assumes t's value to be known. The idea to measure this way is due to Archimedes, so we will call it Archimedes' method. n4 -7 n9 n-10 Your job: Write a Python program to compute n according to Archimedes' method. Now run your code for a polygon with N = 50, 500, 5000, 50000 points and record the estimated value for 7 as a code comment. Provide evidence that an N-sided polygon's perimeter will converge to n as N +. Finally, make a plot showing the set of points (depicted as blue circles) for N = 50 and save it as points.png (from part b; see below). Save your code as code as pi.py. Upload your code and the figure to bitbucket. * To assist with the development of your program, here is a detailed a sketch of the algorithm you may find helpful: (a) Compute N points (Ii,yi) along a circle of radius r = 0.5 according to the formulas I; = 0.5 * cos(2ni/N), Yi = 0.5 * sin(2mi/N), i = 0,1,...,N-1. (5) Let N be an arbitrary integer you set at the top of your program. (b) An important visual test of your program will be to check that these points lie on a circle of radius r = 1/2. Make a plot showing the set of points using N = 50. Plot these points as blue circles and ave this figure as points.png. For full crdit you must use blue circles! (c) Our final step is to measure the perimeter of a polygon defined by N points. Here is a hint to see how we might do this. Lets pretend you are going to walk around the polygon. You start at (20; yo) and walk to (C1, y1). To measure the distance bewteen these two points, you can use the distance formula (21-10)2 + (y1 - y0)2 (6) The entire round-trip (walking aroud the permimeter of the polygon) is accomplished by the "sequence of moves" (10;yo) + (11,7.) + (12,42) +. ... + (IN-1, YN-1) + (20; yo) (7) by moving between neighboring points connected by a straight line. Thus the total length of the path is the -
sum of all the individual distances: CN = V(21-20)2 + (y1 - yo)2 + (12 - 11)2 + (y2 – yı)2 + ... (8) Its up to you to figure out what the full expression for Cn should be. Note: Here's a useful test that you can (and should use while developing your program. Use 4 points and notice that you have an inscribed square (see above figure) defined by the points (.5,0), (0,.5), (5,0), (0.-.5) (9) so our path (-5,0) + (0,.5) + (-5,0) + (0,-.5) + (5,0) (10) has a length of 4 x 0.52 +0.52 2.8284271247461903. This comes from drawing the figure on a sheet of paper, using the distance formula or the Pythagorean theorem, and recognizing that all four sides have the same length.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply