#
#  Cournot-æfing á bls 35.
#

function [fval,fjac]=cournot(q)
c=[0.6;0.8];
c1=c(1);
c2=c(2);
q1=q(1);
q2=q(2);
eta=1.6;
#
# fengið með wxmaxima
#
fval=[(q1+q2)**((-1)/eta)-1/eta*(q1+q2)**((-1)/eta-1)*q1+(-c1)*q1;
    1/(q2+q1)**(1/eta)-q2*(q2+q1)**(-1/eta-1)/eta-c2*q2];
fjac=[-2*(q2+q1)**(-1/eta-1)/eta-(-1/eta-1)*q1*(q2+q1)**(-1/eta-2)/eta-c1, -(q2+q1)**(-1/eta-1)/eta-(-1/eta-1)*q1*(q2+q1)**(-1/eta-2)/eta;
      -(q2+q1)**(-1/eta-1)/eta-(-1/eta-1)*q2*(q2+q1)**(-1/eta-2)/eta, -2*(q2+q1)**(-1/eta-1)/eta-(-1/eta-1)*q2*(q2+q1)**(-1/eta-2)/eta-c2];

endfunction
#
# cournot-fall úr bók
#
#
function [fval,fjac]=cournot_bok(q)
c=[0.6;0.8];eta=1.6; e=-1/eta;
fval=sum(q)^e+e*sum(q)^(e-1)*q-diag(c)*q;
fjac=e*sum(q)^(e-1)*ones(2,2)+e*sum(q)^(e-1)*eye(2)+(e-1)*e*sum(q)^(e-2)*q*[1 1] -diag(c);
endfunction

