Re: ``flattening" systems of equations
- To: mathgroup@smc.vnet.net
- Subject: [mg10423] Re: ``flattening" systems of equations
- From: Allan Hayes <hay@haystack.demon.co.uk>
- Date: Tue, 13 Jan 1998 02:07:24 -0500
- References: <69co6a$ent@smc.vnet.net>
Selwyn Hollis wrote:
> What is the simplest way to convert a system of equations like this:
>
> {{a,b,...}=={c,d,...}, e==f}
>
> into this:
>
> {a==c, b==d,..., e==f}?
>
> (Solve[] works on systems in either form, but FindRoot[] seems to
> require the second.)
>
> --
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Dr. Selwyn Hollis
> Associate Professor of Mathematics
> Armstrong Atlantic State University
> Savannah, GA 31419 USA
> <http://www.math.armstrong.edu/faculty/hollis/>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In[1]:=
{{a,b}=={c,d}, e==f}/.(p_List==q_:> Thread[p==q])//Flatten
Out[1]=
a == c
b == d
e == f
or
In[2]:=
{{a,b}=={c,d}, e==f}/.(p:Equal[_List,_]:> Thread[p])//Flatten
Out[2]=
a == c
b == d
e == f
But, because of
In[3]:=
Equal[__List]
Out[3]=
True
In[4]:=
{{a,b}=={c,d}, e==f}/.(p:HoldPattern[Equal[__List]]:>
Thread[p])//Flatten
Out[4]=
a == c
b == d
e == f
--
Allan Hayes
Mathematica Training and Consulting
Leicester, UK
hay@haystack.demon.co.uk
http://www.haystack.demon.co.uk
voice: +44 (0)116 271 4198
fax: +44 (0)116 271 8642