#include #include #include "TGraph.h" Double_t funz(Double_t x) { /* if(x==0) return 0; else return (exp(x)-1)/sqrt(x); */ return 100.-4*x*x +exp(x)*x; //return exp(x)*x; //return 3. - (x)*(x)+2.*x; //return x*x*x*x*x; // x*exp(x) -> primitiva exp(x)*(x-1) } Double_t funzR(Double_t *x, Double_t *par) { return funz(x[0]); } float pfunz(float x) { return 100.*x- 4.*x*x*x/3. +exp(x)*(x-1); //return exp(x)*(x-1); //return 3.*x - x*x*x/3. +x*x; //return x*funz(x)/6.; } double cintRett(float a, float b, int N) { double h, integ, x; h = (b-a)/N; //metodo dei rettangoli integ=0; for(x=a; xb); x+=h) for(x=a; x i-1) { std::cout<<" a problem here ..... "<Divide(2,2); C->cd(1); gIntRett->SetMarkerStyle(20); gIntRett->SetMarkerColor(kBlack); gIntRett->SetMarkerSize(0.5); gIntRett->Draw("AP"); TF1 *fa = new TF1("fRett","[0]*x",0.,(b-a)/3.); fa->SetParameter(0,fRett); fa->Draw("SAME"); C->cd(2); gIntRettPM->SetMarkerStyle(20); gIntRettPM->SetMarkerColor(kRed); gIntRettPM->SetMarkerSize(0.5); gIntRettPM->Draw("AP"); TF1 *fb = new TF1("fRettPM","[0]*x",0.,(b-a)/3.); fb->SetParameter(0,fRettPM); //fb->Draw("SAME"); TF1 *fb2 = new TF1("fRettPM2","[0]*x*x",0.,(b-a)/3.); fb2->SetParameter(0,fRettPM2); fb2->Draw("SAME"); // C->cd(3); gIntTrap->SetMarkerStyle(20); gIntTrap->SetMarkerColor(kBlue); gIntTrap->SetMarkerSize(0.5); //gIntTrap->Draw("AP"); gIntTrap->Draw("SAMEP"); TF1 *fc = new TF1("fTrap","[0]*x*x",0.,(b-a)/3.); fc->SetParameter(0,fTrap); fc->Draw("SAME"); C->cd(3); gIntSim->SetMarkerStyle(20); gIntSim->SetMarkerColor(kMagenta); gIntSim->SetMarkerSize(0.5); gIntSim->Draw("AP"); TF1 *fd = new TF1("fSim","[0]*x*x*x*x",0.,(b-a)/3.); fd->SetParameter(0,fSim); fd->Draw("SAME"); C->cd(4); TF1 *ftoInt = new TF1("function",funzR,a,b,0); ftoInt->Draw(""); }