Length of a Circle: Iterative Numerical Approximation (Exercise)

The equation of a general circle centered at the point

$$ c = (c_x, c_y)$

with radious $$ r$ is

$$ (x-c_x)^2+(y-c_y)^2 = r^2 $$

it is known that its length is $$ L = 2\pi r $$. We want to approach the actual length by an increasing value of the inscrived polygon length.

Contents

Approximate the length of a circle up to a desired precission

The question now is to compute how many points are needed to approximate the actual length of the circle with the perimeter of the inscrived polygon. For that, we will use a modification of the previous script (V1), following the next steps:

Step 1.

Define a Tolerance precission variable $$tol = 1.e-5$

Initialize the numPoints variable to 8.

Step 2.

Using a while loop until the absError is less than the tolerance

while(absError > tol)

generate the points
compute the present Length
compute the present absError
increment numPoints

end

Step 3.

Show in the commad window the computed value for the numPoints variable.

Solution=

For radious r = 10 and Tol = 1.e-5;

numPoints= 3215 are needed

(c) Numerical Factory 2017