Tangent Line Calculator

Find the equation of the tangent line to f(x) at x = a, with the point, derivative, slope, steps, graph and linear approximation.

Supports x^n, sqrt(x), sin, cos, tan, asin, acos, atan, e^x, ln(x), log(x) (base 10), abs(x) and pi. Write 3x or 3*x.

The x-coordinate of the point, such as 3, −1/2 or pi/4.

Examples

Tangent line to f(x) = x² at x = 3

y = 6x − 9

Exact result

Point of tangency
x₁ = 3
y₁ = f(3) = 9
(3, 9)
Derivative
f′(x) = 2x
Slope m = f′(3)
m = 6
Point-slope form y − y₁ = m(x − x₁)
y − 9 = 6(x − 3)
Slope-intercept form y = mx + b
y = 6x − 9

Step-by-Step Solution

Given: f(x) = x², at x = 3

  1. Step 1 — Find the point on the curve

    Substitute x = 3 into f(x) to get the y-coordinate of the point of tangency.

    f(3) = 3² = 9

    Point: (3, 9)

  2. Step 2 — Find the derivative

    The derivative gives the slope of the curve at every x. Rules used: Power Rule.

    f′(x) = 2x

  3. Step 3 — Find the slope at x = 3

    The slope of the tangent line is the derivative evaluated at the point: m = f′(a).

    f′(3) = 2 · 3 = 6

    m = 6

  4. Step 4 — Use the point-slope form

    Substitute the point (x₁, y₁) = (3, 9) and the slope m = 6 into y − y₁ = m(x − x₁).

    y − y₁ = m(x − x₁)

    y − 9 = 6(x − 3)

  5. Step 5 — Simplify to slope-intercept form

    Expand the bracket and move 9 to the right-hand side.

    y − 9 = 6x − 18

    y = 6x − 9

Final answer: y = 6x − 9

Graph of f(x) and the tangent line

Graph of f(x) and its tangent lineGraph of f(x) = x² for x from 0 to 6, with the point of tangency (3, 9) marked and the tangent line y = 6x − 9.123456510152025
  • f(x)
  • Tangent: y = 6x − 9
  • Point (3, 9)

The graph illustrates the result; the equation above comes from the exact calculation.

Linear approximation

Near x = 3, the tangent line is the best straight-line approximation of f(x). Written as a function it is the linearization:

L(x) = f(a) + f′(a)(x − a)
L(x) = 9 + 6(x − 3)

This is the same line as the tangent. The approximation is very accurate close to x = 3 and gets worse farther away.

L(31/10) = 48/5 ≈ 9.6f(31/10) = 961/100 ≈ 9.61Error |f(x) − L(x)| ≈ 0.01

See every differentiation rule worked out in the Derivative Calculator; the derivative itself is defined as a limit, which you can explore with the Limit Calculator. For the area under the curve, use the Integral Calculator. To check where f(x) is defined before choosing a point, try the Function Domain Calculator and the Function Range Calculator, or evaluate values quickly with the Scientific Calculator.

This tangent line calculator finds the equation of the tangent line to a curve y = f(x) at x = a. It evaluates f(a) to get the point of tangency, differentiates f(x) symbolically, evaluates f′(a) to get the slope, and writes the line in point-slope form and slope-intercept form, showing each step.

It keeps answers exact, recognises horizontal and vertical tangents, explains when no tangent exists, draws the curve with its tangent line, and turns the tangent into a linear approximation you can use to estimate f(x) near the point.

Worked Calculation Examples

ScenarioResultCalculation Step
f(x) = x² at x = 3y = 6x − 9f(3) = 9, so the point is (3, 9). f′(x) = 2x, so m = f′(3) = 6. y − 9 = 6(x − 3), which simplifies to y = 6x − 9.
f(x) = x³ − 2x at x = 1y = x − 2f(1) = 1 − 2 = −1, so the point is (1, −1). f′(x) = 3x² − 2, so m = f′(1) = 1. y + 1 = x − 1, which simplifies to y = x − 2.
f(x) = sin(x) at x = 0y = xf(0) = sin(0) = 0, so the point is (0, 0). f′(x) = cos(x), so m = cos(0) = 1. The tangent is y − 0 = 1(x − 0), or y = x.
f(x) = eˣ at x = 1y = exf(1) = e, so the point is (1, e). f′(x) = eˣ, so m = e. y − e = e(x − 1), which simplifies to y = ex.
f(x) = √x at x = 4y = (1/4)x + 1f(4) = 2, so the point is (4, 2). f′(x) = 1/(2√x), so m = 1/(2·2) = 1/4. y − 2 = (1/4)(x − 4), which simplifies to y = (1/4)x + 1.
f(x) = 1/x at x = 2y = (−1/4)x + 1f(2) = 1/2, so the point is (2, 1/2). f′(x) = −1/x², so m = −1/4. y − 1/2 = (−1/4)(x − 2), which simplifies to y = (−1/4)x + 1.

What Is a Tangent Line?

A tangent line to a curve at a point is the straight line that touches the curve there and points in the same direction as the curve at that instant. If you zoom in far enough on a smooth curve, it becomes almost indistinguishable from its tangent line.

The tangent line to y = x² at x = 3 passes through (3, 9) with slope 6, so its equation is y = 6x − 9.

How to Find a Tangent Line

1. Evaluate f(a) to find the point of tangency (a, f(a)).

2. Differentiate to find f′(x).

3. Evaluate f′(a); this is the slope m.

4. Substitute into y − y₁ = m(x − x₁), then simplify to y = mx + b if you need slope-intercept form.

For f(x) = x³ − 2x at x = 1: f(1) = −1, f′(x) = 3x² − 2, f′(1) = 1, so y + 1 = 1(x − 1), which simplifies to y = x − 2.

Tangent Line Formula

y − y₁ = m(x − x₁), with x₁ = a, y₁ = f(a) and m = f′(a). Together: y − f(a) = f′(a)(x − a).

Solved for y, this is y = f(a) + f′(a)(x − a), which is also the formula for the linear approximation L(x).

How the Derivative Gives the Slope

The slope of a secant line through (a, f(a)) and (a + h, f(a + h)) is [f(a + h) − f(a)]/h. As h → 0, the second point slides along the curve toward the first, and the secant turns into the tangent. The limit of those slopes is the derivative: f′(a) = lim(h→0) [f(a + h) − f(a)]/h.

So the derivative is exactly the slope of the tangent line: for f(x) = x², f′(x) = 2x, and the tangent at x = 3 has slope f′(3) = 6.

How to Find the Point of Tangency

The point of tangency is on the curve, so its y-coordinate is the function value: y₁ = f(a). A common mistake is to use f′(a) as the y-coordinate. f′(a) is the slope, not a height.

For f(x) = √x at x = 4, the point is (4, √4) = (4, 2), while the slope is f′(4) = 1/(2√4) = 1/4.

Point-Slope Form

A line through (x₁, y₁) with slope m can be written y − y₁ = m(x − x₁). It is the natural form for tangent lines because the calculation already gives a point and a slope.

To convert to slope-intercept form, expand and solve for y. For y − 9 = 6(x − 3): y − 9 = 6x − 18, so y = 6x − 9. Both equations describe the same line.

Tangent Line Examples

f(x) = sin(x) at x = 0: the point is (0, 0), f′(x) = cos(x) and f′(0) = 1, so the tangent is y = x.

f(x) = eˣ at x = 1: the point is (1, e), f′(x) = eˣ and the slope is e, so y − e = e(x − 1), which simplifies to y = ex.

f(x) = √x at x = 4: the point is (4, 2), f′(x) = 1/(2√x) and the slope is 1/4, so y − 2 = (1/4)(x − 4), or y = (1/4)x + 1.

f(x) = 1/x at x = 2: the point is (2, 1/2), f′(x) = −1/x² and the slope is −1/4, so y = (−1/4)x + 1.

Tangent Line vs Secant Line

A secant line passes through two points on a curve, and its slope is the average rate of change between them. A tangent line uses a single point, and its slope is the instantaneous rate of change there, given by the derivative.

As the two points of a secant move together, the secant approaches the tangent line. That limiting process is how the derivative is defined.

Horizontal and Vertical Tangents

A horizontal tangent occurs where f′(a) = 0. The line is y = f(a). For f(x) = x² − 4x + 1 at x = 2, f′(2) = 0 and the tangent is y = −3. Horizontal tangents mark possible maximums and minimums.

A vertical tangent occurs where the slope grows without bound, as for f(x) = ∛x at x = 0. Its equation is x = a; it has no slope and cannot be written as y = mx + b.

At a corner, such as |x| at x = 0, the slopes from the left and right differ, and there is no tangent line at all.

Tangent Lines and Linear Approximation

Near x = a, a differentiable function is close to its tangent line. Written as a function, the tangent line is the linearization L(x) = f(a) + f′(a)(x − a), and f(x) ≈ L(x) for x near a.

For example, with f(x) = √x at a = 4, L(x) = 2 + (1/4)(x − 4), so √4.1 ≈ 2 + 0.025 = 2.025. The true value is about 2.02485. The approximation is best close to a and gets worse farther away.

Applications of Tangent Lines

Tangent lines give instantaneous rates of change: the tangent to a position–time graph gives velocity, and the tangent to a cost curve gives marginal cost. They are the basis of linear approximation and of Newton's method for solving equations, which follows tangent lines to the x-axis. They also help locate maximums and minimums, where the tangent is horizontal.

How to Use the Tangent Line Calculator

  1. Type the function f(x), for example x^2 + 3x - 2, sin(x), e^x, ln(x), sqrt(x) or 1/x. Use ^ for powers and put function arguments in parentheses.
  2. Enter the x-value of the point, such as 3, −1/2, 0.5 or pi/4, and press Calculate, or tap one of the examples.
  3. Read the point of tangency (a, f(a)), the derivative f′(x), and the slope m = f′(a). Exact values such as 1/4, √2 or e are kept exact, with decimals alongside.
  4. Use the tangent line in point-slope form y − y₁ = m(x − x₁) or slope-intercept form y = mx + b. Horizontal tangents (m = 0), vertical tangents (x = a) and points with no tangent are identified and explained.
  5. Follow the step-by-step solution and the graph, then use the linear approximation box to estimate f(x) near the point with L(x) = f(a) + f′(a)(x − a).

Frequently Asked Questions

What is a tangent line?

A straight line that touches a curve at a point and has the same slope as the curve there. Near that point, the curve and its tangent line are almost identical.

How do you find the equation of a tangent line?

Find the point (a, f(a)), find the derivative f′(x), evaluate the slope m = f′(a), and substitute into y − f(a) = m(x − a). Simplify to y = mx + b if needed.

What is the tangent line formula?

y − f(a) = f′(a)(x − a). It is the point-slope form y − y₁ = m(x − x₁) with the point (a, f(a)) and slope m = f′(a).

How does the derivative find the tangent line?

The derivative f′(a) is the limit of secant slopes [f(a + h) − f(a)]/h as h → 0, which is exactly the slope of the tangent line at x = a. Together with the point (a, f(a)), that slope determines the line.

How do you find the slope of a tangent line?

Differentiate the function and substitute x = a into the derivative. For f(x) = x² at x = 3, f′(x) = 2x, so the slope is f′(3) = 6.

How do you find the point of tangency?

Substitute x = a into the original function f(x), not into the derivative. The point is (a, f(a)); for f(x) = x² at x = 3 it is (3, 9).

What is the difference between a tangent line and a secant line?

A secant line passes through two points on a curve and has the average rate of change as its slope. A tangent line touches the curve at one point and has the instantaneous rate of change, the derivative, as its slope.

Can a tangent line be horizontal?

Yes. When f′(a) = 0 the tangent is horizontal, with equation y = f(a). This happens at the vertex of a parabola and at other local maximums and minimums.

Can a tangent line be vertical?

Yes. If the slope grows without bound as x approaches a, as for ∛x at x = 0, the tangent is the vertical line x = a. It has an undefined slope and cannot be written as y = mx + b.

What happens if the derivative is undefined?

Then an ordinary tangent line with a slope does not exist at that point. If the slope tends to ±∞ from both sides there is a vertical tangent; if the left and right slopes differ (a corner, like |x| at 0) or go to opposite infinities (a cusp), there is no tangent line.

What is linear approximation?

Using the tangent line to estimate function values near a point: f(x) ≈ L(x) = f(a) + f′(a)(x − a). For example, √4.1 ≈ 2 + (1/4)(0.1) = 2.025.

How do I calculate a tangent line from a function?

Type the function and the x-value into the calculator above and press Calculate. It shows f(a), f′(x), the slope f′(a), the point-slope and slope-intercept equations, each step of the working, and a graph of the curve with its tangent line.

Last updated: September 27, 2026.