## Solving equations using algebra

1

Has anyone ever solved an equation for students using algebraic steps?

2x+3 = 5


Then you show subtracting 3 from both sides

2x+3 -3 = 5 -3


Then you simplify.

2x=2


Then you divide both sides by 2.

2x/2 = 2/2


Then you simplify.

x=1.

Just curious if anyone has ever done this.

Question was closed 2015-02-18T13:34:27.297

2

It is not difficult. You did not write though, what is your ultimate aim, since the way, how to do what you are asking for depends upon that. I take it, you need something as a demonstration for school children or students. This is the way I interpret your requirement to separate the action from simplification. Otherwise, as you know, Mma does simplification automatically, and to separate one from the other takes some special effort. Anyway, here it is:

Step zero: equation

eq = 2 x + 3 == 5;


For the further technically the trick is related to the fact that any equation has the following TreeForm:

TreeForm[eq]


The box entitled "Plus" with the tree coordinate {1} contains the left-hand side of the equation, and that entitled "5" with the coordinate {2} contains it right-hand side, the both are on the level 1. That is,

eq[[1]]

(*   3 + 2 x  *)

eq[[2]]

(*   5   *)


This enables one to map any operation onto any equation, in order to apply this operation to its both sides simultaneously, like this:

Map[Operation, equation]


with the following effect:

Operation[equation[[1]]]==Operation[equation[[2]]]


Let us see, how it works:

Step1: subtraction:

eq2A = Map[HoldForm[Subtract[#, 3]] &, eq]


The result is below. I have to place it as an image, since otherwise it contains lots of boxes:

The HoldForm[] above just prevents the result from the immediate simplification. If one does not care for the simplification, he writes as follows:

    Map[Subtract[#, 3] &, eq]

(*  2 x == 2  *)


Step 2: simplification. It may be simply done by just removing the HoldForm:

    eq2B = eq2A // ReleaseHold

(*   2 x == 2   *)


Step 3: Division. Let us divide the both parts by two and again use the HoldForm construct to prevent the immediate simplification:

eq3A = Map[HoldForm[Divide[#, 2]] &, eq2B]


yielding

Again, removing the HoldForm we allow Mma to simplify:

 eq3B = eq3A // ReleaseHold

(*   x == 1   *)


Done.

Have fun!