I'm having a problem with a basic probability problem. There is a stick which is 4 units in length, we break it in two pieces and the breaking point is randomly distributed. After this we form a triangle by using these two pieces as legs of the triangle. Problem is to calculate expected value of this triangles area.
Now, clearly the area is calculated like this:

And the given model answer is this:

Now my question: I would like to have an explanation, why the answer is like that and how you get that. I understand that we have to use integral because this is continuous distribution but i don't understand why is it calculated like in the model solution.
It is a right angled triangle. The legs are formed by the two pieces of the stick. The lengths are x and 4-x. The sum of the lengths of the two pieces is $x+(4-x)=4$.
The formula for the area of a right angle triangle is $A=\frac{1}{2} \cdot a \cdot b$. a and b are the legs.
The expected value of a uniformly distributed ranodm variable is $E(X)=\frac{a+b}{2}$ In this case is $a=0$ (lower bound) and $b=4$ (upper bound).
Thus $E(X)=2$ and $2E(X)=4$
And $E(X^2)=\int_0^4 x^2\cdot f(x) \ dx$
f(x) is the pdf of a uniformly distributed random variable. Hence, $f(x)=\frac{1}{b-a}=\frac{1}{4-0}=\frac{1}{4}$