#include #include #include //function and initial points Double_t func(Double_t x) { return x*0.5+sin(x); } // histograms filled and drawn in a loop void zlatirez() { TCanvas *c1 = new TCanvas("c1","Zlati rez",200,10,600,600); c1->SetGrid(); Double_t ax,bx,cx,xmin,fmin; xmin=-1e8; ax=-4.; bx=0; cx=1; // Create some histograms. TF1* main = new TF1("MyFunc","func(x)",-5.,5.); main->SetFillColor(41); main->SetNpx(100000); // Fill histograms const Int_t niter=10000; Double_t wgold=(3.-sqrt(5.))*0.5; Double_t r=1-wgold; Double_t epsilon=1e-3; Double_t x[niter], y[niter]; Double_t f1,f2,x0,x1,x2,x3; x0=ax; x3=cx; //wider interval if (fabs(cx-bx) > fabs(bx-ax)) { x1=bx; x2=bx+wgold*(cx-bx); } else { x2=bx; x1=bx-wgold*(bx-ax); } f1=func(x1); f2=func(x2); Int_t i=0; for ( i=0; iUpdate(); c1->Modified(); }