But Author provided the answer to this question as follows. Would you explain that?
[math]E[X_3] = P(X_3=1) + 2P( X_3 =2) = \frac14P^3_{01} + \frac14P^3_{11} + \frac12P^3_{21} + 2 \left[ \frac14P^3_{02} + \frac14P^3_{12} +\frac12P^3_{22} \right][/math]
Now I understand, but I think it's a question that shouldn't be asked for discrete Markov Chain because it's not guaranteed you'll have a whole number as an answer, where your answer must be either 0,1, or 2.
[imath]E[X_3][/imath] is the expected state after 3 transitions.
First, define the distribution for [imath]X_3[/imath]:
[math]X_3 = \begin{cases} 0 &\text{with } \Pr(X_3=0)\\ 1 &\text{with } \Pr(X_3=1)\\ 2 &\text{with } \Pr(X_3=2)\\ \end{cases}[/math]Then [imath]E[X_3]=\cancel{0\cdot \Pr(X_3=0)}+ 1\cdot \Pr(X_3=1) + 2\cdot \Pr(X_3=2)[/imath]
Note that it's not necessary to compute [imath]\Pr(X_3 = 0)[/imath] since it's getting multiply by 0.
Now, find [imath]\Pr(X_3 =1)[/imath]. In words, the probability that after 3 transitions, we're in state 1. Moreover, we could've started in either states 0, 1, or 2. Thus:
[math]\Pr(X_3=1)= \frac{1}{4}p_{01}^{(3)} + \frac{1}{4} p_{11}^{(3)} + \frac{1}{2}p_{21}^{(3)}[/math]Similarly,
[math]\Pr(X_3=2)= \frac{1}{4}p_{02}^{(3)} + \frac{1}{4}p_{12}^{(3)} + \frac{1}{2}p_{22}^{(3)}[/math]
Note: I'm putting the superscript [imath](3)[/imath] in parenthesis to differentiate between exponents and numbers of steps. i.e. [imath]p_{01}^3 \neq p_{01}^{(3)} [/imath]
Putting all the parts together will give you the provided solution.