# Why am I unable to solve this system of equations?

I don't know why I can't solve this system of equations in Mathematica. I just want to find $$p_{i,j}$$ terms that satisfy $$\pi_0 * P^3 = \pi_1$$, as seen here. But I'm getting an error that this isn't a quantified system...

Can someone help me figure out how to get this to run?

• With four equations you can only solve for four variables. I recommend that you use indexed variables rather than subscripts. You can format the indexed variables to display with subscripts on output. – Bob Hanlon Sep 30 at 18:46

P = Array[Subscript[p, ##] &, {4, 4}];
Subscript[π, 0] = {1, 0, 0, 0};
Subscript[π, 1] = {0, 0, 0, 1};
sols = FindInstance[Thread[Subscript[π, 0].MatrixPower[P, 3] == Subscript[π, 1]], Flatten[P], Integers, 1][[1]];
P /. sols // MatrixForm


Subscript[π, 0].MatrixPower[P, 3] - Subscript[π, 1] /. sols


{0, 0, 0, 0}

If the variable space is limited as shown by the one solution, then another possible solution may be had using the following:

ClearAll[p, P, pi0, pi1, myVars, myConstraints, allEquations, solutions]
P = Array[p, {4, 4}];
pi0 = {1, 0, 0, 0};
pi1 = {0, 0, 0, 1};
myVars = Flatten[P];
myConstraints = Flatten[{# <= 1, # >= 0} & /@ myVars];
allEquations = And @@ Flatten[{pi0.P.P.P == pi1, myConstraints}];
solutions = Solve[allEquations, myVars, Integers];


This gives 704 solutions to the equation above and I have confirmed that the one presented by Suba Thomas is one of these.