SHM displacement calculator
This simple harmonic motion displacement calculator finds an oscillator's position at a chosen time from its amplitude, angular frequency, and phase constant.
Run — free
It applies the standard cosine form of the SHM equation and reports displacement in metres. Use it to check physics exercises, evaluate a vibration model, or generate a precise position for a simulation. Every input must be a finite number, so malformed values are rejected instead of producing a misleading result.
Enter quantities that describe the same oscillator
Amplitude sets the greatest distance from equilibrium and must be supplied in metres. Angular frequency describes how rapidly the phase advances and must be in radians per second, while time is entered in seconds. The phase constant is an angle in radians that fixes the oscillator's position within its cycle at time zero. Keep these units consistent: ordinary frequency in hertz is not the same quantity as angular frequency, although you can convert it with angular frequency equal to two times pi times frequency. A negative amplitude is mathematically accepted because the formula remains defined, but in most physical descriptions amplitude is a non-negative magnitude; a negative value is equivalent to shifting the phase by pi radians. Time may be negative when you want to extend the ideal model before its chosen origin. The calculator requires actual JSON numbers. Numeric-looking text, blank values, infinity, and non-numeric tokens are rejected so that an accidental formatting problem cannot silently change the physical interpretation.
Understand the cosine calculation
The calculator evaluates displacement as amplitude multiplied by the cosine of angular frequency times time plus phase. First, multiplying angular frequency by time produces the phase accumulated since the time origin. Adding the phase constant gives the oscillator's total phase at the requested instant. Taking the cosine maps that phase to a value between minus one and one, and multiplying by amplitude scales it to metres. At total phase zero, the oscillator is at positive maximum displacement. At pi over two it crosses equilibrium, at pi it reaches negative maximum displacement, and at two pi it returns to its starting point. This sign convention follows the cosine form of simple harmonic motion. A source that uses a sine form is not contradictory; sine and cosine descriptions differ by a phase shift. Results use JavaScript floating-point arithmetic, so values expected to be exactly zero may appear as extremely small residuals, such as a few quadrillionths of a metre, because pi and trigonometric values cannot generally be represented exactly in binary.
Use the result within the model's limits
The returned displacement is an instantaneous signed position relative to equilibrium, not the total distance travelled. A positive result lies on the side chosen as positive by your coordinate system, while a negative result lies on the opposite side. The calculation represents ideal simple harmonic motion: amplitude and angular frequency remain constant, and damping, external forcing, nonlinear stiffness, and measurement uncertainty are not included. That makes it well suited to textbook mass-spring systems, small-angle approximations, ideal vibration checks, and deterministic simulation inputs. For a real damped oscillator, the amplitude changes with time and this equation alone is incomplete. Likewise, velocity and acceleration require their own derivatives rather than treating displacement as a rate. When comparing a result with experimental data, confirm that the data use the same time origin and phase convention. Through the API, each calculation costs $0.002; the browser version can run the same deterministic formula locally. Because the operation uses no network, random source, or clock, identical numeric inputs always follow the same calculation path and produce the same serialized result.
What you can do with it
Check a physics exercise
Evaluate the standard SHM equation at a specified time and compare the signed position with a worked solution.
Sample an ideal vibration
Calculate positions at selected timestamps for a deterministic mass-spring or vibration model.
Verify phase conventions
Test how a chosen phase constant changes the initial position and later points in an oscillation cycle.
FAQ
Which equation does the calculator use?
It uses x(t) = A cos(ωt + φ), where A is amplitude, ω is angular frequency, t is time, and φ is the phase constant.
What units should I enter?
Enter amplitude in metres, angular frequency in radians per second, phase in radians, and time in seconds. The result is in metres.
Can I enter frequency in hertz?
Not directly. Convert frequency f in hertz to angular frequency with ω = 2πf before submitting the value.
Why is an expected zero a tiny nonzero number?
Floating-point arithmetic approximates pi and trigonometric values, so mathematically exact zeros can have very small numerical residuals.
Does this include damping or external forcing?
No. It calculates ideal simple harmonic motion with constant amplitude and angular frequency.
What does an API calculation cost?
Each API calculation costs $0.002. The calculator can also run free in your browser.
For developers — API access
Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.
API endpoint
Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/mech/shm-displacement \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"amplitude_m":0.5,"angular_frequency_rad_s":3.141592653589793,"phase_rad":0,"time_s":0.5}'const res = await fetch("https://api.kit.forhosting.com/mech/shm-displacement", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"amplitude_m": 0.5,
"angular_frequency_rad_s": 3.141592653589793,
"phase_rad": 0,
"time_s": 0.5
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/mech/shm-displacement",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"amplitude_m": 0.5,
"angular_frequency_rad_s": 3.141592653589793,
"phase_rad": 0,
"time_s": 0.5
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/mech/shm-displacement", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"amplitude_m":0.5,"angular_frequency_rad_s":3.141592653589793,"phase_rad":0,"time_s":0.5}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"amplitude_m":0.5,"angular_frequency_rad_s":3.141592653589793,"phase_rad":0,"time_s":0.5}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/mech/shm-displacement", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"amplitude_m": 0.5,
"angular_frequency_rad_s": 3.141592653589793,
"phase_rad": 0,
"time_s": 0.5
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "mech.shm_displacement",
"status": "queued",
"_links": {
"result": "/tasks/tsk_…/result"
}
}The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |