kill(all);

How to solve chemical equations H(2)+O(2)->H(2)O:
peter.vlasschaert@gmail.com,13/03/2017

1e)  Method Algebraic:
x1 H   + x2 O    = x3 H O
    2        2         2

solve : to find x1,x2,x3

first   equation : Oxygen Balance

eq1: 2*x2 = 1*x3;

second  equation : Hydrogen Balance

eq2: 2*x1 = 2*x3;

how to get (Menu) : -> Equations -> Solve Algebraic System                   

eq3:algsys([eq1, eq2], [x1,x2,x3]);

eq4:part(eq3,1,1);
eq5:part(eq3,1,2);
eq6:part(eq3,1,3);

eq7:subst(%r1= 1,eq4);
eq8:subst(%r1= 1,eq5);
eq9:subst(%r1= 1,eq6);

We find : x1=1,x2=1/2,x3=1

2e) Method Echelon (Maxima) Form:
x1 H   + x2 O    = x3 H O
    2        2         2

 rem : H  = H(2) ,H O = H(2)O
        2          2
       O  = O(2)
        2

            H(2) O(2) H(2)O
         H   2    0    2
         O   0    2    1  

rec:matrix([2,0,2],[0,2,1]);

eq10: echelon(rec);

we put last row ,[0,0,1] -> to represent one molecule H(2)O
( Because not rectangular matrix)

rec1:matrix([2,0,2],[0,2,1],[0,0,1]);

unity matrix: (3,3)

rec1one :matrix([1,0,0],[0,1,0],[0,0,1]);

eq11:echelon(rec1);

eq12: x1 = eq11[1,3];
eq13: x2 = eq11[2,3];
eq14: x3 = eq11[3,3];

             H(2) O(2) H(2)O
         O   0    2    1
         H   2    0    2  

Interchange of rows doesn't matter,'echelon' form.

rec2:matrix([0,2,1],[2,0,2],[0,0,1]);

Try to make form : unity matrix(3,3),see above

eq15:echelon(rec2);

We find : x1=1,x2=1/2,x3=1