Given an area, calculate the angle of a wedge out of an annulus between a square and a circle If we have a shape similar to this picture:

Where the square length is less or equal to the circle's diameter, then I believe the term for the blue area is the annulus.
I was wondering if it is possible to construct a formula to calculate the angle of a wedge, given a starting angle and an area.
Here is an example for a cut of 0-45 degrees:

to clarify what I mean by 'wedge'
I am a programmer, but unfortunately maths in not my strong point, but I did my best attempt before turning to stack-exchange. I have created a brute-forcer to solve this, but am curious to see if there is a better mathematical solution.
My current method of calculation simply increases/decreases the end angle until a valid solution is found. Here is the process
Calculate the area of a slice between the begin-angle and the end-angle.
Calculate the area of a slice of a square by splitting it into triangles.
Subtract the square-slice from the circle slice, check if the area is correct
Change the end-angle if area is incorrect.
I would appreciate any insights into a mathematical solution that doesn't involve brute force.
 A: EDIT: It seems you'll need a root-finding algorithm for this problem. If you have a formula for the area of the annulus as a function of $\theta$, you could also try using a root-finding algorithm on that. The only convenience my answer offers is that the formulas are simpler.

The basic idea I have is to break the angle $\theta$ you're looking for into two parts: $\theta_{offset}$, which is the angle rounded down to the nearest quarter-turn, and $ \theta_{left\ over}$, which is the remaining part of the angle.

Let $A(\theta)$ be the area of the annulus through an angle $\theta$.
Let $r$ be the radius of the circle.
Let $2s$ be the side-length of the square, so that the large square can be divided into four smaller squares of side-length $s$ and area $s^2$.

Each time you travel a quarter-turn, or an angle of $\theta  = \frac{\pi}{2}$, the total area will increase by
$$ A_{\frac{\pi}{2}} = \frac{\pi}{4} r^2 - s^2 $$
So the first thing to do is find how many quarter-turns you've traveled and multiply that number by $\frac{\pi}{2}$ to get $\theta_{offset}$:
$$N_{\frac{\pi}{2}} = \Bigl\lfloor \frac{A(\theta)}{ A_{\frac{\pi}{2}} } \Bigr\rfloor$$
$$\theta_{offset} = N_{\frac{\pi}{2}} \cdot \frac{\pi}{2}$$
Next, we need to find the "left-over" angle that has not yet traveled through a quarter-turn, which will obviously be in the interval $0 < \theta_{left\ over} < \frac{\pi}{2}$.
Define $\ \ \ \ A_{left\ over} = A(\theta) - (N_{\frac{\pi}{2}} \cdot A_{\frac{\pi}{2}})$
If $A_{left\ over} \leq A_{\frac{\pi}{2}}/2$, then we know the left over area is the result of a circular wedge or radius $r$ and angle $\theta_{left\ over}$ minus a triangle with base $s$ and height $s \cdot \tan(\theta_{left\ over})$.
$$A_{left\ over} = \frac{1}{2} \theta_{left\ over} r^2 - \Big[ \frac{s^2 \tan(\theta_{left\ over})}{2} \Big]$$
Otherwise, if If $A_{left\ over} > A_{\frac{\pi}{2}}/2$, then we know the leftover area is the result of a circular wedge minus a square $s^2$ with the aforementioned triangle subtracted from it.
$$A_{left\ over} = \frac{1}{2} \theta_{left\ over} r^2 - \Big[ s^2 - \frac{s^2 \tan(\frac{\pi}{2} - \theta_{left\ over})}{2} \Big]$$
Unfortunately, $\theta_{left\ over}$ doesn't seem to have a simple analytical solution. The best thing I can think of is to use a root-finding algorithm like Newton's method to try and find the $\theta_{left\ over}$ which solves the first or second equation for the two above cases, respectively.
$$0 = \frac{1}{2} \theta_{left\ over} r^2 - \Big[ \frac{s^2 \tan(\theta_{left\ over})}{2} \Big] - A_{left\ over}$$
$$0 = \frac{1}{2} \theta_{left\ over} r^2 - \Big[ s^2 - \frac{s^2 \tan(\frac{\pi}{2} - \theta_{left\ over})}{2} \Big] - A_{left\ over}$$
The angle you want is simply
$$\theta = \theta_{offset} + \theta_{left\ over}$$
A: I'm referring to the following figure:

Denote the side length of the square by $2s$, where it is assumed that $\sqrt{2}s<r$. Draw the two main diagonals, and let the wedge $W$ in question begin at an angle $\theta\in\bigl[0,{\pi\over2}\bigr[\ $ after a diagonal ray, and then proceed in counterclockwise direction. The area of the small wedge between this last diagonal ray and the beginning of $W$ is then given by
$$a(\theta):={r^2\over2}\theta-s^2{\sin\theta\over\cos\theta+\sin\theta}\qquad\left(0\leq\theta<{\pi\over2}\right)\ ,$$
as can be verified using elementary geometry. Let $A$ be the given area of the wedge $W$, and put
$$A':=A+a(\theta)\ .$$
The quantity $A'$ then denotes the total area of the wedge $W'$ whose beginning ray would have been the last diagonal ray. Let
$$Q:={\pi r^2\over4}-s^2$$
be the area of a wedge enclosed between two successive diagonal rays, and put
$$n:=\left\lfloor{A'\over Q}\right\rfloor\ .$$
It follows that
$$A'':=A'-nQ$$
is the overflow of area after $W'$ as well as the given wedge $W$ have crossed their final diagonal ray. Solve by whatever numerical methods the equation
$$a(\delta)=A''$$
for $\delta\in\bigl[0,{\pi\over2}\bigr[\ $, and denote the solution by $\theta^*$. The total central angle $\omega$ of the given wedge $W$ is then  given by
$$\omega:=\theta^*+{n\pi\over2}-\theta\ .$$
