ForHosting KIT · Developer Utilities

Double-angle formula

The double-angle formula API evaluates the three classic double-angle identities of trigonometry — sine, cosine and tangent of 2x — from a single angle supplied in radians or degrees.

● BetaFree · in your browser
Use it from WebAPIEmailTelegramApp soon

You send the angle, pick the identity you need, and receive the exact computed value together with the formula that produced it. The identities applied are sin(2x) = 2 sin(x) cos(x), cos(2x) = cos²(x) − sin²(x), and tan(2x) = 2 tan(x) / (1 − tan²(x)). The computation is fully deterministic: no approximation tables, no external service, just the closed-form identity evaluated in double precision. It answers in one call what would otherwise mean reaching for a calculator, a CAS, or a spreadsheet, and it runs free in your browser on this page before you ever pay $0.002 per API request.

What the double-angle formulas actually say

The double-angle formulas rewrite the trigonometric functions of a doubled angle, 2x, purely in terms of functions of the original angle x. For sine, the identity is sin(2x) = 2 sin(x) cos(x), which follows directly from the angle-sum formula for sine with both addends equal. For cosine, the primary form is cos(2x) = cos²(x) − sin²(x), which is commonly rearranged into two equivalent variants, 1 − 2 sin²(x) and 2 cos²(x) − 1, by applying the Pythagorean identity. For tangent, the identity is tan(2x) = 2 tan(x) / (1 − tan²(x)), which holds wherever the denominator is nonzero. This capability takes one angle — expressed in radians by default, or in degrees when you say so — and evaluates exactly one of these three identities, returning the numeric value along with the formula used. The angle must be a finite number: NaN, infinities, strings that do not parse as numbers, and missing values are all rejected with a clear error rather than silently coerced, because a quiet coercion is exactly the kind of bug that corrupts a downstream calculation.

How the evaluation works and where the edge cases are

Internally, the angle you provide is first normalized to radians, because JavaScript's Math.sin, Math.cos and Math.tan all operate on radians; a degrees input is simply multiplied by π/180. Then the sine and cosine of the angle are computed once, and the requested identity is assembled from them. For sin(2x) and cos(2x) this is all there is to it: the identities are defined for every finite angle and the result is a stable floating-point number, lightly rounded to ten decimal places so that repeated calls on different machines produce byte-identical output. Tangent is different because it has a genuine domain restriction: tan(x) is undefined where cos(x) is zero, and tan(2x) is undefined wherever 1 − tan²(x) equals zero, which happens when 2x is an odd multiple of π/2. Rather than returning an enormous or infinite number that looks like a result, the capability detects these cases with an explicit check and returns a descriptive invalid-input error explaining that the tangent is undefined for that angle.

When a programmatic double-angle evaluation is useful

Most people meet the double-angle formulas in a calculus or physics course, but the programmatic version earns its place in automation. Signal-processing code that synthesizes or analyzes waveforms frequently needs sin(2x) and cos(2x) when working with harmonics; a robotics or graphics pipeline may need them when composing rotations; and a teaching platform may need a trusted, deterministic oracle to grade student answers against. Because the same code that answers API calls also runs free in the browser widget on this page, you can validate an expected value interactively and then bake the identical computation into a script, a CI check, or a homework system without any risk that the two environments disagree. Pricing is simple: $0.002 per request through the API, with no per-unit surcharge, and the browser version is free for interactive use. The capability keeps no state between calls, performs no network access, and stores nothing — the input angle goes in, the identity value comes out, and that is the entire transaction.

Check a trigonometry homework answer

Verify a computed sin(2x), cos(2x) or tan(2x) against a deterministic oracle instead of trusting a hand calculation.

Compute harmonic terms in signal code

Evaluate sin(2x) or cos(2x) for the second harmonic of a waveform from the fundamental angle, in radians or degrees.

Grade student submissions automatically

Feed the same angle through the API and compare the returned value to the student's answer within a tolerance.

What does it cost?

$0.002 per API request. The same computation is free in your browser on this page.

Which units does the angle accept?

Radians by default, or degrees when unit is set to degrees. Degrees inputs are converted to radians internally before the identity is evaluated.

Which identities are supported?

sin(2x) = 2 sin(x) cos(x), cos(2x) = cos²(x) − sin²(x), and tan(2x) = 2 tan(x) / (1 − tan²(x)), selected with the identity field.

What happens if the angle is not a number?

The request is rejected with an invalid-input error. NaN, infinities and unparsable strings are never silently coerced into a result.

What happens where tan(2x) is undefined?

You get a descriptive invalid-input error explaining that the tangent is undefined for that angle, instead of an infinite or misleading number.

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.

POSThttps://api.kit.forhosting.com/math/double-angle-formula

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.

curl -X POST https://api.kit.forhosting.com/math/double-angle-formula \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"angle":30}'
{
  "angle": 30
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "math.double_angle_formula",
  "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.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

Read the full KIT documentation →