So I need to find $E(X_2)$, when $p=1$ and $X_0 = 0$.
This is how the task sounds:
Let's say that $(X_n, n=0,1, \ldots)$ is Markovs chain where $E=\{0,1\}$ and matrix is:
$$P=\begin{bmatrix}0.5&0.5\\p&1-p\end{bmatrix}$$
I get that
$$P^2=\begin{bmatrix}0.75&0.25\\0.5&0.5\end{bmatrix}$$
Then $EX_2 = 0*P(X_2=0 | X_0=0) + 1*P(X_2=1|X_0=0)=0.25$
So answer actually is $0.25$, but could somone explain, why do I need to square my matrix and also I do not understand this part: $EX_2 = 0*P(X_2=0 | X_0=0) + 1*P(X_2=1|X_0=0)=0.25$
Why we use $X_2$ and $X_0$, if the formula is $p_{i,j} = P(X_{n+1} = j | X_n=i)$ with every $i,j=0,1,\ldots,N$
If I take $n=1$ Then shouldn't I use: $P(X_2=0 | X_1)$ or something like that?
P.S. Sorry for bad english
The series $X_n$ represents the state of the Markov process at step $n$, and each successive value is related by way of the matrix, $P$. The relationship between terms of $X_n$ is:
$$ X_{n+1} = P X_n $$
Looking at the relevant values of $n$ gives us:
$$ X_1 = PX_0 \\ X_2 = PX_1 $$
Substiting one into the other gives $X_2 = PPX_0 = P^2 X$, so the squaring is simply because, to get 2 steps forward rather than one, we have to multiply by $P$ twice, exactly like we'd have if we were multiplying by a number twice.
As for the $EX_2$ part, I'm going to take an educated case that this is supposed to be expectation value of $X_2$. Because $E=[0,1]$, the first element of $X_2$ represents the probability of an outcome of $0$ and the second represents the probability of an outcome of $1$. The expectated value of $X_2$ is the sum each of these outcomes, multiplied by the probabilities they occur. Because multiplications by $0$ and $1$ cancel in the way they do, this is equal to the second component of $X_2$.