! subrutina pentru calculul functiei F(W) si jacobianului JF(W): 
! X, X1, X2  = input
! ab = output
subroutine SUB_AB(X, X1, X2, a, b)
use work

implicit real(8) (a-h, o-z)
real(8)  X(ngl), X1(ngl), X2(ngl)
real(8)  a(ngl,ngl), b(ngl)

common /coef/	beta_h2, gama_h

real(8) mx2(ngl), mw



! jacobianul:
A =M + JG*beta_h2 + JG1*gama_h + JF*beta_h2
      

! termenii liberi bb = -F(w);
! Calculeaza M*X2:
do i =1,ngl
mw =0.
	do j=1,ngl
	mw =mw +m(i,j)*x2(j)
	enddo
mx2(i) =mw
enddo

!MX2 =matmul(M,X2)

b =-(MX2 +G +F -P)

end

