$2−2x$ for $x∈(0,1)$ and $0$ otherwise.
i started by calculating expectation $E(x)$ so integrated $(2−2x)x$ from $0$ to $1$ and it was $E(x)=1/3$
now to find variance(x) it is $var(x)= E(x-E(x))^2$ and i am getting it zero which is wrong
$2−2x$ for $x∈(0,1)$ and $0$ otherwise.
i started by calculating expectation $E(x)$ so integrated $(2−2x)x$ from $0$ to $1$ and it was $E(x)=1/3$
now to find variance(x) it is $var(x)= E(x-E(x))^2$ and i am getting it zero which is wrong
On
$$Var(X)=E[X^2]-E[X]^2=2\int_0^1(x^2-x^3)dx-\frac19=2\left(\frac{x^3}{3}-\frac{x^4}{4}\right)_0^1-\frac19=$$$$=2\left(\frac13-\frac14\right)-\frac19=\frac16-\frac19=\frac{1}{18} $$
Using your method
$$Var(X)=E[(X-E[x])^2)=\int_0^1(x-1/3)^2(2-2x)dx=$$ $$=\frac19\int_0^1\left(-18 x^3+{30 x^2}-{14 x}+{2}\right)dx=\frac19 \left(-\frac{9x^4}{2}+10x^3-7x^2+2x\right)_0^1=\frac19(-9/2+10-7+2)=\frac{1}{18}$$
You have to calculate the second moment $\mathbb{E}[X^2]$ then easy find
$$\mathbb{V}[X]=\mathbb{E}[X^2]-\mathbb{E}^2[X]$$
$$\mathbb{E}[X^2]=\int_0^1 x^2 f(x) dx=\dots=\frac{1}{6}$$
thus
$$\mathbb{V}[X]=\frac{1}{6}-\frac{1}{9}=\frac{1}{18}$$