# How can I estimate or calculate the area of a circular segment?

Given a circle (for simplicity, $x^2 + y^2 = 1$) and a chord on this circle parallel to the $x$ axis $y = p - 0.5$ ($p \in [0,1]$ being the only parameter I control), how can I estimate the relationship between $p$ and the ratio between the circular segment determined by the circle and the chord and the point $(0,-1)$?

I do not require full precision (I only have coarse control over $p$, after all), but if no readily available approximation is available, I'll take the full formula.

In English — I have a circular shape in Powerpoint; I want to color a portion of its area with a given color. Powerpoint doesn't let me color a circular sector using the gradient fill tool, so I have to resort to a gradient section. The alternative is complicating the drawing with the arc tool and its fiddly controls. Thus, I'd like to know what portion of the circle I'd color if I color what's below a chord placed at $p$% height of the circle with red and the remainder in white.

-
Your circle has radius 1, so if you want to fill it to a percentage of its height $p$ the resulting $d$ distance on the Wikipedia picture should be $1-2p$, not $0.5-p$. Edit : and by the way if you make that change your formula does give the answer $0$ for $p=0$. – Vhailor May 29 '11 at 16:06
@Vhailor Obviously; see my edits and the hopefully correct answer below. Thank you. – badp May 29 '11 at 16:09

Edit: I was wrong about the number of times you have to apply $f$ in each case. Corrected below.

If you want to "fill" the area $D$ in a circle of radius $1$, then you want to solve the equation:

$$\cos^{-1} q - q\sqrt{1-q^2} = D$$

Which is the same as:

$$q = \cos(D+q\sqrt{1-q^2})$$

Letting $f(q)=\cos(D+q\sqrt{1-q^2})$, you can use the sequence $0, f(0), f(f(0)), f(f(f(0))), ...$ For the most part you only need to compute $f^{20}(0)$ to get the result you want. You can get a better convergence if you start with $q_0=1-\frac{2D}{\pi}$. Then $f^{12}(q_0)$ is usually close enough.

[This is actually somewhat slower than a binary search for solution $q$, so binary search might be the way to go.]

So, if your want to represent $P\in[0,1]$, take $D=P\pi$, compute $q=f^5(1-2P)$, and your fill percentage is $\frac{1-q}2$.

For example for $P=10\%=0.1$, $D=\frac{\pi}{10}$, $q\approx 0.687$, and you want to fill $\frac{1-q}2 \approx 16\%$

-
Wow, do you really need 20 iterations to get the first three digits? I thought that method was faster than that. – badp May 29 '11 at 16:57
It seems like it, yes. Probably Newton's Method converges much better. – Thomas Andrews May 29 '11 at 18:36

You're making a few trivial errors. Aside from an inconsistent definition of $p$ - the relationship (the equation for the horizontal line) is $y=p-0.5$ at the beginning of your question but $d\equiv y = 1-2p$ at the end of the question, you forgot the coefficient $2$ inside the sine. With this fix, you will get $\pi/2$ for the half-circle.

-

Wikipedia says that for this circle:

the area is: $$A = R^2 / 2 \cdot (\phi - \sin\phi)$$ where:

• $R = 1$ (I'm only interested in the area ratio)
• $\phi = 2 \arccos \frac{d}{R} = 2 \arccos d$
• $d = 2(0.5 - p) = 1 - 2p$ for $p < 0.5$

So I have: $A = \arccos(1 - 2p) - \frac{1}{2} \sin 2 \arccos (1 - 2p), 0 < p < 0.5$

Given that the circle has area $\pi$, the result I seek is:

$$\frac{1}{\pi} \left( \arccos(1 - 2p) - \frac{1}{2} \sin 2 \arccos (1 - 2p)\right), 0 < p < 0.5$$

Wolfram Alpha doesn't suggest simpler versions of this formula. Here's a lookup table for my convenience:

   p → Ratio   |     p → Ratio   |     p → Ratio   |     p → Ratio
0.03    0.01   |  0.16    0.1    |  0.30    0.25   |  0.42    0.4
0.05    0.02   |  0.21    0.15   |  0.34    0.3    |  0.46    0.45
0.1     0.05   |  0.25    0.2    |  0.38    0.35   |  0.5     0.5


If anybody cares, the function can be approximated by $y = 1.27p - 0.135$ for $p \to 0.5$.

In reality, the colored percentage is less than that because of that thick border covering the bottom and top edge of the circle; indeed I initially believed that the relationship was sublinear for low values of $p$, while it's not. I'm afraid accounting for this factor analytically would make the calculations prohibitively expensive for my simple use case, however.

-