| Author |
Comment/Response |
Forum Moderator
email me
 |
10/01/02 10:01am
Solve is evaluated before Thread in your example.
Your list is treated as a system and the system
likely has no solution, hence the empty set.
In[36]:= f1 = 3x+2y-z == 4
In[37]:= f2 = x + 2*y - z == 4
In[38]:= f3 = 3*x + y - z == 4
In[39]:= Thread[Solve[{f1,f2,f3},z]]
Out[39]= {}
Here are some ways to apply Solve to a list of
equations.
Here is a list:
In[50]:= eqns={f1,f2,f3}
Out[50]=
{3 x + 2 y - z == 4, x + 2 y - z == 4, 3 x + y - z == 4}
You can use Table:
In[51]:= Table[Solve[eqns[[i]],z],{i, 1, Length[eqns]}]
Out[51]= {{{z -> -4 + 3 x + 2 y}}, {{z -> -4 + x + 2 y}}, {{z -> -4 + 3 x + y}}}
You could define a new function that uses Solve:
In[52]:= solveList[funcs_]:= Solve[funcs,z]
and then Map that function onto the list:
In[53]:= Map[solveList,eqns]
Out[53]= {{{z -> -4 + 3 x + 2 y}}, {{z -> -4 + x + 2 y}}, {{z -> -4 + 3 x + y}}}
You can also use a "pure function" in Map to
skip the function definition step.
In[54]:= Map[Solve[#,z]&, eqns]
Out[54]= {{{z -> -4 + 3 x + 2 y}}, {{z -> -4 + x + 2 y}}, {{z -> -4 + 3 x + y}}}
URL: , |
|