What is the proof for variance of triangular distribution? In Wikipedia, the formula for the variance of the triangular distribution is given here. However, I don't know how to find it. I have tried a brute force method but the formula is quite complicated (polynomial of degree 5 in a, b, c) and I can't simplify it (I tried manually and with Xcas).
The following part is edited thanks to @Imaosome remark:
I came to this question with the following problem:
Say $X$ and $Y$ are independent random variables with uniform distribution between $0$ and $1$.
I want to study $Z = X-Y$. With convolution, I find that the distribution is triangular, centered in $0$ with extremities $-1$ and $1$ (the proof is also available in this pdf here). With Wikipedia notations, it gives $a=-1, b=1, c=0$. And in this case, we sum $2$ independent variables therefore the variance shoud be
$Var(X)+Var(-Y) = Var(X)+Var(Y)=2 Var(X)$. The variance of $X$ is $1/12$ (see for instance formula here). Therefore the variance of $Z$ is $Var(Z) = 2 * 1/12 = 1/6$.
If I come back to Wikipedia formula, I find:
$$
\frac{a^2+b^2+c^2-ab-ac-bc}{18}=\frac{1+1+0+1-0-0}{18}=1/6.
$$
This shows, at least in that particular case that the formula is correct. But I would like to try and prove Wikipedia result. Once again, I know that it should be possible to prove it by integration but I did not succeed and I hope somebody has a simple way to get this formula.
Here are the details. By definition, we want to compute:
\begin{align*}
\sigma^2 &= \int_a^c \frac{2(x-a)}{(b-a)(c-a)} \left( x - \frac{a+b+c}{3} \right)^2 dx + \int_c^b \frac{2(b-x)}{(b-a)(b-c)} \left( x - \frac{a+b+c}{3} \right)^2 dx \\
&= \frac{2}{(b-a)(c-a)} \left[ \frac{1}{3} (x-a) \left( x - \frac{a+b+c}{3} \right)^3 - \frac{1}{12} \left( x - \frac{a+b+c}{3} \right)^4 \right]_a^c \\
& ~~~~~~ \frac{2}{(b-a)(b-c)} \left[ \frac{1}{3} (b-x) \left( x - \frac{a+b+c}{3} \right)^3 - \frac{1}{12} \left( x - \frac{a+b+c}{3} \right)^4 \right]_c^b
\end{align*}
From there, one can see that terms in $\left( x - \frac{a+b+c}{3}\right)$ cancel out leaving us with:
\begin{align*}
\sigma^2 &= \frac{2}{12(b-a)(c-a)} \left( - \left( \frac{2c-a-b}{3} \right)^4 + \left( \frac{2a-b-c}{3} \right)^4 \right) \\
& ~~~~~~ \frac{2}{12(b-a)(b-c)} \left( - \left( \frac{2b-a-c}{3} \right)^4 + \left( \frac{2c-a-b}{3} \right)^4 \right) \\
&= \frac{((c-a)-(b-c))^5 +(b-c)((b-a)+(c-a))^4 - (c-a)((b-a)+(b-c))^4}{ 2 \times 3^5 (b-a)(b-c)(c-a) }
\end{align*}
And from this point, I am stuck. After all, maybe the last line is not helping much. I don't know.
 A: It's a little easier to use the identity $\ \sigma^2=\mathbb{E}\big(Z^2\big)-\mathbb{E}(Z\,)^2\ $:
\begin{align}
\mathbb{E}\big(Z^2\big)&=\frac{2}{(b-a)(c-a)}\int_a^cx^2(x-a)\,dx\\
&\hspace{2em}+\frac{2}{(b-a)(b-c)}\int_c^bx^2(b-x)\,dx\\
&=\Bigg(\frac{2}{(b-a)(c-a)}\Bigg)\Bigg(\frac{c^4-a^4}{4}-\frac{a\big(c^3-a^3\big)}{3}\Bigg)\\
&\hspace{2em}+\Bigg(\frac{2}{(b-a)(b-c)}\Bigg)\Bigg(\frac{b\big(b^3-c^3\big)}{3}-\frac{b^4-c^4}{4}\Bigg)\\
&=\Bigg(\frac{1}{(b-a)(c-a)}\Bigg)\Bigg(\frac{3\big(c^4-ac^3\big)+a^4-ac^3}{6}\Bigg)\\
&\hspace{2em}+\Bigg(\frac{1}{(b-a)(b-c)}\Bigg)\Bigg(\frac{3\big(c^4-bc^3\big)+b^4-bc^3}{6}\Bigg)\\
&=\Bigg(\frac{1}{(b-a)(c-a)}\Bigg)\Bigg(\frac{3c^3(c-a)+a(a-c)\big(a^2
+ac+c ^2\big)}{6}\Bigg)\\
&\hspace{2em}+\Bigg(\frac{1}{(b-a)(b-c)}\Bigg)\Bigg(\frac{3c^3(c-b)+b(b-c)\big(b^2+bc+c^2\big)}{6}\Bigg)\\
&=\frac{3c^3-a^3-a^2c-ac^2}{6(b-a)}+\frac{b^3+b^2c+bc^2-3c^3}{6(b-a)}\\
&=\frac{a^2+b^2+c^2+ab+ac+bc}{6}\\
\mathbb{E}(Z\,)^2&=\Big(\frac{a+b+c}{3}\Big)^2\\
&=\frac{a^2+b^2+c^2+2ab+2ac+2bc}{9}\\
\sigma^2&=\mathbb{E}\big(Z^2\big)-\mathbb{E}(Z\,)^2\\
&=\frac{a^2+b^2+c^2-ab-ac-bc}{18}
\end{align}
A: The computation is best performed on the location-transformed variable such that the mode is at $0$.  In particular, suppose $$X \sim \operatorname{Triangular}(a,b,c), \\ f_X(x) = \begin{cases} 0, & x < a \\ \frac{2(x-a)}{(b-a)(c-a)}, & a \le x \le c \\ \frac{2(b-x)}{(b-a)(b-c)}, & c < x \le b, \\ 0, & x > b. \end{cases}$$  Then consider $$Y = X - c$$ which then has density
$$f_Y(y) = \begin{cases}
0, & y < a - c \\
\frac{2(y-(a-c))}{(b-a)(c-a)}, & a-c \le y \le 0 \\
\frac{2((b-c)-y)}{(b-a)(b-c)}, & 0 < y \le b-c \\
0, & x > b-c.
\end{cases}$$
All we did was shift the density, which lets us now use the auxiliary parameters $\alpha = a-c$, $\beta = b-c$, to write
$$f_Y(y) = \begin{cases}
0, & y < \alpha \\
\frac{2(y-\alpha)}{(\beta - \alpha)(-\alpha)}, & \alpha \le y \le 0 \\
\frac{2(\beta-y)}{(\beta - \alpha)\beta}, & 0 < y \le \beta \\
0, & y > \beta.
\end{cases}$$
Now the variance calculation performed on $Y$ proceeds as follows:
$$\begin{align}
\operatorname{E}[Y^k] &= \int_{y=\alpha}^0 y^k \frac{2(y-\alpha)}{(\beta-\alpha)(-\alpha)} \, dy + \int_{y=0}^\beta y^k \frac{2(\beta-y)}{(\beta-\alpha)\beta} \, dy \\
&= \frac{2}{(\beta - \alpha)(-\alpha)} \left[\frac{y^{k+2}}{k+2} - \alpha \frac{y^{k+1}}{k+1}\right]_{y=\alpha}^0 + \frac{2}{(\beta - \alpha)\beta} \left[\beta\frac{y^{k+1}}{k+1} - \frac{y^{k+2}}{k+2} \right]_{y=0}^\beta \\
&= \frac{2}{(\beta-\alpha)} (\beta^{k+1} - \alpha^{k+1}) \left(\frac{1}{k+1} - \frac{1}{k+2} \right) \\
&= \frac{2(\beta^{k+1} - \alpha^{k+1})}{(k+1)(k+2)(\beta-\alpha)}.
\end{align}$$
For $k \in \{1, 2\}$ we easily get
$$\operatorname{E}[Y] = \frac{\alpha + \beta}{3} \\
\operatorname{E}[Y^2] = \frac{\alpha^2 + \alpha\beta + \beta^2}{6}.$$
Consequently, $$\operatorname{Var}[X] = \operatorname{Var}[Y] = \frac{\alpha^2 - \alpha \beta + \beta^2}{18} = \frac{a^2 + b^2 + c^2 - (ab + bc + ca)}{18}.$$
Note that we have used the fact that a location transformation of a random variable does not change its variance.  This calculation minimizes the number of integrations we need to perform and reduces the number of parameters we need to account for.  We also get the additional result for the $k^{\rm th}$ raw moment of $Y$, which has a particularly convenient form.
Also note that we could have written the density of the transformed variable $Y$ simply by choosing $c = 0$, $a = \alpha$, $b = \beta$ from the density of $X$; however, I wanted to emphasize how the density of $Y$ is obtained by shifting $X$ by $c$.
