# How to generate a list (or even a sequence or a string) containing {x[1]==0&&x[2]==0&&…&&x[10]==0?

I need to solve a bunch of systems of n equations in n unknowns where n varies. I can do them, one by one, but I wish to automate the process.

The first equation equals 1 and the rest all equal zero. I currently type in each set of equations manually as follows. I have the n unknowns in a list: list1 = {r,s,...,t}. I have the expressions for the LHS in a 2nd list: list2 = {expr1, ..., exprn}. I write

sol = Solve[list2[[1]]==1 && list2[[2]]==0 ... && list2[[n]]==0, list1]


I would like to just type Solve[expr, list] where expr is something like

list2[[1]]==1 && list2[[2]]==0 ... && list2[[n]]==0.


I experimented with Table, RowBox, BoxData, and even CellPrint but I don't know enough to write an expression involving && and == that will work inside the Solve function.

• maybe Solve[Thread[list2==Prepend[ConstantArray[0,Length[list2]-1],1]], list1]? – kglr Sep 29 '19 at 3:41
• Solve[First@list2 == 1 && And @@ Thread[Rest@list2 == 0], list1] – Bob Hanlon Sep 29 '19 at 5:50
• Both of these work perfectly. Thank you kglr and Bob Hanion. – matrixbud Sep 29 '19 at 11:53

## 1 Answer

You can try

Solve[Thread[list2 == Prepend[ConstantArray[0, Length[list2] - 1], 1]], list1]