Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1998
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1998

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Adding equations

  • To: mathgroup at smc.vnet.net
  • Subject: [mg14392] Re: [mg14342] Adding equations
  • From: Daniel Lichtblau <danl>
  • Date: Sun, 18 Oct 1998 15:09:58 -0400
  • References: <199810150428.AAA18222@smc.vnet.net.>
  • Sender: owner-wri-mathgroup at wolfram.com

Lawrence Walker wrote:
> 
> Group:
> 
> I've been trying to add two equations as follows:
> 
> In[4]:=
>     a==b;
> In[5]:=
>     c==d;
> In[6]:=
>     %4+%5
> Out[6]=
>     (a==b)+(c==d)
> 
> The result I was looking for is (a+c)==(b+d). The following works but it
> seems clumsy. In[7]:=
>     %4[[1]]+%5[[1]]==%4[[2]]+%5[[2]] Out[7]=
>     a+c==b+d
> Is there a way to elegantly add (sub, mult, div) two equations?  Also is
> there an elegant way to add (sub, mult, div) an expression to both
> sides of an equation?
> 
> Lawrence Walker


You might use Thread:

In[29]:= Thread[Plus[a==b,c==d], Equal] Out[29]= a + c == b + d

Another common approach is to use the automatic threading capability of
e.g. Plus over the head List. To do so you may change Equal to List,
operate, then change back.

In[30]:= ((a==b) + (c==d) /. Equal->List) /. List->Equal Out[30]= a + c
== b + d


Daniel Lichtblau
Wolfram Research


  • Prev by Date: Re: loading packages-followup
  • Next by Date: Re: Adding equations
  • Previous by thread: Adding equations
  • Next by thread: Re: Adding equations