void freefall_h(){ double x=100;//[m] double x0=0;//[m] double v=100;//[m/s] double v0=0;//[m/s] double t;//[s] double dt;//[s] double g=9.8; TGraph *gr_v = new TGraph(512*100); TGraph *gr_x = new TGraph(512*100); t=0;//iinuma dt=1E-3;//iinuma 1msec int i=0;//iinuma while(t<5){ t+=dt; double k[4], l[4]; k[0] = dt*v0; l[0] = dt*(-g); k[1] = dt*(v0+l[0]/2.0); l[1] = dt*(-g); k[2] = dt*(v0+l[1]/2.0); l[2] = dt*(-g); k[3] = dt*(v0+l[2]); l[3] = dt*(-g); x=x0+(k[0]+2*k[1]+2*k[2]+k[3])/6.0; v=v0+(l[0]+2*l[1]+2*l[2]+l[3])/6.0; x0=x; v0=v; if(i<512*100)gr_v->SetPoint(i,t,v); if(i<512*100)gr_x->SetPoint(i,t,x); printf("point at t=%lf x=%lf \n",t,x); i++; } //iinuma ///////Graph gROOT->SetStyle("Plain"); gROOT->ForceStyle(); gStyle->SetOptStat(0); gStyle->SetCanvasBorderMode(0); gStyle->SetPadColor(0); gStyle->SetTitleFillColor(0); gStyle->SetStatColor(0); gStyle->SetCanvasColor(0); gStyle->SetFrameLineColor(1); TCanvas *c = new TCanvas("c","check x",200,100,500,500); c->SetLeftMargin(0.13); TH2F* frame = new TH2F("frame"," ",10, -0.1, 6, 100, -150, 10); frame->SetTitle(""); frame->GetXaxis()->SetLabelSize(0.04); frame->GetXaxis()->SetTitleSize(0.05); frame->GetYaxis()->SetLabelSize(0.04); frame->GetYaxis()->SetTitleSize(0.05); frame->GetXaxis()->SetTitle("t[sec]"); frame->GetYaxis()->SetTitle("x[m]"); frame->GetYaxis()->SetTitleOffset(1.2); frame->SetStats(0); frame->Draw(); gr_x->SetMarkerStyle(7); gr_x->SetMarkerColor(1); gr_x->SetLineWidth(2); gr_x->Draw("p"); c->SetGrid(); }