#include #include #include void fit2points(){ const Int_t num = 2; //Both Double_t or Float_t return same results. Double_t x1[2] = {1.e8, 1.e8 + 1.e6}; //base 1.e8 has no problem. Double_t x2[2] = {1.e9, 1.e9 + 1.e6}; //base 1.e9 returns not proper error. Double_t y[2] = {0., 1.}; Double_t ex[2] = {1., 1.}; //if error x is 0, fits have no problems. Double_t ey[2] = {0.1, 0.1}; TGraphErrors *gr1 = new TGraphErrors(num, x1, y, ex, ey); TGraphErrors *gr2 = new TGraphErrors(num, x2, y, ex, ey); gr1->SetMarkerStyle(20); gr2->SetMarkerStyle(20); TCanvas *c = new TCanvas("c","c",1200,800); c->Divide(2,1); c->cd(1); gr1->Draw("AP"); TF1 *f1 = new TF1("f1", "pol1"); gr1->Fit(f1,""); c->cd(2); gr2->Draw("AP"); TF1 *f2 = new TF1("f2", "pol1"); gr2->Fit(f2,""); return; }