Solving the following equations
eq =
{
0 == e["P", {m["f6p", "c"], m["atp", "c"]}, {}, {}]*
k["1", False] - e["P", {m["f6p", "c"]}, {}, {}]*m["atp", "c"]*
k["1", True] -
e["P", {m["f6p", "c"]}, {}, {}]*k["2", False] +
e["P", {}, {}, {}]*m["f6p", "c"]*k["2", True],
0 == -(e["P", {m["fdp", "c"]}, {}, {}]*m["adp", "c"]*
k["3", False]) +
e["P", {m["fdp", "c"], m["adp", "c"]}, {}, {}]*
k["3", True] +
e["P", {}, {}, {}]*m["fdp", "c"]*k["4", False] -
e["P", {m["fdp", "c"]}, {}, {}]*k["4", True],
0 == -(e["P", {m["f6p", "c"], m["atp", "c"]}, {}, {}]*
k["1", False]) + e["P", {m["f6p", "c"]}, {}, {}]*m["atp", "c"]*
k["1", True] +
e["P", {m["fdp", "c"], m["adp", "c"]}, {}, {}]*k["5", False] -
e["P", {m["f6p", "c"], m["atp", "c"]}, {}, {}]*k["5", True],
0 == e["P", {m["fdp", "c"]}, {}, {}]*m["adp", "c"]*
k["3", False] - e["P", {m["fdp", "c"], m["adp", "c"]}, {}, {}]*
k["3", True] -
e["P", {m["fdp", "c"], m["adp", "c"]}, {}, {}]*k["5", False] +
e["P", {m["f6p", "c"], m["atp", "c"]}, {}, {}]*k["5", True],
0 == eTotal - e["P", {}, {}, {}] -
e["P", {m["f6p", "c"]}, {}, {}] -
e["P", {m["fdp", "c"]}, {}, {}] -
e["P", {m["f6p", "c"], m["atp", "c"]}, {}, {}] -
e["P", {m["fdp", "c"], m["adp", "c"]}, {}, {}]
};
for
vars=
{
e["P",{},{},{}],
e["P",{m["f6p","c"]},{},{}],
e["P",{m["fdp","c"]},{},{}],
e["P",{m["f6p","c"], m["atp","c"]},{},{}],
e["P",{m["fdp","c"], m["adp","c"]},{},{}]
};
using Solve, yields two different results (depending on the approach chosen):
(1) Solving 'as is':
sol = Solve[eq, vars][[1]];
sol[[2]] /. {catch_e :> catch, m["adp", "c"] -> 0}
returns
e["P", {m["f6p", "c"]}, {}, {}] -> 0
which is simply wrong. Read Prohibit replacement by ReplaceAll (/.), if you're wondering about
{catch_e :> catch, m["adp", "c"] -> 0}
(2) Anonymize, Solve, Back-translation Anonymizing the whole system (using Unique[]), solving, and back-translating
anon = # -> Unique[] & /@ Cases[eq, (_m | _e | _k), \[Infinity]];
revAnon = Reverse /@ anon;
anonEq = eq /. anon;
anonVars = vars /. anon;
sol2 = Solve[anonEq, anonVars][[1]] /. revAnon;
sol2[[2]] /. {catch_e :> catch, m["adp", "c"] -> 0}
returns something different
e[P,{m[f6p,c]},{},{}]->(eTotal (k[1,False] k[2,True] k[3,True] k[4,True] m[f6p,c]+k[1,False] k[2,True] k[4,True] k[5,False] m[f6p,c]+k[2,True] k[3,True] k[4,True] k[5,True] m[f6p,c]))/(k[1,False] k[2,False] k[3,True] k[4,True]+k[1,False] k[2,False] k[4,True] k[5,False]+k[2,False] k[3,True] k[4,True] k[5,True]+k[1,True] k[3,True] k[4,True] k[5,True] m[atp,c]+k[1,False] k[2,True] k[3,True] k[4,True] m[f6p,c]+k[1,False] k[2,True] k[4,True] k[5,False] m[f6p,c]+k[2,True] k[3,True] k[4,True] k[5,True] m[f6p,c]+k[1,True] k[2,True] k[3,True] k[4,True] m[atp,c] m[f6p,c]+k[1,True] k[2,True] k[4,True] k[5,False] m[atp,c] m[f6p,c]+k[1,True] k[2,True] k[3,True] k[5,True] m[atp,c] m[f6p,c]+k[1,True] k[2,True] k[4,True] k[5,True] m[atp,c] m[f6p,c]+k[1,False] k[2,False] k[3,True] k[4,False] m[fdp,c]+k[1,False] k[2,False] k[4,False] k[5,False] m[fdp,c]+k[2,False] k[3,True] k[4,False] k[5,True] m[fdp,c]+k[1,True] k[3,True] k[4,False] k[5,True] m[atp,c] m[fdp,c])
wich is correct.
I have no clear idea why this is happening, only speculations. Using something else than Symbols as variables must be the problem, as replacing all those complicated expressions by real Symbols makes the difference. Has anyone ever had a problem like this? Using these nested expressions (together with custom notations in the notebook interface) is my way of keeping track of variables and parameters in large problems. It would very frustrating if I had to abandon this habit.
Update: Something I should have done before posting the question (I changed the variable name that contains the solution from the anonymizing approach to sol2 in the problem description):
testRules = # -> RandomReal[] & /@
Union@Cases[{sol[[2, 2]],
sol2[[2, 2]]}, (_m | _e | _k), \[Infinity]];
(sol[[2, 2]] /. testRules) == (sol2[[2, 2]] /. testRules)
yields True
. So both solutions are actually correct, they are just differently arranged.
Following Mr.Wizard's suggestion/post (using Simplify):
sol[[2, 2]] === sol2[[2, 2]]
yields False
, while
Simplify[sol[[2, 2]]] === Simplify[sol2[[2, 2]]]
yields True.