6
$\begingroup$

I run the Eliminate command on the expression that gave me the symbolic solution like this for example:

a + b == ab - c + d

I assigned the solution to be f = a + b == ab - c + d however I want to get rid of == sign so that I can continue with calculation and f should be : f= a+b-ab+c-d

a+b-ab+c-d

I have tried Normal @ f but no change.

Thanks in advance.

$\endgroup$
5
$\begingroup$

one way might be to make a lhs() and rhs() functions.

ClearAll[a, b, c, d, x, y, lhs, rhs]    
lhs[eq_] := eq /. (x_) == (y_) -> x;
rhs[eq_] := eq /. (x_) == (y_) -> y;

Now you can write

eq = a + b == a b - c + d;
f = lhs[eq] - rhs[eq]

Mathematica graphics

This will work only for input of form x==y of course.

$\endgroup$
8
$\begingroup$

a + b == ab - c + d is stored internally as Equal[a + b, ab - c + d].

And what you want instead is Subtract[a + b, ab - c + d].

You can get there by replacing Equal with Subtract by doing this:

f = Apply[Subtract, a + b == ab - c + d]

which gives you a-ab+b+c-d, but that is the same as what you asked for, just with Mathematica sorting the variables into the order it wants.

$\endgroup$
  • 4
    $\begingroup$ Or you can do a similar thing with a replacement rule: a + b == ab - c + d /. Equal -> Subtract $\endgroup$ – bill s Jun 21 '17 at 3:12
  • 4
    $\begingroup$ @bill s I understand completely. I tend to think that novice users might come up to speed a little easier and be a little less confused if we show them Map and Apply and ReplaceAll with [ and ] neatly containing their arguments than if we just give them strings of /@ and @@ and /. and -> that they often don't even know that they can search for in the help system and have no idea what the precedence is. Once they have the functions figured out then they can go wild with abbreviations. $\endgroup$ – Bill Jun 21 '17 at 3:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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