- #1
RJLiberator
Gold Member
- 1,095
- 63
Homework Statement
I'm using ROOT (c++) to graph a numerical representation of the equation of motion.
For simplicity, I am using initial velocity = 10 and initial height = 10.
change in time = 0.05
so we find velocity by V_n = V_(n-1) -9.81*0.05
For some reason, this code is not giving me a correct reading.
I graph this against the computational method, and the computational method works perfectly.
Homework Equations
The Attempt at a Solution
Code:
float x[100], y[100];
int n = 100;
float timestep = 9.81*0.05;
float v = 10;
for (int i=0;i<n;i++) {
x[i] = i*timestep;
y[i] = v-timestep;
v = v-timestep;
}
TGraph *gr = new TGraph(n,x,y);
gr->SetMarkerColor(kBlue);
gr->SetMarkerStyle(29);
gr->Draw();