A symmetry is a transformation that changes the description of a physical situation without changing the relevant laws. A conservation law states that a quantity remains constant for a specified system. These ideas meet precisely in Noether's theorem: under its assumptions, every continuous differentiable symmetry of an action corresponds to a conserved quantity.
Consider an isolated experiment performed today and repeated tomorrow with the same preparation. If the governing law has no preferred time origin, shifting every event by the same amount does not change its predictions. This is time-translation symmetry. If moving the entire isolated apparatus by the same displacement does not change the internal motion, the law has spatial-translation symmetry. If rotating the whole setup preserves the predictions after the result is rotated with it, the law has rotational symmetry.
The initial conditions need not themselves look symmetric. A projectile launched east does not have to produce the same untransformed trajectory after the apparatus is rotated north. The correct comparison transforms the inputs and then transforms the output in the corresponding way. This behavior is often called equivariance.
For a state transformation \(T\) and evolution map \(\Phi_t\), the comparison has the form
\[\Phi_t(T\mathbf y_0)=T\Phi_t(\mathbf y_0)\]when the transformation is a symmetry and all boundary conditions are transformed too. A fixed wall, external field, or laboratory support can break a symmetry that the isolated microscopic law would otherwise possess.
import numpy as np
def evolve(position, velocity, duration):
return np.asarray(position) + np.asarray(velocity) * duration
position, velocity = np.array([1.0, 2.0]), np.array([3.0, -1.0])
shift = np.array([7.0, 4.0])
assert np.allclose(
evolve(position + shift, velocity, 2), evolve(position, velocity, 2) + shift
)
print("Free motion respects a translation of the origin.")
For generalized coordinates \(q_i\), velocities \(\dot q_i\), and a Lagrangian \(L(\mathbf q,\dot{\mathbf q},t)\), the action between two times is
\[S=\int_{t_1}^{t_2}L(\mathbf q,\dot{\mathbf q},t)\,dt\]The physical path makes the action stationary under appropriate endpoint conditions, leading to the Euler-Lagrange equations:
\[\frac{d}{dt}\left(\frac{\partial L}{\partial\dot q_i}\right)-\frac{\partial L}{\partial q_i}=0\]Noether's theorem applies to a continuous family of transformations that leaves the action invariant, or changes the Lagrangian only by a total time derivative under the more general statement. It is not the claim that every visual symmetry, every discrete reflection, or every convenient code transformation automatically creates a new scalar conservation law.
If the Lagrangian has no explicit time dependence, the quantity
\[E_L=\sum_i\dot q_i\frac{\partial L}{\partial\dot q_i}-L\]is conserved along solutions. For ordinary particles with
\[L=T-U\]and standard velocity-independent potential energy, this quantity is the mechanical energy \(E=T+U\).
The key condition is no explicit dependence on time. A trajectory still changes with time, and its coordinates appear in the Lagrangian; that does not break time-translation symmetry. A moving support, prescribed time-varying field, or external drive does. In that case energy may enter or leave the chosen mechanical system.
Adding a constant to potential energy changes the numerical zero of \(E\) but not forces, energy differences, or conservation. That freedom is a reference convention, not the time-translation symmetry that produces energy conservation.
If the Lagrangian is unchanged by translating an isolated system in some direction, the corresponding component of total linear momentum is conserved. Generalized momentum is defined by
\[p_i=\frac{\partial L}{\partial\dot q_i}\]For Cartesian coordinates of ordinary nonrelativistic particles, \(\mathbf p=m\mathbf v\). If a Cartesian coordinate does not appear in the Lagrangian, it is cyclic, and its conjugate momentum is constant:
\[\frac{\partial L}{\partial q_i}=0\quad\Rightarrow\quad\frac{dp_i}{dt}=0\]For a system of particles, internal forces can exchange momentum among parts while total momentum remains constant. The practical balance law is
\[\frac{d\mathbf P}{dt}=\mathbf F_{\mathrm{external}}\]Momentum conservation therefore depends on the chosen system boundary. A person walking inside a boat exchanges momentum with the boat; considering only the person hides the compensating momentum. Considering person, boat, and relevant expelled or incoming mass restores the appropriate balance.
If an isolated system's Lagrangian is invariant under continuous rotations about an axis, the corresponding angular-momentum component is conserved. Full rotational invariance gives conservation of the angular-momentum vector. For a particle about an origin,
\[\mathbf L=\mathbf r\times\mathbf p\]and the balance law is
\[\frac{d\mathbf L}{dt}=\boldsymbol\tau_{\mathrm{external}}\]A central force points along \(\mathbf r\), so its torque about the force center is zero and angular momentum about that point is conserved. The result depends on the origin and on external torques. Angular momentum about one point need not equal angular momentum about another.
In a central-force orbit, conserved angular momentum implies equal areas are swept in equal times. This connects rotational symmetry to Kepler's second law without requiring the orbit to be circular.
Translations and rotations can vary by an arbitrarily small parameter, so they are continuous. Reflection is usually discrete: there is no chain of infinitesimal reflections connecting it to the identity in ordinary space. A reflection symmetry can still constrain solutions and produce useful parity labels, but the elementary Noether correspondence above is specifically about continuous symmetries.
Some transformations change the mathematical description while leaving every physical state unchanged. These gauge redundancies require special care; they are not simply ordinary motions through distinct physical configurations. This lesson uses mechanical translations and rotations, where the distinction is easier to see.
A conserved quantity remains constant only for the system to which the law applies. An open subsystem can gain energy, momentum, or angular momentum through its boundary. The more general accounting form is
\[\text{change inside}=\text{transfer in}-\text{transfer out}+\text{sources}\]Friction does not destroy total energy. It transfers organized mechanical energy into thermal and internal forms. Mechanical energy alone decreases if those forms are outside the bookkeeping. Momentum can be transferred to Earth through friction or supports. Always name the system before claiming a violation.
initial_momentum = 5.0
impulse_in, impulse_out = 2.0, 0.5
final_momentum = 6.5
residual = final_momentum - initial_momentum - (impulse_in - impulse_out)
print(f"Momentum balance residual: {residual:.3g} kg m/s")
The residual must have units and a scale. A fixed absolute tolerance can be too strict for large systems and too loose near zero, so combine physically justified absolute and relative tolerances.
Symmetry can be absent in the law, absent only in the environment, or present in the law but not in a chosen state. A uniform gravitational field selects a vertical direction and breaks full rotational symmetry. A circular bowl may have a rotationally symmetric potential while a ball resting at one off-center location does not share that symmetry. This last case is a property of the state, not necessarily of the governing law.
Approximate symmetry can produce approximate conservation over a limited interval. A planet perturbed weakly by other planets may have orbital quantities that change slowly rather than remain exactly fixed. Report the scale and duration of the approximation instead of replacing "approximately conserved" with "conserved."
A continuous model can possess an exact invariant while its discrete update does not. Forward Euler, for example, generally adds energy to an ideal harmonic oscillator. A small invariant error over a short trace does not guarantee acceptable long-time behavior. Some geometric integrators preserve a modified structure and keep errors bounded without keeping the exact physical energy constant at every step.
Test the physical law and the numerical method separately. Use an analytic trajectory when available, transform the initial data, and compare at matching physical times. Then reduce time step and spatial resolution independently. If symmetry and conservation residuals shrink at the expected rate, the discrepancy is likely discretization error. A residual that does not shrink can reveal inconsistent boundaries, a missing force, or a mistaken conserved quantity.
for steps in [20, 40, 80]:
dt = 2.0 / steps
x, shifted_x = position.copy(), position + shift
for _ in range(steps):
x += dt * velocity
shifted_x += dt * velocity
print(steps, np.linalg.norm(shifted_x - (x + shift)))
assert np.allclose(shifted_x, x + shift)
Sampling can create false confidence. Measuring only once per period may hide oscillating energy error, and rounded output may conceal drift. Inspect the full-resolution internal values and report the maximum, final, and characteristic pattern of the residual.
When using symmetry to predict conservation, first state the action or equations and the system boundary. Name the continuous transformation and its parameter. Verify that the law, external fields, constraints, and boundary conditions have the claimed invariance. Then identify the corresponding quantity and confirm its balance equation.
When checking computed data, do not infer the theorem backward from a nearly flat graph. A quantity may look constant over a short interval by coincidence or inadequate precision. Use the governing equations and symmetry argument first; use the numerical trace as verification.
Symmetry gives conservation laws their structural explanation, while balance laws show how those quantities move across a boundary. Used together, they provide both a deep theoretical connection and a practical way to detect incomplete models, inconsistent conditions, and numerical drift.
A freely moving body reaches 7 metres before a constant change of coordinate origin is applied. The question for this calculation is precise: how does shifted final position change when we change coordinate shift, 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.
The shift changes position labels but leaves velocity and displacement unchanged. 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 -5 to 5 m. 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 coordinate shift, expressed in m. The output is
shifted final 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 2 m, the expression gives 9 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("7+q", locals={"q": q})
reference_input = 2.0
reference_output = float(expression.subs(q, reference_input))
print("Input:", reference_input, "m")
print("Predicted shifted final 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 2 m. The midpoint, at 0 m, gives 7 m. The upper endpoint gives 12 m. Read these together with the assumptions: they describe different choices of coordinate shift 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([-5.0, 0.0, 5.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} m -> {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 coordinate shift; the vertical axis shows shifted final 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(-5.0, 5.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("Coordinate shift (m)")
ax.set_ylabel("Shifted final 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 shifted final position change near the reference input? Its units are the output unit divided by the input unit. For this calculation, the derivative at 2 m is 1 in those ratio units. Locally, the output increases as the input increases. This statement is local; the sign or size of the slope can be different elsewhere on the curve.
\[f'(q) = 1\]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 = 2.05
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 2.05 m. The tangent estimate is 9.05 m, while the full expression gives 9.05 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 = 10.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 coordinate shift inside the stated interval, predict whether shifted final 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: The shift changes position labels but leaves velocity and displacement unchanged. 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(5.0) - evaluate(-5.0))
for points in [101, 201, 401]:
grid = np.linspace(-5.0, 5.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.