Let's take a look back at this familiar "Law of cosines":
Consider the triangle $\triangle ABC$. Let $a = BC, b = AC, c = AB$; $\angle A, \angle B, \angle C$ are the angles of the triangle opposite to side $a, b, c,$ respectively. By the Law of Cosines: $$a^{2} = b^{2} + c^{2} - 2bc \cdot \cos \angle A$$
This formula can apply for any triangle.
But what about quadrilaterals? Is there a formula, which shows the relationship between sides and angles, similar to the Law of Cosines? Can we extend the Law of Cosines???
This is the way to approach the formula for quadrilaterals (It's not (really) a proof):
Given the quadrilateral ABCD. Let $a = BC, b = CD, c = AB, d = AD$. Let $E = AB \cap CD$ and $G = AC \cap BD$
Let consider $\triangle ABC$ as a "special quadrilateral" (where $d=0$). Then by the Law of Cosines:
$$a^{2} = b^{2} + c^{2} - 2bc \cdot \cos \angle BEC = b^{2} + c^{2} - 2bc \cdot \cos \angle BGC$$
(because when $d=0$, $E \equiv G \equiv A \Rightarrow \angle BEC = \angle BGC$)
Notice that when $d=0$ then $CA = CD = CE = b$; $BD = BE = BA = c$. So we can guess the general formula for a quadrilateral will be one of these two formulas:
$$ a^{2} + Kd^{2} = b^{2} + c^{2} - 2 \cdot BE \cdot CE \cdot \cos \angle BEC \text{ (1)}$$ $$ a^{2} + Kd^{2} = b^{2} + c^{2} - 2 \cdot BD \cdot CA \cdot \cos \angle BGC \text{ (2)}$$
(where $K$ is a constant)
The reason we add $Kd^{2}$ is to make the formula homogeneous (since the Law of Cosines is also homogeneous), and when $d=0$, the $Kd^{2}$ term is gone. Moreover, from our intuition, if the formula contains $\angle BEC$, then two sides, which multiply to its cosines, have to be $BE$ and $CE$. Otherwise, those two sides will be $BD$ and $CA$ multiplied by $\cos \angle BGC$
To see which one is possibly correct, we can try to apply the formula to a special quadrilateral: square. In a square, $a=b=c=d$, "$BE = CE = \infty$", "$\angle BEC = \infty$", $\angle BGC = 90^{\circ}$. Apply $(1)$ and $(2)$:
$$(1): a^{2} + Ka^{2} = a^{2} + a^{2} - \infty$$ $$(2): a^{2} + Ka^{2} = a^{2} + a^{2}$$
$(1)$ is definitely wrong. The formula $(2)$ can be true if $K=1$, so let re-written it:
$$a^{2} + d^{2} = b^{2} + c^{2} - 2 \cdot BD \cdot CA \cdot \cos \angle BGC$$
To be sure that this formula is correct, let's apply this in another quadrilateral. This time is a rectangle, where $\angle BGC = 60^{\circ}$. We have $a=d, b=c=a\sqrt{3}$, $BD = AC = 2a$. Apply the formula that we've just found, we get:
$$a^{2} + a^{2} = 3a^{2} + 3a^{2} - 2 \cdot 4a^{2} \cdot \frac{1}{2}$$
And this is true. You can verify it with some other quadrilaterals, and it'll also true. So, our new extended "Law of Cosines" is:
$$a^{2} + d^{2} = b^{2} + c^{2} - 2 \cdot BD \cdot CA \cdot \cos \angle BGC$$
So that seems fine. But
Is there a proof of the formula above?
Now, my main question (and my main focus) is:
Can we extend the formula (find a general formula) for polygons with n sides?
This question is what I'm looking for (This isn't a homework question). I'm really curious about this. If you have an answer (or just an idea) to approach, please provide it.
Thank you a lot and have a nice day :D
Let us consider convex $n$-gon $A_1A_2\cdots A_n$ where $\overline{A_jA_{j+1}}=a_j$ with $\angle{A_jA_{j+1}A_{j+2}}=\theta_j$.
Now, let us put our $n$-gon on the $xy$ plane in the following way :
$A_1$ is at the origin
The side $A_1A_2$ is on the $x$-axis
The $x$-coordinate of $A_2$ is positive
The $y$-coordinate of $A_3$ is positive.
Here, if we consider the projection of each side on the $x$-axis, then we get $$a_1+a_2\cos(\pi-\theta_1)+a_3\cos(2\pi-(\theta_1+\theta_2))+\cdots +a_n\cos((n-1)\pi-(\theta_1+\theta_2+\cdots +\theta_{n-1}))=0$$ which can be written as $$a_1=\sum_{k=1}^{n-1}(-1)^{k+1}a_{k+1}\cos\bigg(\sum_{j=1}^{k}\theta_j\bigg)\tag1$$
Similarly, if we consider the projection of each side on the $y$-axis, then we get $$a_2\sin(\pi-\theta_1)+a_3\sin(2\pi-(\theta_1+\theta_2))+\cdots +a_n\sin((n-1)\pi-(\theta_1+\theta_2+\cdots +\theta_{n-1}))=0$$ which can be written as $$0=\sum_{k=1}^{n-1}(-1)^{k+1}a_{k+1}\sin\bigg(\sum_{j=1}^{k}\theta_j\bigg)\tag2$$
From $(1)(2)$, we obtain $$a_1^2+0^2=\bigg(\sum_{k=1}^{n-1}(-1)^{k+1}a_{k+1}\cos\bigg(\sum_{j=1}^{k}\theta_j\bigg)\bigg)^2+\bigg(\sum_{k=1}^{n-1}(-1)^{k+1}a_{k+1}\sin\bigg(\sum_{j=1}^{k}\theta_j\bigg)\bigg)^2$$ which can be written as $$a_1^2=\sum_{k=1}^{n-1}a_{k+1}^2+\sum_{1\le p\lt q\le n-1}\bigg(2(-1)^{p+1}a_{p+1}\cos\bigg(\sum_{j=1}^{p}\theta_j\bigg)\times (-1)^{q+1}a_{q+1}\cos\bigg(\sum_{j=1}^{q}\theta_j\bigg)+2(-1)^{p+1}a_{p+1}\sin\bigg(\sum_{j=1}^{p}\theta_j\bigg)\times (-1)^{q+1}a_{q+1}\sin\bigg(\sum_{j=1}^{q}\theta_j\bigg)\bigg)$$ i.e. $$a_1^2=\sum_{k=1}^{n-1}a_{k+1}^2+\sum_{1\le p\lt q\le n-1}2(-1)^{p+q}a_{p+1}a_{q+1}\bigg(\cos\bigg(\sum_{j=1}^{p}\theta_j\bigg)\cos\bigg(\sum_{j=1}^{q}\theta_j\bigg)+\sin\bigg(\sum_{j=1}^{p}\theta_j\bigg)\sin\bigg(\sum_{j=1}^{q}\theta_j\bigg)\bigg)$$ i.e. $$a_1^2=\sum_{k=1}^{n-1}a_{k+1}^2+\sum_{1\le p\lt q\le n-1}2(-1)^{p+q}a_{p+1}a_{q+1}\cos\bigg(\sum_{j=1}^{q}\theta_j-\sum_{j=1}^{p}\theta_j\bigg)$$ Therefore, we get $$\color{red}{a_1^2=\sum_{k=1}^{n-1}a_{k+1}^2+\sum_{1\le p\lt q\le n-1}2(-1)^{p+q}a_{p+1}a_{q+1}\cos\bigg(\sum_{j=p+1}^{q}\theta_j\bigg)}$$
For example, for pentagon $A_1A_2A_3A_4A_5\ (n=5)$, we get
$$\color{red}{a_1^2=a_2^2+a_3^2+a_4^2+a_5^2-2a_{2}a_{3}\cos(\theta_2)+2a_{2}a_{4}\cos(\theta_2+\theta_3)-2a_{2}a_{5}\cos(\theta_2+\theta_3+\theta_4)-2a_{3}a_{4}\cos(\theta_3)+2a_{3}a_{5}\cos(\theta_3+\theta_4)-2a_{4}a_{5}\cos(\theta_4)}$$
Added : One can get several formulas.
For quadrilateral $A_1A_2A_3A_4\ (n=4)$ :
If we change $(1)(2)$ to $$(1)\implies a_4\cos(\theta_4)=a_1-a_2\cos(\theta_1)+a_3\cos(\theta_1+\theta_2)$$$$(2)\implies a_4\sin(\theta_4)=a_2\sin(\theta_1)-a_3\sin(\theta_1+\theta_2)$$squaring and adding give $$a_4^2=a_1^2+a_2^2+a_3^2-2a_1a_2\cos(\theta_1)-2a_2a_3\cos(\theta_2)+2a_1a_3\cos(\theta_1+\theta_2)$$
If we change $(1)(2)$ to $$(1)\implies a_1+a_3\cos(\theta_1+\theta_2)=a_2\cos(\theta_1)+a_4\cos(\theta_4)$$$$(2)\implies a_3\sin(\theta_1+\theta_2)=a_2\sin(\theta_1)-a_4\sin(\theta_4)$$squaring and adding give $$a_1^2+a_3^2+2a_1a_3\cos(\theta_1+\theta_2)=a_2^2+a_4^2+2a_2a_4\cos(\theta_1+\theta_4)$$
If we change $(1)(2)$ to $$(1)\implies a_3\cos(\theta_1+\theta_2)-a_2\cos(\theta_1)=a_4\cos(\theta_4)-a_1$$$$(2)\implies a_3\sin(\theta_1+\theta_2)-a_2\sin(\theta_1)=-a_4\sin(\theta_4)$$squaring and adding give $$a_2^2+a_3^2-2a_2a_3\cos(\theta_2)=a_1^2+a_4^2-2a_1a_4\cos(\theta_4)$$
For pentagon $A_1A_2A_3A_4A_5\ (n=5)$ :