# How do I graph acceleration?

I have written some java code for the calculation of some various acceleration and etc. type data. I am now trying to graph that data so I can pull specific data over a time line. The values I have received via my math program are purely accurate with several different means of error checking. I do not need assistance for the java programming. What I need is a accurate graphing techniques so I can get the appropriate data.

http://physicsforidiots.com/wp/wp-content/ql-cache/quicklatex.com-f80733c4cb4c6cb9bdef0e44fe176cab_l3.svg

acceleration formula

The x axis in that is the time variable. The y axis should be distance, but I'm getting totally bogus numbers. I know I may be off on my understanding of how it would graph.

    double D = Double.parseDouble(txtDistance.getText());
double T = Double.parseDouble(txtTime.getText());
double IV = Double.parseDouble(txtIVelocity.getText());
double M = Double.parseDouble(txtMass.getText());

double hd = Distance(D);
double ht = Time(T);

//2.0*(xt/th-v_i)/th
//double A = (2 * (hd - ht * IV)) / (ht * ht);
double A = 2 * (hd/ht - IV)/ht;
double PG = (A / 9.8) * 100;

//IV + A * ht
//double V = hd / ht;
double V = IV + A * ht;
double PL = (V / 299792458) * 100;
double MPH = V * 2.236936;

double F = M * A;
double LBT = F * 0.224809;

DecimalFormat df = new DecimalFormat("####0.0000");

txtVelocity.setText(String.valueOf(df.format(V)));
txtPLight.setText(String.valueOf(df.format(PL)));
txtMph.setText(String.valueOf(df.format(MPH)));

txtAcceleration.setText(String.valueOf(df.format(A)));
txtPGForce.setText(String.valueOf(df.format(PG)));

txtThrust.setText(String.valueOf(df.format(F)));
txtLBThrust.setText(String.valueOf(df.format(LBT)));


As you can see by that, I am inputting distance, time, initial velocity, and mass. And in return, it calculates and displays final velocity, percent light speed, miles per hour, acceleration, percent G-force, trust in newton's, and lbs of thrust.

Sample data:

Distance: 160934400 Km (just over an AU) Time: 40 hrs Initial velocity: 3070 m/s (geosynchronous earth orbit) Mass: 54431 Kg

The craft starts in earth orbit and accelerates for 50% of the distance and decelerates for 50% of the distance. This is figured with 72000 seconds, and 80467200000 meters.

Sample response:

Final velocity: 1117600.0000 m/s Percent light: 0.3728 % Miles per hour: 2499999.6736 mph (for human understanding of speed for reader) Acceleration: 30.9592 m/s^2 Percent G-force: 315.9099 % Thrust: 315.9099 N Lbs Thrust: 378834.2788 Lbs (again for human understanding)

I know these numbers are as accurate as they can be utilizing the constant acceleration equations posted above. I know these numbers are extreme, but it is a science fiction novel.

The purpose of all this is I am writing a science fiction novel and I have a story line and a time line. I am needing various speeds, based on time and acceleration, etc. I have an additional program that will take this data and graph it so I can click on points to get the appropriate data I need at the given time in the story.

What is the appropriate means of graphing that so I can get accurate numbers that will make sense for my story when you, potential reader read the book?

As an aside for even more accurate numbers, I need to know how to modify my equations to account for gravitational interference in acceleration, etc.

I have spent the last week, upwards to 80 hours working on this so my book can be as accurate as it can be. With that being said, it would be near impossible for me to include all my work on this subject. Any assistance you are willing to offer so I can move forward with this novel would be extremely appreciated.

• Define bogus numbers. – Kyle Kanos Jun 12 '15 at 16:33
• You seem to want to produce a graph as a necessary step for producing "accurate" values of velocity from time and accelleration. The graph seems superfluous and harmful to your aim - wouldn't it be simpler, quicker and more accurate to simply calculate the result using a calculator (or a three-cell spreadsheet)? – RedGrittyBrick Jun 12 '15 at 16:37
• Potentially, you are correct, and would be a good thing to produce, and a bit of assistance in doing so would be greatly appreciated. I was preferring a graph for the visualization aspect of it, which could potentially be included in the book in some meaningful manner. For now a spreadsheet would get me going, but I would still like to have the graph and the knowledge by which it was created. – texasman1979 Jun 12 '15 at 16:48
• (.5 * 30.9592\right) x^2 + 3070x + 0 ........ When I graph that, I get a parabola that totally doesn't make any sense to the data I have. – texasman1979 Jun 12 '15 at 16:52
• (.5 30.9592) x^2 + 3070x + 0 ..... edit – texasman1979 Jun 12 '15 at 16:58

I am more familiar with graphing in Python than in the language you are using. The following snippet of code produces the graph you are asking for:

import numpy as np
import matplotlib.pyplot as plt

# sci fi velocity graph
D = 160934400000     # m
v_i = 3070           # m/s
total_time = 40*3600 # seconds: 40 hours

# to cover half the distance in half the time, we solve
# x(t) = x(0) + v_0*t + 0.5*a*t*t
# x(0) = 0
# x(t) = D/2
# t = total_time / 2 = th
th = total_time / 2
xt=D/2
a = 2.0*(xt/th-v_i)/th

print 'acceleration needed is %.2f m/s^2'%a
# this prints out 30.96 m/s^2 - encouraging

# calculate position during acceleration phase - every second:
tm = 20*3600 # time at mid point
x=[]
for t in range(0,tm+1):
x.append(v_i*t + 0.5 * a * t * t)

xm = x[-1] # position at mid point

for t in range(tm+1, 2*tm):
x.append((v_i + tm*a)*(t-tm) - 0.5 * a * (t - tm) * (t - tm) + xm)

time = np.arange(0,2*tm)/3600.0

plt.close('all')
plt.figure()
plt.plot(time, np.array(x)/1000)
plt.xlabel('time (hr)')
plt.ylabel('position (km)')
plt.show()

v_t = np.diff(x)
plt.figure()
plt.plot(np.array(x[:-1])/1000,v_t/1000)
plt.xlabel('position (km)')
plt.ylabel('velocity (km/s)')
plt.show()

plt.figure()
plt.plot(time[:-1], v_t/1000)
plt.xlabel('time (hr)')
plt.ylabel('velocity (km/s)')
plt.show()


This produces the following graph:

You can also plot velocity as a function of time:

Or as a function of position:

• Comment in the programming: Numpy is a bit more expressive on the array math than you use. While I'm sure (hoping) that it was for clarity's sake, just thought I should point it out. – Kyle Kanos Jun 12 '15 at 19:05
• @KyleKanos Yes - I decided not to go all Python in this as it would likely confuse my audience. Actually I originally had tighter code with more lines of explanation, then decided to go more basic. Like this it is easier to follow / translate? – Floris Jun 12 '15 at 19:17
• i must say that actually comes out to the 1.6E11 meters is it supposed to, but i made a booboo in the explanation. that is included in your graph. it should accelerate to half point and decelerate to end point. from 0 to 40 it should appear to be more of a bell curve. – texasman1979 Jun 12 '15 at 20:10
• I am plotting the position, not the velocity, along the Y axis. The slope of this curve is the velocity - you see it accelerating for the first half and decelerating for the second half. If you want, you can plot velocity (which would be a triangle if plotted against time) or even velocity as a function of position (rather than time). I added those graphs. Did I understand you correctly? – Floris Jun 12 '15 at 20:38
• Mass is not an issue as the ship uses an experimental magnetic propulsion. The mass will not change. The sun is a rather large fuel tank. :) Thank you very much for your help. – texasman1979 Jun 13 '15 at 1:35