# Numerical methods for estimating the circular area in Python

Institute for Environmental and Spatial Analysis...University of North Georgia

## 1   Circle equation

$x^2+y^2=r^2$ where $r$ is the radius.

Rewriting the above equation yields $y=\pm\sqrt{r^2-x^2}.$

## 2   Sweeping algorithm

The basic idea is to split a circle with a radius of $r$ into multiple rectangles with the same base width $dx$ by sweeping a vertical line starting from the left-most point on the circumference at $(-r, 0)$ along the $x$-axis towards the right-most point on the circumference at $(r, 0)$.

There are three ways to calculate the height of each rectangle. Take two points at the current sweeping point $x$ and the next $x+dx$ which compose the width of the current rectangle. We can calculate its height at

1. $x$ (red),
2. $x+dx$ (blue), or
3. $x+0.5\,dx$ (magenta).

We will see how these different approaches work.

## 3   Homework: A biased numerical method for estimating the circular area

Please implement the for and while versions of method 2 (rectangular height at $x+dx$). Submit FirstLastname_circ_area.zip that contains circ_area_for.py and circ_area_while.py to the D2L assignment folder.