#                              Ren-Cang Li, June 1, 1996
#                              na.rcli@na-net.ornl.gov

cx1fixedf3out:=proc(x:vector, dx:vector, cx1)
    local fvect, DF, niter, err, eps, i, j;
    fvect:=vector(7): DF:=matrix(7,7): niter:=0:
    #
    err:=1: niter:=0: eps:=10^(-Digits+30):
    #
    while err > eps and niter <= 100 do
        niter:=niter+1:
        for i from 1 to 2 do
            fvect[i]:=subs(cx[1]=cx1,  cx[2]=x[1], cx[3]=x[2], cx[4]=x[3],
                           cy[1]=x[4], cy[2]=x[5], cy[3]=x[6], cy[4]=x[7], 
			   f[i]):
            for j from 1 to 7 do
                DF[i,j]:=subs(cx[1]=cx1,  cx[2]=x[1], cx[3]=x[2], cx[4]=x[3],
                           cy[1]=x[4], cy[2]=x[5], cy[3]=x[6], cy[4]=x[7], 
			   g[i][j+1]):
            od:
        od: 
        for i from 4 to 8 do
            fvect[i-1]:=subs(cx[1]=cx1,  cx[2]=x[1], cx[3]=x[2], cx[4]=x[3],
                           cy[1]=x[4], cy[2]=x[5], cy[3]=x[6], cy[4]=x[7], 
			   f[i]):
            for j from 1 to 7 do
                DF[i-1,j]:=subs(cx[1]=cx1,  cx[2]=x[1], cx[3]=x[2], cx[4]=x[3],
                           cy[1]=x[4], cy[2]=x[5], cy[3]=x[6], cy[4]=x[7], 
			   g[i][j+1]):
            od:
        od: 
        err:=norm(fvect): 
	# print(err): # print(evalf(Svd(DF))):
        x:= evalm(x-linsolve(DF, fvect)):
    od:
    # print(`In cx1fixedf3out`): print(err);
    if niter>100 then
       print(`In MyItern: Over 100 iterations`):
    else
    # Compute derivative dcx_i over dcx_1
        for i from 1 to 2 do
                fvect[i]:=-subs(cx[1]=cx1,  cx[2]=x[1], cx[3]=x[2], cx[4]=x[3],
                                cy[1]=x[4], cy[2]=x[5], cy[3]=x[6], cy[4]=x[7], 
			        g[i][1]):
        od: 
        for i from 4 to 8 do
            fvect[i-1]:=-subs(cx[1]=cx1,  cx[2]=x[1], cx[3]=x[2], cx[4]=x[3],
                           cy[1]=x[4], cy[2]=x[5], cy[3]=x[6], cy[4]=x[7], 
			   g[i][1]):
        od: 
	dx:=linsolve(DF, fvect):
    fi:
end:
