I'm trying to solve for $p3$ in 3p3-5 = p1 + p2
at positions where p1*p2 == 0
:
deltap = 10^(-2)
tabletry = Table[p1*p2, {p1, 0, 2}, {p2, 0, 2}] // MatrixForm
tabletest = Table[{If[p1*p2 == 0, True, False ]}, {p1, 0, 2}, {p2, 0, 2}] // MatrixForm
$$\left( \begin{array}{ccc} 0 & 0 & 0 \\ 0 & 1 & 2 \\ 0 & 2 & 4 \\ \end{array} \right)$$
$$\left( \begin{array}{ccc} {(True)}\ & (True) & (True) \\ \ (True) & (False) & (False) \\ \ (True) & (False) & (False) \\ \end{array} \right) $$
(Array[# #2 /. {(0) -> Style[Solve[3 p3 - 5 == # + #2, p3][[1, 1, -1]], Red], _ :>
0} &, {3, 3}, 0]) // MatrixForm
EDIT
Now I'm trying to up the level of code, trying to evaluate the difference in p3
following at true
entries. Full code:
deltap = 10^-2;
tabletry = (Table[p1*p2, {p1, 0, 2}, {p2, 0, 2}] ) // MatrixForm
tst = ( Map[{# == 0 } &, tabletry, {-1}] ) // MatrixForm
eqn1 = 1/p3 - 5p3 = p1 + p2
eqn2 = 1/p3 - 5p3 + deltap = p1 + p2
diff = p3 /. FindRoot[eqn2, {p3,1}] - p3 /. FindRoot[eqn1,{p3,1}]
(Array[# #2 /. {(0) -> Style[Evaluate[diff[#, #2]][[1, 1, -1]], Red], _ :>
0} &, {3, 3}, 0]) // MatrixForm
Solve[p3 == p1 + p2 && And @@ ((# == 0 || # == 1 || # == 2) & /@ {p1, p2}) && p1*p2 == 0, {p1, p2, p3}]
$\endgroup$