using System; using static System.Math; using static System.Console; class main{ static void Main(){ vector c = new vector("1 1"); int n=c.size; matrix A = new matrix(n,n); var rnd=new System.Random(1); for(int i=0;i f = (z)=>{ ncalls++; return (A*(z-c)).map(t=>t*t*t); }; /* Func f = delegate(vector z){ ncalls++; vector r=new vector(2); double x=z[0],y=z[1],b=10; r[0]=2*(1-x)*(-1)+b*2*(y-x*x)*(-1)*2*x; r[1]=b*2*(y-x*x); return r; }; */ double eps=1e-4; vector p = new vector("2 2"); p.print("broyden:\n start point:"); int nsteps = roots.broyden(f,ref p,eps); WriteLine($"nsteps={nsteps}"); WriteLine($"ncalls={ncalls}"); p.print("root="); f(p).print("f(root)="); WriteLine($"eps = {eps}"); WriteLine($"f(root).norm() = {f(p).norm()}"); if(f(p).norm()