# How to manipulate a system of equations

I have the following Manipulate[] working just fine.

Manipulate[
permut = Permutations[{eq1, eq2, eq3, eq4, eq5}, {3}];
eq1 = x^a - 4 y - z^b == 1;
eq2 = Sqrt[x] + y + 3 z == 4;
eq3 = x - y^2 + Sqrt[z] == 2;
eq4 = x^a - 4 y^a - z^c == 6;
eq5 = x^b + 6 y - z^c == 8;
NSolve[permut[[eqSet]], {x, y, z}, Reals],
{a, -2, 2, 1},
{b, -2, 2, 1},
{c, -1, 1, 0.5},
{eqSet, 1, Length[permut], 1}
]


I want to solve a system of 3 equations with varying parameters. With Permutations[] I like to run a different set of 3 equations for each element of index "eqSet". I can do that for each element of Permutations[], no problem. My problem here is that I cannot see the group of 3 equations solved. eqSet is an index to pick a set of 3 equations from permutations but I cannot know which set of equations have been solved.

[1] Can I get the names (such as eq1, e2, etc) of the actual set of equations being solved, for example, "eq2, eq5, eq4}"?

[2] Suppose that I solved the set of equations: "{eq2, eq5, eq4}", but now I like to replace "eq2" with equation "eq1" in this set without changing counter value "eqSet". How can I do this?

Thanks.

• If I replace NSolve[permut[[eqSet]],{x,y,z},Reals] with names=Permutations[{"eq1","eq2","eq3","eq4","eq5"},{3}]; {names[[eqSet]],NSolve[permut[[eqSet]],{x,y,z},Reals]} then it displays the names of the three equations along with the solution.
– Bill
Jul 19, 2020 at 19:05
• @Bill: Yes, it works in the way I expected. Thanks a lot. Jul 19, 2020 at 20:09

You can use a RadioButtonBar to pick the 10 combinations of equations. Use Subsets[equations, {3}] instead of Permutations because this avoids all the choices where you have a repeated equation.

It's a bit clunky and I didn't know how to represent this very well with the UI elements, but I've also added a CheckboxBar so you can select the equations from the first set to replace with equations in the second set.

mysolve[a1_, b1_, c1_, d1_, eqs_] := {x, y, z} /.
Quiet[NSolve[eqs /. {a -> a1, b -> b1, c -> c1, d -> d1}, {x, y, z},
Reals]]
permut = Subsets[Range[5], {3}];
equations1 = {x^a - 4 y - z^b == 1, Sqrt[x] + y + 3 z == 4,
x - y^2 + Sqrt[z] == 2, x^a - 4 y^a - z^c == 6,
x^b + 6 y - z^c == 8};
equations2 = {x^d + Sqrt[6 y] - Sqrt[z^c] == 10, x^b + z^d == 14,
x^c + 6 y == 12, x^a + y^d - z^c == 7,
x^c + 6 Sqrt[y] - Log[z^d] == 9};
pchoice = First@permut;
permut], "Choose equations.", Left]
replacementchoices =
DeleteCases[
Flatten[Outer[Rule, Range[Length[equations1]],
Range[Length[equations2]]]], x_ -> x_];
Labeled[CheckboxBar[Dynamic[replchoice],
ToString /@ replacementchoices], "Choose replacements.", Left]
Manipulate[
results1 = mysolve[a, b, c, d, equations1[[pchoice]]];
results2 = If[ListQ[replchoice] && Length[replchoice] > 0,
newequations = ReplacePart[equations1[[pchoice]],
With[{choices = ToExpression[replchoice]},