Haversine function calculator
The haversine of 90° is 0.5: one minus the cosine, halved, matches the square of the sine of half the angle, 0.707106781187 times itself. Both forms are shown, so you can check the identity at a glance. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Angle
- 90 deg
- Angle rad
- 1.5707963268 deg
- Angle deg
- 90
- Haversine
- 0.5
- Cos theta
- 0
The haversine of an angle is the compact trigonometric quantity defined by hav(θ) = (1 − cos θ) / 2, which is algebraically identical to sin squared of half the angle. Great-circle distance formulas, spherical excess checks, and many navigation worksheets use this form because it stays numerically well-behaved for small central angles where a direct cosine difference loses precision. This capacity takes one angle in degrees or radians, evaluates both equivalent expressions, and returns a stable rounded haversine together with cos θ and sin(θ/2) so you can audit the identity by eye.
What the haversine function is and why it exists
The haversine function maps a real angle θ to a value in the closed interval [0, 1]. By definition hav(θ) equals one minus the cosine of θ, all over two. Because of the half-angle identity sin²(φ) = (1 − cos 2φ) / 2 with φ = θ/2, the same quantity is also equal to the square of the sine of half the angle.
That dual reading is what makes the function useful: textbooks and older nautical tables often tabulate haversines so that spherical triangle formulas can be written without nested square roots of negative differences, while modern code uses the same algebra to compute great-circle central angles from latitude and longitude differences. When two points on a sphere are close, cos c ≈ 1 for the central angle c, and subtracting two nearly equal cosines of coordinates would cancel significant digits; rearranging through haversines keeps intermediate values small and positive.
This page is not a full point-to-point distance tool—those landings ask for two coordinate pairs—but the elementary building block: given only θ, report hav(θ) and the pieces that prove the identity. Understanding that single-number step is what homework, code reviews, and spherical geometry notes actually need before the multi-coordinate formula is assembled.
Numerical range, precision, and how this differs from distance tools
Because cosine ranges over [−1, 1], the expression (1 − cos θ)/2 always lands in [0, 1] for real θ, with hav(0) = 0, hav(π) = 1, and hav(π/2) = 1/2. Tiny floating-point drift that would push the value slightly outside [0, 1] is clamped so callers never see −1e−16 or 1 + 1e−16 as a legitimate haversine. Use those when you already have coordinates or need signed half-angle trig; use this page when the question is simply “what is the haversine of this angle?”
in degrees or radians.
What you can do with it
Homework and textbook haversine checks
Students enter 60°, 90°, or π radians and confirm hav(θ) equals (1 − cos θ)/2 and sin²(θ/2) before assembling a full spherical triangle solution.
GIS and navigation intermediate steps
Developers verify that intermediate haversine values in a great-circle or rhumb-line code path match the closed-form single-angle definition.
FAQ
What is the haversine of an angle?
hav(θ) = (1 − cos θ) / 2, which is also equal to sin²(θ/2). This calculator returns that value for any finite angle in degrees or radians.
Is this the same as great-circle distance?
No. Distance tools take two latitude/longitude pairs. This page evaluates only the haversine of a single angle—the building block inside those formulas.
What happens if the angle is not a number?
Only finite numeric angles (or digit strings that parse to finite numbers) are accepted.
What is the haversine of 90 degrees?
It is 0.5. The cosine of 90° is 0, so one minus the cosine, divided by two, gives 0.5, and squaring the sine of half the angle, 0.707106781187, gives the same 0.5.
What range of values can the haversine take?
Always from 0 to 1. The haversine of 0 is 0, the haversine of π is 1 and the haversine of a right angle is one half, because the cosine of a real angle never leaves the range from minus one to one.
Related tools
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/trig/haversine-function \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"angle":90}'const res = await fetch("https://api.kit.forhosting.com/trig/haversine-function", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"angle": 90
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/trig/haversine-function",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"angle": 90
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/trig/haversine-function", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"angle":90}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"angle":90}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/trig/haversine-function", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"angle": 90
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "trig.haversine_function",
"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. |
Technical notes
Non-numeric or non-finite input is rejected with invalid_input.
How to call the calculator and read the result
A short formula string documents the identity used. Send a numeric field named angle (aliases theta and value are accepted) and optionally unit set to deg or degrees (the default) or rad or radians. Digit strings that parse to finite numbers are allowed; missing fields, empty strings, NaN, Infinity, objects, and other non-numeric types fail with invalid_input naming the problem field. On success the JSON echoes the input angle and normalized unit, reports the angle in both radians and degrees, and returns haversine as the primary result. For transparency it also returns cos_theta, sin_half, and sin_half_squared so you can confirm that (1 − cos θ)/2 and sin²(θ/2) agree after rounding. Pricing for a successful API call is a flat $0.002 under the item unit; validation failures are never charged. Typical clients include students checking hav(90°) = 1/2, tutors generating answer keys, GIS developers verifying intermediate steps of a great-circle implementation, and CI pipelines that freeze expected JSON so a refactor cannot silently change the definition.
Numerical range, precision, and how this differs from distance tools
Related search intents such as great-circle distance between two lat/lon points, half-angle sin/cos/tan with signs, or power-reduction of sine squared are separate landings with different inputs and SEO titles.
Integration use cases
CI fixtures for spherical math libraries
Pipelines freeze JSON golden outputs for known angles so a future refactor cannot redefine hav(θ) or flip units silently.
Technical questions
How do I compute the haversine function online?
POST a numeric angle (and optional unit deg or rad) to this endpoint, or use the free browser form. The response field haversine is the primary result.
Is the browser haversine calculator free?
Yes. The in-browser runner uses the same library as the API and costs nothing. The API charges $0.002 per successful request from your prepaid KIT balance.