# 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.

- Calculator id: `hookes-law` · Category: Physics (`physics`) · Tool name: `calculate_hookes_law`
- Canonical page: https://tttkmbb.com/physics/hookes-law · This document: https://tttkmbb.com/physics/hookes-law.md · JSON definition: https://tttkmbb.com/physics/hookes-law.json

## Purpose

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.

**Use when:** 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).

## Input

| Parameter | Type | Unit | Required | Description |
| --- | --- | --- | --- | --- |
| `spring_constant_n_m` | number | N/m | required | Stiffness k in newtons per metre. (> 0) |
| `displacement_m` | number | m | required | Extension (positive) or compression (negative) from the natural length, in metres (1 cm = 0.01 m). |
| `mass_kg` | number | kg | optional | Optional mass on the spring; enables the oscillation period and frequency outputs. (> 0) |

## Output

| Field | 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). |

## 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.

## Data Sources

- HyperPhysics – Elastic potential energy — http://hyperphysics.phy-astr.gsu.edu/hbase/pespr.html (reference, retrieved 2026-09-23)
- Wikipedia – Hooke's law — https://en.wikipedia.org/wiki/Hooke%27s_law (reference, retrieved 2026-09-23)

Data freshness: `static`. Deterministic formula with fixed constants; results never go stale. Inputs supplied by the caller determine the output.

## API

- `GET https://tttkmbb.com/api/v1/calculate/hookes-law?spring_constant_n_m=…&displacement_m=…`
- `POST https://tttkmbb.com/api/v1/calculate/hookes-law` with JSON body `{"inputs": {…}}`
- Response: unified envelope (`success`, `request`, `result.values`, `result.units`, `sources`, `freshness`, `timestamp`, `next_actions`, `links`); see https://tttkmbb.com/docs/response-format.md
- Schema: https://tttkmbb.com/api/v1/calculators/hookes-law · OpenAPI operationId `calculate_hookes_law` in https://tttkmbb.com/openapi.json
- Authentication: none. Rate limit: fair use, see https://tttkmbb.com/docs/rate-limits.md.

## MCP

- Server: `https://tttkmbb.com/mcp` (Streamable HTTP, JSON-RPC 2.0, no auth)
- Tool:  `run_calculator` with `{"calculator_id": "hookes-law", "inputs": {…}}`

## Example

- k = 200 N/m stretched 5 cm with 0.5 kg: inputs `{"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: inputs `{"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
```

## Limitations

The spring is loaded beyond its elastic (linear) limit, or you need gravitational energy (use potential-energy) or a pendulum's period (use pendulum). Ideal massless linear spring (Hooke's law holds only within the elastic limit); the period formula ignores damping and the spring's own mass. All values are computed from the formula above; no measurement or live data is involved.

## 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

- [Pendulum Period Calculator](https://tttkmbb.com/physics/pendulum.md) — Period of a pendulum oscillator.
- [Potential Energy Calculator](https://tttkmbb.com/physics/potential-energy.md) — Gravitational rather than elastic stored energy.
- [Force Calculator](https://tttkmbb.com/physics/newtons-second-law.md) — Force from mass and acceleration.
