An ideal spring stores energy while it is stretched or compressed. The force changes with extension, so potential energy is the signed work needed to move against the modeled restoring force—the area under the appropriate force-versus-extension curve. It is not a decorative quadratic tied to a spring drawing.
Think like a programmer
Derive potential energy from the same force function used by the simulation, with a declared reference extension. Keep extension, stiffness, force, energy, unit convention, and deformation regime in state/diagnostics. If a force law changes, update the energy calculation or perform numerical quadrature; never leave a hand-written ½kx² in a renderer after replacing Hooke’s law.
Model checklist
Inputs
Reference extension, current extension x, spring constant k or general force law F(x), loading/unloading path policy, numerical quadrature settings where needed, and unit conventions.
For a conservative force, calculate U(x) − U(xref) = −∫xref^x F(s)ds; use the same force law as dynamics and track path dependence explicitly when the material is nonconservative.
Output
Restoring force, stored/recoverable energy or work curve, energy difference, monotonicity/scaling diagnostics, and validity status.
Check
For F = −kx, U = ½kx² relative to zero extension; energy is even in x and nonnegative for k > 0; doubling x quadruples U; numerical force is the negative slope of U; a loading/unloading loop reports nonzero dissipated work rather than one conservative potential.
\[F=-kx\qquad U=\int_0^x ks\,ds=\frac12kx^2\]
Spring force and stored energy
Change stiffness and extension. The spring force points back toward equilibrium, while the stored energy stays positive.
Stiffness 40 N/m; extension 0.35 m; restoring force -14.00 N; elastic energy 2.45 J.
The negative sign in Hooke’s law points force back toward the reference extension. Energy is positive because it describes work supplied against that force. Check both derivatives: differentiating U gives dU/dx = kx, and the conservative force is F = −dU/dx. This relationship catches a sign bug that a nonnegative energy chart would not reveal.
For a general conservative force curve, use consistent units: newtons times metres gives joules. Numerical integration needs a grid or adaptive tolerance and a reference point. Test an analytic Hooke-law fixture before accepting a tabulated material curve. If force differs during loading and unloading, the area between curves is dissipated energy; a single-valued potential cannot represent that hysteresis without extra material state.
Try this experiment
Prediction: Doubling extension quadruples ideal spring energy, while a hysteretic loading/unloading curve stores and returns different work.
Keep stiffness fixed and predict the energy ratio before doubling x. Compare a numerical work integral with ½kx², then use a finite difference to check that −dU/dx reproduces force. Sketch or provide a loading/unloading force table and identify the loop area as loss, not recoverable elastic energy.
Where this model breaks
Hooke’s law is local. Springs bottom out, coils have mass, and materials can yield, buckle, fracture, or heat, so the force curve may not remain linear or conservative. A quasi-static work integral omits wave propagation, rate dependence, and distributed strain energy unless those are part of the model.
Summary
Compute elastic energy from the modeled force curve and reference extension. For an ideal spring it grows as extension squared; for nonlinear or hysteretic materials, preserve the force law, path policy, and any dissipated-work ledger.
Glossary
Hooke’s law: linear restoring-force approximation.
Spring constant: stiffness parameter in N/m.
Elastic potential energy: recoverable energy stored by deformation.
Hysteresis: loading/unloading path difference that can dissipate work.
Reference extension: chosen configuration with defined zero potential energy.
Self-check
Why is ideal spring energy quadratic?
What does the minus sign in Hooke’s law mean?
Which derivative relation checks force against energy?
Why can a hysteretic material not use one conservative potential alone?
Sources
OpenStax, University Physics Volume 1, elastic potential energy.
L. D. Landau and E. M. Lifshitz, Theory of Elasticity.
Model contract
Treat the lesson as a small function before treating it as a fact to memorize. Give every value a unit, keep only the state needed for the next step, and make the output easy to inspect.
Quantities you set or measure, with units and useful bounds.
State
Values the program must retain to reproduce the next result.
Rule
The relationship or update that turns inputs and state into a result.
Check
A known limit, unit check, invariant, or measured result that can expose a bad model.
Implement the idea as a model
For Elastic Energy, write down the quantities you can control, the values your program must retain, and the result a reader could inspect. In Equilibrium and Elasticity, the useful program is not the drawing: it is the smallest explicit model that makes a prediction you can test.
Guided experiment
Prediction: changing one declared input while holding the others fixed should change only the outputs that the model connects to that input. Choose one input, predict the direction of change, then check a limiting case such as zero, a symmetric arrangement, or a familiar low-speed or small-change approximation.
Where this model breaks
This lesson is a teaching model, not a complete simulator. Before using it outside the stated question, check which interactions, scales, uncertainties, boundary conditions, and measurement limits it leaves out.
Summary
Treat Elastic Energy as a contract: named inputs and units enter a rule, the rule produces an observable result, and a known limit or invariant checks whether the implementation deserves trust.
Glossary
Input: a measured value or chosen parameter supplied to a model.
State: the smallest set of values needed to continue or reproduce a model.
Validation: comparing an output with a known result, limit, invariant, or measurement.
Self-check
Which values are inputs, and which values must remain state?
What observable result would tell you the model is behaving as expected?
Which assumption would you test first before applying the model to a real system?
Model review: turn Elastic Energy into a test
Derive and compute the stored energy of an ideal spring from its force function.
Name the inputs and units that the equilibrium and elasticity model needs.
Separate the state you must keep from values you can calculate when needed.
Write one rule that maps the current state and inputs to an observable result.
Choose a limiting case, unit check, invariant, or known result before trusting an output.
State one assumption you would change before using this simplified model for a real decision.