%EXS 3.8
k1=0.12;
k2=0.22;
atot=0.6;
btot= 1.0;
%startgissning a=atot*c, b=btot*l
a=atot/2;
b=btot/2;
x=[a b]';
iter=0;
xnorm = 1;
while xnorm>1e-4 & iter<10
    f=[a+k1*a*b+k2*a*b^2-atot
       b+k1*a*b+2*k2*a*b^2-btot];
    df = [1+k1*b+k2*b^2 k1*a+2*k2*a*b
        k1*b+2*k2*b^2 1+k1*a+4*k2*a*b];
    dx=-df\f; 
    x=x+dx;
    xnorm=norm(dx, inf);%största felet
    a=x(1);
    b=x(2);
    iter=iter+1;
   
end
xnorm
iter
x
f=[a+k1*a*b+k2*a*b^2-atot
   b+k1*a*b+2*k2*a*b^2-btot]