I would like to replace parts of the expression, with variables p[1]
and p[2]
, that are invariant under inversion p[1] <-> p[2]
. Namely I would like to replace p[1] * p[2]
as pro
, and p[1] + p[2]
as sum
.
exp = x /. Solve[{
x == 2 p[1] p[2] + p[1] q[2] (2 + x) + q[1] (1 + y),
y == 2 p[1] p[2] + q[1] p[2] (2 + y) + q[2] (1 + x)},
{x, y}][[1]] /. q[i_] :> 1 - p[i] // Simplify
This is nearly there, but for this expression specifically. Although I think my goal is posed loosely, my question is: how would I go about this in a convenient way?
MapAt[ExpandAll
, exp, {2}] //. {p[1]^a_.*p[2]^a_. :> pro^a, b_.*p[1] + b_.*p[2] :> b*sum}
p[1]^2 p[2]
bep[1] pro
? $\endgroup$p[1]^a_.*p[2]^b_.
correctly. Can I do without priorExpandAll
selective mapping? $\endgroup$Eliminate[ {exp == 0, pro == p[1] p[2], sum == p[1] + p[2]}, {p[1], p[2]}]
$\endgroup$