Cosine calculator
Type an angle in radians and get its cosine, rounded to twelve decimals: 1.0471975511965976, which is π/3, gives exactly 0.5. Any finite angle works, however large, and the answer always lies between −1 and 1. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Angle
- 1.0471975512
- Angle
- 1.0471975512 rad
- Cosine
- 0.5
Send any finite angle, however large or small, and get back the exact double-precision cosine, rounded to twelve decimal places for stable, reproducible results. The same code runs free in your browser on this page, so you only pay when you automate it.
What cosine actually measures
On the unit circle, an angle measured in radians from the positive x-axis lands on a point whose horizontal coordinate is the cosine of that angle. That single number tells you how much of the direction points along the x-axis: 1 when the angle is 0, 0 at a quarter turn (π/2), -1 at a half turn (π), and back to 0 at three quarters of a turn.
Because the circle wraps around, cosine is periodic with period 2π — the cosine of 100 radians is perfectly well defined, and this calculator handles arbitrarily large finite angles without complaint. Radians are the natural unit here: they measure angle as arc length on the unit circle, which is why every formula in calculus, physics and signal processing assumes them. If your angle is in degrees, divide by 180 and multiply by π before calling.
The result always lies in the closed interval [-1, 1]; if you ever see a value outside it, something upstream fed you degrees by mistake.
Where cosine shows up in practice
Cosine is everywhere a projection or a periodicity appears. In physics, the work done by a force is F·d·cos(θ), so the cosine of the angle between force and displacement scales the result. In graphics and games, the dot product of two unit vectors equals the cosine of the angle between them — the cheapest visibility and lighting test there is.
In signal processing, a pure tone is literally a cosine wave, and the Fourier transform measures how much of each cosine frequency lives inside a signal. In navigation, the law of cosines turns three known sides of a triangle into any angle.
What you can do with it
Project a force or vector
Multiply a magnitude by cos(θ) to get the component of a force, velocity or field along an axis, straight from a script or spreadsheet.
Angle between two directions
Feed the angle from a dot product into lighting, collision or alignment logic and verify the cosine you expect is the cosine you get.
Generate and check waveforms
Evaluate a cosine wave at any phase when prototyping audio, animation or sensor models without installing a math library.
FAQ
Does it take degrees or radians?
Radians only. To convert degrees, multiply by π and divide by 180 before calling: 60° becomes about 1.0471975512 radians.
Can I pass the angle as a string?
Non-numeric input is rejected with a clear error message.
What is the range of the output?
Always a number in the closed interval [-1, 1]. The response also echoes the normalized angle, the unit (rad) and the method used.
What is the cosine of 0, π/2 and π?
The cosine of 0 is 1, of π/2 (a quarter turn) it is 0 and of π (a half turn) it is −1; at three quarters of a turn it is 0 again. These are the horizontal positions on the unit circle.
What is cosine used for?
To take the part of a force or a velocity that points along an axis, as in the work formula F·d·cos(θ); to measure the angle between two directions through a dot product; and to describe waves, since a pure tone is a cosine wave.
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/math/cos \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"angle":1.0471975511965976}'const res = await fetch("https://api.kit.forhosting.com/math/cos", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"angle": 1.0471975511965976
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/math/cos",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"angle": 1.0471975511965976
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/math/cos", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"angle":1.0471975511965976}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"angle":1.0471975511965976}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/math/cos", 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": 1.0471975511965976
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "math.cos",
"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
The cosine API takes an angle expressed in radians and returns its cosine — a single number between -1 and 1. It is the fundamental trigonometric ratio behind waves, rotations, projections and periodic motion, computed here in one deterministic call.
How the computation works
The output is rounded to twelve decimal places before it is returned. There is no network call, no randomness and no clock anywhere in the path, so the same input always produces the same output, today and in any replay of your logs. The endpoint validates that your angle is a finite number — accepting plain JSON numbers as well as numeric strings like "1.5708" or "6.283e-1" — and then evaluates the cosine in IEEE-754 double precision, the same arithmetic your browser and every modern runtime use. Non-finite inputs are rejected with a clear invalid_input error: NaN, Infinity, booleans, empty strings and values that are not numeric at all never reach the computation.
Where cosine shows up in practice
Engineers reach for this endpoint when they want that single primitive without shipping a math library into a spreadsheet, a no-code automation or a serverless function. At $0.002 per request it costs less than the time to write the import line — and for interactive use, the identical computation runs free on this very page.
Technical questions
What does it cost?
$0.002 per request via the API. It is also free to run in your browser on this page — the same code executes both ways.
What happens with very large angles?
Any finite number is accepted. Cosine is periodic with period 2π, so large angles are handled exactly; only non-finite values such as Infinity or NaN are rejected with an invalid_input error.
How accurate is the result?
The cosine is computed in IEEE-754 double precision and rounded to twelve decimal places, so results are stable and reproducible across machines and between the browser widget and the API.