What is the tangent line at a point?
Type a function of x and the point a. The page gives the tangent line y = mx + b at (a, f(a)), with its slope m = f′(a), and draws the curve with the point marked.
- Tangent line y =
- 6x - 9
The tangent line to x^2 at x = 3 is y = 6x - 9.
- Slope f′(a)
- 6
- Point f(a)
- 9
Tangent line y =: 6x - 9. The tangent line to x^2 at x = 3 is y = 6x - 9.
The curve y = f(x), with the point x = a
How to calculate
Finds the equation of the tangent line to y = f(x) at x = a, with its slope, checked numerically.
Example with the default inputs (Function f(x) x^2, At x = a 3): The tangent line to x^2 at x = 3 is y = 6x - 9.
Method: y = f(a) + f′(a)(x − a). A computer algebra system finds f′(a); it is shown only when f′ matches a difference quotient at 20 points and at a.
- The variable is x; angles are in radians; ln is the natural logarithm.
- An answer that fails its check is not shown.
Worked examples
Each example is checked against the calculator on every build.
- Function f(x) x^2, At x = a 3 gives Tangent line y = 6x - 9, Slope f′(a) 6, Point f(a) 9.Source: OpenStax, Calculus Volume 1, section 3.1 Defining the Derivative, Example 3.1. https://openstax.org/books/calculus-volume-1/pages/3-1-defining-the-derivative
- Function f(x) 1/x, At x = a 2 gives Tangent line y = 1 - x/4, Slope f′(a) -0.25, Point f(a) 0.5.
How it works
The tangent line calculator finds the line that touches y = f(x) at x = a:
y = f(a) + f′(a)(x − a)
It is the Taylor polynomial of f of order 1 about a. A computer algebra system (nerdamer, open source) finds it with exact numbers and writes it expanded, as mx + b; the algebra runs in the background after you start typing.
The page shows three things:
- Tangent line y = the expanded line, exactly (for example 6x − 9, or x cos(1) − cos(1) + sin(1) for sin(x) at 1).
- Slope f′(a): the slope m, as a decimal to 10 significant figures.
- Point f(a): the y value of the point of tangency (a, f(a)), as a decimal to 10 significant figures (left out in the case step 6 names).
Every answer is checked before it is shown.
- f must be a real number at a. F(a) that is not a number, or is ±∞ while f is a number just beside a (at a ± 10⁻⁶ × max(1, |a|): ln(x) or 1/x at 0), means f is not defined at x = a; ±∞ on both sides as well means f(a) is past the largest computer number, about 1.8 × 10³⁰⁸ (e^x at 710), and the page says f(a) is too large.
- The one-sided difference quotients (f(a + h) − f(a))/h and (f(a) − f(a − h))/h, with h = 10⁻⁶ × max(1, |a|), must agree to 1 part in 1,000 of max(1, |right quotient|), plus 10⁻¹⁵ × |f(a)|/h for rounding. If they do not, the page says the slopes of f just left and right of a differ. That happens at a corner, a jump or a vertical tangent, and also where h is too wide for the curve (sin(x) at 10⁶, x^(4/3) at 0): the page does not claim f has no derivative.
- The derivative the algebra uses is compared with a numeric difference quotient at 20 points (to 1 part in a million), and the coefficients f(a) and f′(a) with the checked derivative at a.
- The slope m of the line L, read as (L(10⁸) − L(−10⁸))/(2 · 10⁸), or as (L(1) − L(−1))/2 when that is past the largest computer number (e^x at 700), must agree with the average of the two quotients in step 2 to 10⁻⁵ × max(1, |m|), plus 10⁻¹⁵ × |f(a)|/h for rounding.
- A slope below the smallest normal computer number, 2⁻¹⁰²² (about 2.2 × 10⁻³⁰⁸), or a slope of 0 when the line still has an x term, has lost its digits (e^x at −800): the page gives no answer. x e^(−x) at 700 has slope about −6.9 × 10⁻³⁰², which is shown.
- Point f(a) is L(a) worked out exactly by the algebra, when that value agrees with f(a) in decimals to 10⁻¹² × (|f(a)| + |f′(a) a|). It is shown when the algebra's text is 0 (cos(2x) at π/4 gives 0, not the 6.1 × 10⁻¹⁷ that π rounded to a computer number gives), or when rounding a to a computer number cannot move its 10th figure: |f′(a) a| × 2.2 × 10⁻¹⁶ under 5 × 10⁻¹¹ × |f(a)|. Otherwise the point is left out (x³ − 2x at √2).
If any check fails, the algebra finds no formula, or the work takes over 3 seconds, the page says "No verified answer" (or why not) and shows no line.
What you can type
- A number has at most 15 digits in a row. A computer number keeps only about 16 digits, so a longer one (9007199254740993) would stand for a nearby number (9007199254740992), and the page asks for fewer digits instead. Write very large or very small numbers with a power of ten (1e-20).
- The function f uses the variable x. Numbers can have decimals (2.5) and powers of ten (1e-3).
- Operations: + − * / and ^ for powers. Brackets group. A number or bracket next to a letter multiplies: 2x, 3(x + 1), x sin(x).
- Constants: pi (or π) and e.
- Functions: sqrt, cbrt, ln (and log, the same natural logarithm), log10, exp, abs (or |x|), sin, cos, tan, sec, csc, cot, asin, acos, atan (arcsin, arccos, arctan also work), sinh, cosh, tanh and their inverses. Angles are in radians. sin x without brackets means sin(x); sin x^2 means sin(x²).
- The point a is a number or a constant expression: 3, −1.5, pi/4, e.
How answers are written
- The line is written expanded, in the syntax you type: ^ for powers, a number or a space before a letter for multiplication, π for pi, ln for the natural logarithm. The terms can come in any order (1 − x/4 is the line −x/4 + 1), and like terms that hold π or e may stay apart (3x π^2 − 2 π^3 − 2x).
- Numbers in the line are exact: fractions such as 1/6, and values such as sqrt(3)/2, e^20 or cos(1). A line that would hold a number the algebra could only give rounded (a whole number past 2⁵³; a fraction p/q, p and q being the numbers that multiply its top and its bottom, such as 288557167/(342919925e), when q after removing its factors 2 and 5 is over 1,000,000, or is over 1 while |p| times it is over 10¹²; or a decimal with more than 12 significant digits) is not shown: the page says "No verified answer".
- The slope and the point are decimals to 10 significant figures, rounded half up.
What gets no answer
- f not defined at a, f(a) too large, or slopes just left and right of a that differ (|x| or the cube root of x at 0).
- A step that fails its check, finds no formula, or takes over 3 seconds.
The chart
The chart draws y = f(x) from x = a − 3 to a + 3, with the point (a, f(a)) marked. Where f is not a real number the curve has a gap.
Worked examples by hand
f(x) = x² at x = 3 (OpenStax Calculus Volume 1, section 3.1, Example 3.1). f′(x) = 2x, so the slope is m = f′(3) = 6. The point is (3, f(3)) = (3, 9). The line is y = 9 + 6(x − 3) = 6x − 9.
f(x) = 1/x at x = 2 (OpenStax Calculus Volume 1, section 3.1, Example 3.3). f′(x) = −1/x², so m = f′(2) = −1/4. The point is (2, 1/2). The line is y = 1/2 − (x − 2)/4 = 1 − x/4, that is y = −x/4 + 1.
Other questions people ask
What is a tangent line?
The tangent line to y = f(x) at x = a is the line through the point (a, f(a)) with slope f′(a). Close to a it is the straight line that fits the curve best: zoom in on a smooth curve and it looks more and more like its tangent line.
How do I find the equation of the tangent line?
Find the slope m = f′(a) by differentiating f and putting in x = a. Find the point: y₀ = f(a). The line is y − y₀ = m(x − a), which you can rewrite as y = mx + (y₀ − ma). For f(x) = x² at x = 3: f′(x) = 2x, so m = 6; f(3) = 9; the line is y = 6(x − 3) + 9 = 6x − 9.
Why is there no tangent line at some points?
A tangent line needs a slope, and some curves have none at some points. |x| has a corner at 0: the slope is −1 on the left and 1 on the right. The page compares the slope just left and just right of a and gives no line when they differ. A curve like the cube root of x has a vertical tangent at 0, where the slope is infinite; the page gives no line there either.
What is the difference between a tangent line and a secant line?
A secant line crosses the curve at two points, (a, f(a)) and (b, f(b)), and its slope is (f(b) − f(a))/(b − a). As b moves towards a, the secant line turns into the tangent line and its slope into the derivative f′(a).
Can the tangent line cross the curve?
Yes. The tangent line touches the curve at a but may cross it elsewhere, and even at a itself: the tangent to x³ at 0 is y = 0, the x-axis, which the curve crosses there. Near an inflection point the curve passes from one side of its tangent line to the other.
How is the answer checked?
A computer algebra system finds the line; each derivative it uses is compared with a numeric difference quotient at 20 points, and each coefficient with the derivative at a. The page then compares the slope with the slope of f just left and right of a. If any check fails, it says "No verified answer" instead of showing the line.