9
$\begingroup$

If we have two equations E1 and E2, and instead of using Solve to solve it, we simply need to manually add them up which would allow some simplification that could lead to better visibility of its structure, I found that

E1 + E2

would always fail. Instead, I need to extract left and right sides of an equation explicity using

E1[[1]] + E2[[1]] == E1[[2]] + E2[[2]]

enter image description here

Is there any built-in function to do this?

$\endgroup$
3
  • 1
    $\begingroup$ Hey Jim, in general we don't put names under posts on this site, because we have the box on the left with your user information. Why don't you change your user name to something better than user2452474 to make you more recognizable? Go to your user profile and click on edit. $\endgroup$
    – halirutan
    Commented Jun 11, 2013 at 0:25
  • 2
    $\begingroup$ Another thing, when you write a question and post code, please review the most common pitfalls in Mathematica. Specifically, don't use capitalized variable names. When you include code, please use code blocks so that everyone can copy and paste your example. $\endgroup$
    – halirutan
    Commented Jun 11, 2013 at 0:30
  • $\begingroup$ @halirutan Just learned how to paste code. Thanks! $\endgroup$
    – JimmyLin
    Commented Jun 11, 2013 at 18:11

2 Answers 2

16
$\begingroup$

What you need is Thread, to thread the plus operator over the equations:

e1 = 3 a == b;
e2 = 6 c == d;
Thread[e1 + e2, Equal]
(* 3 a + 6 c == b + d *)
$\endgroup$
1
  • $\begingroup$ I tested and it worked. Thanks. $\endgroup$
    – JimmyLin
    Commented Jun 11, 2013 at 19:46
1
$\begingroup$

Also

Inner[Plus, e1, e2, Equal]

3 a + 6 c == b + d

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.