Kinematics describes motion without first asking what forces cause it. In one dimension, a position function tells where an object is at every modeled time. Velocity is the rate at which position changes, and acceleration is the rate at which velocity changes. Their signs depend on the chosen coordinate axis, not on whether an object is "really" moving forward or backward.
The statement "the object is at five metres" is incomplete. Position must be measured relative to an origin, along a chosen positive direction, in a stated reference frame. For a cart on a straight track, place the origin at one marker and choose rightward as positive. A position of \(x=-5\,\mathrm{m}\) then means five metres to the left of that origin. It does not mean negative distance.
If the cart moves from initial position \(x_i\) to final position \(x_f\), its displacement is
\[\Delta x=x_f-x_i\]Displacement can be positive, negative, or zero. Distance travelled is the total length of the path and is nonnegative. A cart that moves four metres left and then four metres right has zero displacement but travels eight metres.
Over a time interval, average velocity is displacement divided by elapsed time:
\[\bar v=\frac{\Delta x}{\Delta t}=\frac{x(t_2)-x(t_1)}{t_2-t_1}\]On a position-versus-time graph, this is the slope of the secant line joining the two events. Instantaneous velocity is the limit as the interval shrinks:
\[v(t)=\lim_{\Delta t\to0}\frac{x(t+\Delta t)-x(t)}{\Delta t}=\frac{\mathrm{d}x}{\mathrm{d}t}\]It is the slope of the tangent to the position graph. A positive slope means velocity is positive in the chosen coordinates; a negative slope means velocity is negative. A horizontal tangent gives zero instantaneous velocity, but the object may accelerate and begin moving again immediately afterward.
Instantaneous speed is the magnitude of velocity, \(|v|\). Average speed is distance travelled divided by elapsed time and is generally not the magnitude of average velocity.
Average acceleration describes the change in velocity over an interval:
\[\bar a=\frac{\Delta v}{\Delta t}\]Instantaneous acceleration is
\[a(t)=\frac{\mathrm{d}v}{\mathrm{d}t}=\frac{\mathrm{d}^2x}{\mathrm{d}t^2}\]Acceleration and velocity need not point in the same direction. When they have the same sign, speed increases. When they have opposite signs, speed decreases. A constant negative acceleration does not always mean slowing down: after the velocity becomes negative, that same acceleration makes the object move faster in the negative direction.
If acceleration is constant, integrating it with initial conditions at \(t=0\) gives
\[v(t)=v_0+at\]and
\[x(t)=x_0+v_0t+\frac{1}{2}at^2\]Every term in the position equation has length dimensions. The initial conditions are visible by substitution: at zero time, position is \(x_0\) and velocity is \(v_0\). Differentiating the position function recovers the velocity, and differentiating again recovers the constant acceleration.
initial_position_metres = 10.0
initial_velocity_metres_per_second = -2.0
acceleration_metres_per_second_squared = 0.5
time_seconds = 6.0
velocity = (
initial_velocity_metres_per_second
+ acceleration_metres_per_second_squared * time_seconds
)
position = (
initial_position_metres
+ initial_velocity_metres_per_second * time_seconds
+ 0.5 * acceleration_metres_per_second_squared * time_seconds**2
)
print(f"Position: {position:.1f} m; velocity: {velocity:.1f} m/s")
from dataclasses import dataclass
@dataclass(frozen=True)
class MotionState:
position_metres: float
velocity_metres_per_second: float
def constant_acceleration_state(
initial: MotionState,
acceleration_metres_per_second_squared: float,
time_seconds: float,
) -> MotionState:
position_metres = (
initial.position_metres
+ initial.velocity_metres_per_second * time_seconds
+ 0.5 * acceleration_metres_per_second_squared * time_seconds**2
)
velocity_metres_per_second = (
initial.velocity_metres_per_second
+ acceleration_metres_per_second_squared * time_seconds
)
return MotionState(
position_metres=position_metres,
velocity_metres_per_second=velocity_metres_per_second,
)
The function evaluates a closed-form trajectory. It does not need to store every earlier state, and it introduces no time-step truncation error.
Let \(x_0=10.0\,\mathrm{m}\), \(v_0=-2.0\,\mathrm{m/s}\), and \(a=0.50\,\mathrm{m/s^2}\). The object initially moves left while accelerating right.
It changes direction when velocity reaches zero:
\[0=v_0+at\quad\Rightarrow\quad t_{\mathrm{turn}}=-\frac{v_0}{a}=4.0\,\mathrm{s}\]Its position then is
\[x(4.0\,\mathrm{s})=10.0-8.0+4.0=6.0\,\mathrm{m}\]At \(t=6.0\,\mathrm{s}\), the position is \(7.0\,\mathrm{m}\) and the velocity is \(1.0\,\mathrm{m/s}\). The displacement from the start is negative three metres. The distance travelled is four metres to the turning point plus one metre back to the right, or five metres. This example shows why distance cannot be recovered from endpoint displacement whenever the velocity changes sign.
The slope of the position graph is velocity. The slope of the velocity graph is acceleration. The signed area under a velocity-versus-time graph is displacement, and the signed area under an acceleration-versus-time graph is change in velocity.
For constant positive acceleration, the acceleration graph is a horizontal line, the velocity graph is a straight line with positive slope, and the position graph is a parabola curving upward. The position graph can slope downward during the early part even while it curves upward. That combination represents negative velocity with positive acceleration, exactly as in the worked example.
A position function for an ordinary massive object should not jump instantaneously; that would imply an unbounded velocity. A velocity graph with an instantaneous jump implies an impulsive idealization and unbounded acceleration at the jump. Piecewise graphs in textbooks may use sharp corners to approximate changes that occur over short but nonzero intervals.
These idealizations can still be useful when the detailed transition is outside the question's scale. The page or program should name them rather than interpreting a sharp pixel corner as literal infinite acceleration.
A trustworthy implementation can test the relationships among the functions:
Constant-acceleration equations cease to apply when acceleration changes substantially with time, position, or velocity, or when a collision introduces a discontinuity in the idealized velocity. The definitions of position, velocity, and acceleration remain; the simple polynomial functions do not.
A formula may be algebraically evaluable outside the interval where its model applies. The worked trajectory can be evaluated at negative time, but that output describes an extrapolation before the chosen initial event. It is meaningful only if the same constant acceleration and coordinate frame also apply there. Likewise, evaluating far into the future may extend beyond a track, cross a collision, or enter a regime where the acceleration changes.
Store or document the allowed time interval with the trajectory. A plotting function should not silently suggest validity over all real time merely because it can request arbitrary values. Domain information belongs beside the function's assumptions and units, especially when a later algorithm composes several motion phases.
The cart from the worked reversal example starts at 10 metres with velocity minus 2 metres per second. The question for this calculation is precise: how does position change when we change time, while keeping the other choices fixed? The earlier sections explain the physical relationship. Here we turn one part of that relationship into a calculation that you can run, inspect, and change in Google Colab.
Constant acceleration of 0.5 metres per second squared applies over this interval. Keep that sentence beside the results. A formula can return a number outside its useful range, and a plotting library will usually draw that number without asking whether the physical assumptions still hold. The selected interval is from 0 to 6 s. It gives us a specific domain to discuss instead of leaving the graph's range to a software default.
Use the notebook link above the lesson, run the setup cell, and then run the cells in order. The code below is also included there. NumPy handles the arrays of numerical values, SymPy keeps the equation symbolic, and Matplotlib draws the results. If these libraries or notebook cells are unfamiliar, start with Your first physics notebook.
In this small example, q stands for time, expressed in s. The output is
position, expressed in m. The equation below uses the numerical values in those
units. Any fixed coefficients therefore carry the units needed to make the relation
consistent. A value supplied in another unit must be converted before it enters this
expression.
This is a function of one changing input. It is not a statement that the physical system has only one variable. We deliberately hold the other inputs fixed so that one cause of variation is visible. Changing several inputs at once would make it harder to tell which change produced the output difference. Write down the held-fixed choices before trying a different experiment.
At 4 s, the expression gives 6 m. This is our reference calculation. It is a prediction of the stated example, not a new measurement. Its displayed digits help us compare implementations. They should not be read as a claim that physical inputs are known to six significant figures.
import numpy as np
import sympy as sp
import matplotlib.pyplot as plt
q = sp.Symbol("q", real=True)
expression = sp.sympify("10-2*q+q**2/4", locals={"q": q})
reference_input = 4.0
reference_output = float(expression.subs(q, reference_input))
print("Input:", reference_input, "s")
print("Predicted position:", reference_output, "m")
sp.Symbol declares a mathematical symbol. It does not assign a numerical measurement
to that symbol. subs then replaces the symbol with our chosen input, and float
converts the resulting symbolic number into a standard Python numerical value.
Keeping these steps separate lets us inspect the equation before numerical substitution.
It also prevents a later plot from becoming the only surviving record of the model.
Before drawing hundreds of points, calculate three. The lower endpoint gives 10 m. The midpoint, at 3 s, gives 6.25 m. The upper endpoint gives 7 m. Read these together with the assumptions: they describe different choices of time within the same example, with the other inputs held fixed.
These three values are a useful first check, but they do not establish the shape between them. Two endpoints can be equal even when the curve bends or oscillates in between. Likewise, a large change between endpoints does not tell us whether the relationship is linear. We need the equation and intermediate samples to answer those questions.
evaluate = sp.lambdify(q, expression, modules="numpy")
inputs = np.array([0.0, 3.0, 6.0])
outputs = np.asarray(evaluate(inputs), dtype=float)
outputs = np.broadcast_to(outputs, inputs.shape)
for input_value, output_value in zip(inputs, outputs):
print(f"{input_value:.6g} s -> {output_value:.6g} m")
assert np.all(np.isfinite(outputs))
lambdify turns the symbolic expression into a numerical function. We explicitly select
NumPy as its numerical backend so it can accept an array. The same expression now has
two useful forms: one for algebra and one for calculating many cases. The assertion
checks that the chosen inputs produce finite outputs. It would catch an infinity or an
undefined numerical result, but a finite value can still be physically inappropriate.
The horizontal axis shows time; the vertical axis shows position. Every plotted point is a prediction of the same expression. We mark the reference case separately so that a reader can connect the earlier printed value to its place on the curve. The axis labels include units because a shape without a scale cannot tell us the size of a physical effect.
input_grid = np.linspace(0.0, 6.0, 301)
output_grid = np.asarray(evaluate(input_grid), dtype=float)
output_grid = np.broadcast_to(output_grid, input_grid.shape)
fig, ax = plt.subplots(figsize=(7, 4))
ax.plot(input_grid, output_grid, label="Stated model")
ax.scatter([reference_input], [reference_output], label="Reference case", zorder=3)
ax.set_xlabel("Time (s)")
ax.set_ylabel("Position (m)")
ax.legend()
ax.grid(alpha=0.25)
fig.tight_layout()
plt.show()
Look for a sign change, a turning point, or a region where the curve becomes steep. Connect each feature to the expression rather than to the colour of the line. If the curve has a minimum or maximum, changing the input in opposite directions may have similar effects on the output near that point. If it is nearly straight over a short interval, a local linear approximation may be useful even when the complete expression is nonlinear.
Increasing the number of samples makes the line smoother and may reveal features that a coarse grid missed. It does not improve the physical inputs or enlarge the model's validity range. For quantities that can take only discrete values, use the line as a guide to the relationship and interpret only the allowed input values. A plotting function does not enforce such restrictions for you.
A derivative asks a more specific question than the whole graph: how quickly does position change near the reference input? Its units are the output unit divided by the input unit. For this calculation, the derivative at 4 s is 0 in those ratio units. Locally, the output has no first-order change as the input increases. This statement is local; the sign or size of the slope can be different elsewhere on the curve.
\[f'(q) = \frac{q}{2} - 2\]For a small input change, multiply the derivative by that change to estimate the output change. Then compare that estimate with a fresh evaluation of the full expression. The distinction between these two calculations matters: the derivative gives a tangent approximation, while substitution evaluates the chosen expression at the new point.
slope_expression = sp.diff(expression, q)
slope_at_reference = float(slope_expression.subs(q, reference_input))
changed_input = 4.03
linear_prediction = reference_output + slope_at_reference * (
changed_input - reference_input
)
full_prediction = float(evaluate(changed_input))
print("Symbolic derivative:", slope_expression)
print("Tangent prediction:", linear_prediction, "m")
print("Full expression:", full_prediction, "m")
print("Approximation difference:", full_prediction - linear_prediction, "m")
Here the changed input is 4.03 s. The tangent estimate is 6 m, while the full expression gives 6.00023 m. If the two values are close, it means the chosen input change is small enough for this local approximation at this point. It does not mean the entire model is linear. If the slope is zero, a quadratic or higher-order term may supply the leading change instead.
This is also the beginning of uncertainty propagation. If the input has a small stated standard uncertainty, the magnitude of the slope times that uncertainty estimates one contribution to output uncertainty. Do not automatically use the same rule for a wide interval, a discontinuity, a turning point with zero first derivative, or several correlated uncertain inputs. Those situations need more of the model than one slope.
We can estimate the same slope from values on either side of the reference point. Subtract the lower output from the upper output and divide by twice the input step. Parentheses are essential: the entire output difference must be divided by the entire input interval. Without them, Python can execute a different mathematical expression while still producing a plausible number.
The calculation below uses three decreasing step sizes. Each estimate is compared with the symbolic derivative, so the reference is independent of the numerical difference formula. Near an endpoint, it is acceptable here to evaluate a small extension only because the displayed mathematical expression is smooth there; such a check does not assert that extrapolated values describe additional physical cases.
input_span = 6.0
for fraction in [1e-2, 1e-3, 1e-4]:
step = input_span * fraction
upper = float(evaluate(reference_input + step))
lower = float(evaluate(reference_input - step))
numerical_slope = (upper - lower) / (2 * step)
difference = numerical_slope - slope_at_reference
print(f"step={step:.6g}: slope={numerical_slope:.6g}, difference={difference:.6g}")
For a smooth function, reducing the step often reduces the approximation error at first. Very small steps can eventually make subtraction of nearly equal floating-point values less reliable. Therefore “smaller” is not an unlimited guarantee of “better.” Compare the observed behaviour over a useful range of steps instead of choosing the smallest number the computer can represent.
An absolute slope difference is useful when the expected slope is near zero. A relative difference would divide by a very small reference and could look enormous even when the absolute discrepancy is tiny. Away from zero, a relative difference can help compare quantities with very different scales. The tolerance should reflect the question and the numerical method, rather than a universal decimal threshold copied into every test.
Make one copy of the reference calculation before editing it. Choose a second value of time inside the stated interval, predict whether position will rise or fall, and then evaluate the expression. Place the prediction and the result in a text cell. If they disagree, identify whether the mistake was in the sign, the unit conversion, the algebra, or the assumption about how the curve behaves.
Next choose a shorter plotting interval around the reference point. Compare the local curve with its tangent approximation. Then widen the interval again. The difference shows why a useful local estimate need not describe the whole range. Keep the axis labels and numerical scale visible when comparing the plots; automatic axis limits can make two different effects appear equally large.
Finally, return to the physical limit stated at the start: Constant acceleration of 0.5 metres per second squared applies over this interval. Describe one change to the setup that would violate that limit. State what new input, equation, or observation would be needed before trusting an answer in the changed situation. This last step connects the Python experiment to the physics instead of treating successful execution as the only criterion for a useful result.
Before saving, restart the runtime and run all cells in order. A result that depends on an earlier, now-deleted input cell is not reproducible from the saved notebook. Keep unrounded values for later calculations, round only the reported output, and label any new data as measured, assumed, or generated. The graph and printed values should remain traceable to the same expression and the same choices of inputs.
There is another way to check that the expression and its derivative describe the same relationship. Add up the small output changes predicted by the slope across the chosen input interval. In the continuous limit, this integral equals the output at the upper endpoint minus the output at the lower endpoint. The result has units of m: the input unit in the integration cancels the input unit in the denominator of the slope.
This statement is about the mathematics of this particular relationship. It does not assign a new physical meaning to an arbitrary area under a graph. For example, an area under force versus distance represents work, while an area under a different pair of quantities may represent something else or have no standard name. Always carry the axis units through the calculation before naming an integral.
slope_function = sp.lambdify(q, slope_expression, modules="numpy")
endpoint_change = float(evaluate(6.0) - evaluate(0.0))
for points in [101, 201, 401]:
grid = np.linspace(0.0, 6.0, points)
slopes = np.asarray(slope_function(grid), dtype=float)
slopes = np.broadcast_to(slopes, grid.shape)
integrated_change = np.trapezoid(slopes, grid)
print(
points,
"integrated change:",
integrated_change,
"endpoint change:",
endpoint_change,
)
The trapezoidal rule joins neighbouring slope samples with straight segments and adds their signed areas. A negative contribution remains negative; replacing every slope by its magnitude would calculate a different quantity. Increasing the sample count provides a practical refinement check. If the values do not settle toward the endpoint difference, first inspect the interval, singularities, and array ordering.
Do not conclude that two agreeing calculations prove the model is physically complete. Both use the same selected relationship, so an omitted effect would be omitted from both. Their agreement is evidence that the numerical tools implement that relationship consistently. Comparing with an independent experiment or a more appropriate physical model is a separate test.
Keep this comparison in the notebook when you change the expression. It is particularly useful after adding a coefficient, changing a sign convention, or converting an input unit. A code cell that produces a smooth graph can conceal these mistakes; a second calculation of the same output change gives you another place to notice them.