Equation of tangent line calculator
The equation of tangent line calculator turns a polynomial and an x-coordinate into the line that touches the curve at that point.
Run — free
It evaluates the polynomial to find the contact point, differentiates it to obtain the instantaneous slope, and then calculates the vertical intercept. The result includes both slope-intercept form and point-slope form, so it is useful for checking calculus exercises, preparing worked examples, or adding a predictable symbolic-numeric step to an application.
Enter the polynomial and point clearly
Write the function as an ordinary polynomial in x, such as 3x^2 - 2x + 1, and provide the x-coordinate where the tangent is required. You may include spaces, an optional multiplication sign between a number and x, and either ^ or ** before a nonnegative integer exponent. A leading y= or f(x)= prefix is also accepted. Decimal coefficients and scientific notation are supported, which makes the calculator suitable for both textbook expressions and coefficients obtained from measurements. The expression must remain a polynomial: variables other than x, parentheses, division by x, roots, trigonometric functions, negative exponents, and fractional exponents are rejected instead of being interpreted approximately. This strict input contract prevents an unsupported expression from silently producing a plausible but incorrect line. The x-coordinate must be a finite number. After validation, like powers are combined automatically, so an expression such as x^2 + 2x^2 is treated as 3x^2 before the point and slope are calculated.
How the slope and intercept are derived
For a polynomial f(x), the tangent at x=a passes through the point (a, f(a)) and has slope f'(a). The calculator evaluates the polynomial and its first derivative together using a bounded form of Horner's method. This avoids constructing an expanded derivative string and gives a direct numeric result for both the y-coordinate and the slope. Once m=f'(a) is known, the tangent begins in point-slope form: y-f(a)=m(x-a). Rearranging that identity gives y=mx+b, where b=f(a)-ma. The returned slope and intercept are therefore linked to the displayed equation rather than being separate estimates. For example, a horizontal tangent has slope zero and is formatted simply as y=b. Coefficients are cleaned to stable numeric precision, including removal of negative zero, so equivalent computations produce consistent JSON. If the requested values overflow finite arithmetic, the input is rejected rather than returning Infinity or a damaged equation.
Read and verify the result
The result reports x and y for the point of tangency, slope for the derivative at that point, intercept for the constant term of the line, and equation for the copy-ready slope-intercept form. It also returns a point-slope equation, which preserves the substitution used in the derivation and can be easier to compare with handwritten work. A quick verification is to substitute the returned x into y=mx+b: the result should equal the returned y. You can also differentiate the original polynomial independently and evaluate that derivative at x; it should match slope. These two checks confirm the two defining properties of a tangent line at a regular polynomial point: the line passes through the curve and has the same instantaneous rate of change there. Browser use is free, while automated requests use the published $0.002 base price. Because the algorithm has no network access, randomness, stored state, or clock dependency, the same valid input produces the same structured result in every supported channel.
What you can do with it
Check a calculus exercise
Compare a handwritten derivative and tangent-line equation with a deterministic result that includes each essential value.
Prepare teaching examples
Generate point-slope and slope-intercept forms from selected polynomials without repeating routine arithmetic.
Automate polynomial analysis
Add a stable tangent calculation to educational software, reports, tests, or data-processing workflows.
FAQ
What input forms are accepted?
Use a polynomial in x with numeric coefficients and nonnegative integer powers, such as 4x^3 - 2x + 7. Optional spaces, multiplication signs, y=, and f(x)= are accepted.
How is the tangent slope calculated?
The slope is the first derivative of the polynomial evaluated at the supplied x-coordinate.
How is the y-intercept found?
After finding the point value f(a) and slope m, the calculator uses b=f(a)-ma.
Can the tangent line be horizontal?
Yes. When the derivative at the selected point is zero, the result is a horizontal line written as y equal to the intercept.
Does it support rational or trigonometric functions?
No. This capability intentionally accepts polynomials only and rejects division by a variable, roots, negative or fractional powers, and named functions.
What does an API request cost?
The base price is $0.002 per request. The same deterministic calculation is also available free in the 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/calculus/tangent-line-equation \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"polynomial":"3x^2 - 2x + 1","x":2}'const res = await fetch("https://api.kit.forhosting.com/calculus/tangent-line-equation", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"polynomial": "3x^2 - 2x + 1",
"x": 2
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/calculus/tangent-line-equation",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"polynomial": "3x^2 - 2x + 1",
"x": 2
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/calculus/tangent-line-equation", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"polynomial":"3x^2 - 2x + 1","x":2}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"polynomial":"3x^2 - 2x + 1","x":2}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/calculus/tangent-line-equation", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"polynomial": "3x^2 - 2x + 1",
"x": 2
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "calculus.tangent_line_equation",
"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.
Limits
max_chars | 2000 |
max_degree | 1000 |
max_terms | 1000 |
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. |