Home › Physics › Hooke's Law Calculator
Hooke's Law Calculator
Computes the restoring force of a linear spring and the elastic potential energy stored at a given displacement, plus the natural period and frequency of a mass on that spring when a mass is supplied.
When to use
You know a spring constant and how far the spring is stretched or compressed and need the force or stored energy, or the oscillation period of a spring–mass system.
Do not use when: The spring is loaded beyond its elastic (linear) limit, or you need gravitational energy (use potential-energy) or a pendulum's period (use pendulum).
Formula
force_n = spring_constant_n_m × |displacement_m|; U = ½ × spring_constant_n_m × displacement_m²; T = 2π × √(mass_kg / spring_constant_n_m); f = 1 / T
Ideal massless linear spring (Hooke's law holds only within the elastic limit); the period formula ignores damping and the spring's own mass.
Inputs
| Parameter | Type | Unit | Required | Description |
|---|---|---|---|---|
spring_constant_n_m | number | N/m | yes | Stiffness k in newtons per metre. Range: > 0 |
displacement_m | number | m | yes | Extension (positive) or compression (negative) from the natural length, in metres (1 cm = 0.01 m). |
mass_kg | number | kg | no | Optional mass on the spring; enables the oscillation period and frequency outputs. Range: > 0 |
Outputs
| Output | Type | Unit | Description |
|---|---|---|---|
force_n | number | N | Magnitude of the restoring force |k × x|, directed back toward the natural length. |
elastic_potential_energy_j | number | J | U = ½ × k × x². |
period_s | number | s | T = 2π√(m / k) (only when mass_kg is given). |
frequency_hz | number | Hz | f = 1 / T (only when mass_kg is given). |
Example
k = 200 N/m stretched 5 cm with 0.5 kg: {"spring_constant_n_m":200,"displacement_m":0.05,"mass_kg":0.5} → {"force_n":10,"elastic_potential_energy_j":0.25,"period_s":0.3142,"frequency_hz":3.1831}
k = 5000 N/m compressed 12 cm: {"spring_constant_n_m":5000,"displacement_m":-0.12} → {"force_n":600,"elastic_potential_energy_j":36}
GET https://tttkmbb.com/api/v1/calculate/hookes-law?spring_constant_n_m=200&displacement_m=0.05&mass_kg=0.5
Machine access
- API:
GET https://tttkmbb.com/api/v1/calculate/hookes-law(query parameters) orPOSTwith a JSON body{"inputs": {...}} - Schema: https://tttkmbb.com/api/v1/calculators/hookes-law · Markdown: https://tttkmbb.com/physics/hookes-law.md · JSON definition: https://tttkmbb.com/physics/hookes-law.json
- MCP: server
https://tttkmbb.com/mcp, toolrun_calculator with calculator_id="hookes-law" - OpenAPI operationId:
calculate_hookes_law - Freshness:
static. Authentication: none. Rate limit: fair use (see rate limits).
Sources
- HyperPhysics – Elastic potential energy (reference)
- Wikipedia – Hooke's law (reference)
FAQ
How do I find the spring constant?
Hang a known mass and measure the extension: k = m·g / x. For example 0.5 kg stretching a spring 2.45 cm gives k = 0.5 × 9.80665 / 0.0245 ≈ 200 N/m.
Does the sign of the displacement matter?
Only for direction; the force magnitude and the stored energy are the same for equal stretch or compression.
Related calculators
- Pendulum Period Calculator — Period of a pendulum oscillator.
- Potential Energy Calculator — Gravitational rather than elastic stored energy.
- Force Calculator — Force from mass and acceleration.