# Setting up a system of equations for solution

There are two lists as follows:

Vars =
{{(x1)Cos[x2], Sin[x2], 0, (x3) (Sin[x2])}, {(Cos[x2]) (Sin[x4]),
(x3)Cos[x4], 1, x1}};
Const = {{1, 0, 0, 1}, {0, 1, 1, 2}};


Using Vars and Const, I want to make a system of equations like :

SysEqu =
{(x1)Cos[x2]==1, Sin[x2]==0, 0==0, (x3) (Sin[x2])==1,
(Cos[x2])(Sin[x4])==0, (x3)Cos[x4]==1, 1==1, x1==2}


Then a UI asks about the VARIABLES to be solved and finally :

sol1 = NSolve[SysEqu, VARIABLES];


I know that NSolve generally may have some problems to give exact answers for any kind of equation. Other approaches could be acceptable instead of NSolve[].

P.S.

To setup my equations, I used this code:

SetEqual = MapThread[Set, {Vars, Const}, 2];


However, some errors appear that two of them are :

Tag Times in x2 Sin[x2] is Protected.
Cannot assign to raw object 1.

• 1 isn't a variable, so naturally it cannot be assigned anything. Jul 3, 2015 at 8:19

Your problem is the Set. Set means you're assigning something to a variable (=), x2 Sin[x2] is not a variable. Try Equal[] instead, this is equivalent to ==.

Vars = {{(x1) Cos[x2], Sin[x2],
0, (x3) (Sin[x2])}, {(Cos[x2]) (Sin[x4]), (x3) Cos[x4], 1, x1}};
Const = {{1, 0, 0, 1}, {0, 1, 1, 2}};


yields the output:

{{x1 Cos[x2] == 1, Sin[x2] == 0, True,
x3 Sin[x2] == 1}, {Cos[x2] Sin[x4] == 0, x3 Cos[x4] == 1, True,
x1 == 2}}


The trues show up because you're asking 0==0 and 1==1.

• Thank you so much for helping. However, my major problem is still unsolved; a GUI that solve the sol1 . Jul 5, 2015 at 7:35
• @Shellp Your request for a UI is pretty broad. One problem is that you have six equations in four unknowns. NSolve[SysEqu] "works" as it should, but there are no solutions. Jul 5, 2015 at 14:08
• @Shellp I'm afraid that this system doesn't have solutions, you're asking: $\sin{x_{2}}==0, x_{3}\sin{x_{2}} == 1$ This means that $x_{2}=k\pi, k\in \mathbb{Z}$, and $x_{2}\ne k\pi$ at the same time. Jul 6, 2015 at 14:57