kill(all)$

load(lrats),ratprint:false$

maxima:reaction rate (experimental),lsq ,version 1.0
peter.vlasschaert@gmail.com,03/01/2023

→ref : youtube 
--------------------

---------------------------------------------------------------------------------

ref part 1:youtube:https://www.youtube.com/watch?v=RW-4-Uu-Lm0

ref :part 2:youtube:https://www.youtube.com/watch?v=ZmdDdZda720

-----------------------------------------------------------------------------------

p1:[A+H,B,B+H,C,C+H,D];

p1a:print("A+H→B,r1")$
p1b:print("B+H→C,r2")$
p1c:print("C+H→D,r3")$

list :reaction rate

p1d:makelist(concat(r,i),i,1,length(p1)/2);

build equations : from "p1"
---------------------------------

eq[i]:=p1[2*i]-p1[2*i-1]=0;

p2:makelist(eq[i],i,1,length(p1)/2);

p2a:sort(listofvars(p2));

coef matrix :"p2"
----------------------

→ ν

p3:coefmatrix(p2,p2a);

→ transpose(ν)

p3a:transpose(p3);

reaction rate for every product :{A,B,C,D,H}
--------------------------------------------------------
R[x], x ={A,B,C,D,H}

p4a:transpose(p1d);

simp:false;

→ R =transpose(ν).p4a

p4b:R = p3a.p4a;

simp:true;

p4c:p4b;

p4c1:rhs(p4b)[1];

p4c2:flatten(makelist(rhs(p4b)[i],i,1,length(p2a)));

p4d1:makelist(sconcat(R,[i]),i,p2a);

p4d3:map("=",p4d1,p4c2);

R [x],x ={A,B,C,D,H}

p4d4:transpose(p4d3);

- sign = react ,+sign = forming

math :      b = M.x
→  M^(t).b = (M^(t).M).x      , t     ⇒ transpose
→ (M^(t).M)^(-1). M^(t).b     ,(-1)  ⇒ inverse
                  R =ν^t.r                  ,b =R, M =ν^t,x=r
→ (ν.ν^t)^(-1).ν.R =r

exact values : r1=1.2,r2=.8,r3=0.5

rexact:[r1=1.2,r2=.8,r3=.5];

p5re:ev(lratsubst(rexact,p4d3),nouns);

p5re1:float(p5re);

→Measurements :

experimental values :assume some :error,R

→ find : R,experimental

p6e:[-1.25,0.37,0.33,0.54,-2.41];

→ computation : r
see : math "above" ⇒  r=(ν.ν^t)^(-1).ν.R

r =

step 1:p3.p3a;

p6c1:p3.p3a;

step 2: inverse (p3.p3a)

p6c2:invert(p6c1);

step 3: inverse (p3.p3a).p3

p6c3:p6c2.p3;

step 4: inverse (p3.p3a).p3.transpose(p6e)

experimental :ri,i=1,2,3

float :experimental ⇒

p6c4:p6c3.transpose(p6e);