My goal is to add three equations: a==b, c==d, e==f. I could used MapThread and Replace as shown below, but is there a simpler method?
eqs={a==b, c==d, e==f};
MapThread[Plus,eqs/.Equal->List]/.List->Equal (* a+c+e==b+d+f *)
eqs = {a == b, c == d, e == f};
<< EqualThread.m
Total[eqs]
(*a+c+e==b+d+f*)
EqualThread is found at https://library.wolfram.com/infocenter/ID/4491/, and it has worked for every version of Mathematica since the 90's. If you put it in your init.m file, adding, subtracting, multiplying and dividing equations becomes effortless.
It also works for functions, such as
Log[eqs[[1]]]
(*Log[a] == Log[b]*)
Option 1
eqs = {a == b, c == d, e == f};
Equal @@ Total[List @@@ eqs]
Option 2
Equal @@ Last@Accumulate[List @@@ eqs]
Option 3
Thread[Total[eqs],Equal]
Unfortunately, AddSides works on only pair of equations and not set of equations. Hence this works
AddSides[a == b, c == d]
But not
AddSides[a == b, c == d, e == f]
But you can do
option 4
Last@FoldList[AddSides,eqs]
Fold[AddSides, eqs] suffices.
$\endgroup$
Fold but for some reason, I forgot. Good it works.
$\endgroup$
Try this:
eqs = {a == b, c == d, e == f};
Equal @@ Plus @@@ Transpose[List @@@ eqs]
(* a + c + e == b + d + f *)
Have fun!
eqs = {a == b, c == d, e == f};
Total[eqs[[All, 1]]] == Total[eqs[[All, 2]]]
(* a + c + e == b + d + f *)
```
ApplySides[Total, #[[All, 1]] == #[[All, 2]]] &[eqs]?
$\endgroup$