The number of monochromatic triangles It is well known that the minimum number of monochromatic triangles in a red/blue coloring of the edges of the complete graph $K_n$ is given by Goodman's formula
$$M(n)=\binom n3-\left\lfloor\frac n2\left\lfloor\left(\frac{n-1}2\right)^2\right\rfloor\right\rfloor;$$
see OEIS sequence A014557 or the original paper by A. W. Goodman, On sets of acquaintances and strangers at any party, Amer. Math. Monthly 66 (1959), 778–783, or my answer to this math.stackexchange question.

Is there any literature on the more general question, what is the minimum number of monochromatic triangles in a red/blue coloring of the edges of the complete graph $K_n$ with a prescribed number of edges of each color?

...

Is there any literature on the related question, given natural numbers $n$ and $k$, what is the minimum value of the quantity $m+kb$ over all red/blue colorings of the edges of the complete graph $K_n$, where $m$ is the number of monochromatic triangles (of either color) and $b$ is the number of blue edges?

 A: Suppose that the red degree of each vertex is denoted by $r_x$, and the total number of red edges is $R=\frac{1}{2}\sum_x r_x$. Then the number of monochromatic triangles is exactly
$$ \binom{n}{3}-(n-1)R+\frac{1}{2}\sum_xr_x^2.$$
The minimum value can be derived from this, but the answer will be a little messy according as $2R$ is divisible by $n$ or not. If $2R$ is divisible by $n$, the minimum this can be is when all the $r_x$ are equal (so $=2R/n$), and so for example in this case the minimum number of monochromatic triangles is
$$ \binom{n}{3}-(n-1)R+\frac{2R^2}{n}.$$
(Note this is indeed attainable by taking red edges to be a regular graph. Also this is always a lower bound for the number of monochromatic triangles by Cauchy-Schwarz, but will not be achievable if $R$ is not divisible by $n$.)
The first formula is just a rearrangement of Goodman's more general formula, which says that for all coloured $K_n$ the number of monochromatic triangles is equal to
$$ \frac{1}{2}\left(\sum_x \binom{r_x}{2}+\sum_x\binom{n-1-r_x}{2}-\binom{n}{3}\right).$$
(The proof of which is just to note that if we count all monochromatic pairs of edges from each vertex then each monochromatic triangle is counted 3 times and non-monochromatic triangles are counted once.)
