using System; using static System.Console; using static System.Math; public partial class qnewton{ //public static readonly double EPS=1.0/1048576; //public static readonly double EPS=1.0/2097152; public static readonly double EPS=1.0/4194304; public static vector gradient(Funcf, vector x){ vector g=new vector(x.size); double fx=f(x); for(int i=0;if, ref vector x, double acc=1e-3){ double fx=f(x); vector gx=gradient(f,x); matrix B=matrix.id(x.size); int nsteps=0; while(nsteps<999){ nsteps++; vector Dx=-B*gx; if(Dx.norm()1e-6){ B.update(u,u,1/uTy); // SR1 update } x=z; gx=gz; fx=fz; } return nsteps; }//SR1 }//class