acalculator

What is the linear approximation of f?

Type a function, the centre a, and (if you like) a nearby x. The page gives the linear approximation L(x) = f(a) + f′(a)(x − a) and compares its estimate with f(x).

Your numbers

Use x, + - * / ^, brackets, pi, e, sqrt, ln, sin, cos, tan.
L(x) =
x/6 + 3/2

The linear approximation of sqrt(x) at x = 9 is L(x) = x/6 + 3/2.

Estimate L(x)
3.016666667
Exact f(x)
3.016620626

L(x) =: x/6 + 3/2. The linear approximation of sqrt(x) at x = 9 is L(x) = x/6 + 3/2.

The curve y = f(x), with the point x = a

How to calculate

Finds the linearization L(x) of f at x = a and uses it to estimate f at a nearby x, checked numerically.

Example with the default inputs (Function f(x) sqrt(x), Centre a 9, Estimate f at x = (optional) 9.1): The linear approximation of sqrt(x) at x = 9 is L(x) = x/6 + 3/2.

Method: L(x) = 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.

Machine-readable copies: Markdown, JSON.

Worked examples

Each example is checked against the calculator on every build.

  1. Function f(x) sqrt(x), Centre a 9, Estimate f at x = (optional) 9.1 gives L(x) = x/6 + 3/2, Estimate L(x) 3.016667, Exact f(x) 3.016621.Source: OpenStax, Calculus Volume 1, section 4.2 Linear Approximations and Differentials, Example 4.5. https://openstax.org/books/calculus-volume-1/pages/4-2-linear-approximations-and-differentials
  2. Function f(x) sin(x), Centre a pi/3, Estimate f at x = (optional) 31pi/90 gives L(x) = sqrt(3)/2 - π/6 + x/2, Estimate L(x) 0.883479, Exact f(x) 0.882948.

How it works

The linear approximation calculator finds the linearization of f at x = a:

L(x) = f(a) + f′(a)(x − a)

This is the tangent line to y = f(x) at a, the Taylor polynomial of order 1. A computer algebra system (nerdamer, open source) finds it with exact numbers and writes it expanded; the algebra runs in the background after you start typing.

The page shows:

  • L(x) = the linearization, expanded, exactly (for example x/6 + 3/2).
  • Estimate L(x): L at the x you typed under "Estimate f at x", as a decimal to 10 significant figures: f(a) + f′(a)(x − a), worked out with the decimal values of f(a) and f′(a).
  • Exact f(x): f at that x, to compare: the algebra's exact value of f at the typed x when it agrees with f(x) in decimals (to 10⁻¹² × (|f(x)| + s)), else f(x) in decimals. It is shown when it is a real number and holds its 10 figures: the algebra's text is 0 (ln(x) at 1), or rounding x to a computer number, or rounding inside f, cannot move its 10th figure: s × 2.2 × 10⁻¹⁶ under 5 × 10⁻¹¹ × |f(x)|, where s = |x f′(x)| is read from f at x(1 ± 10⁻⁷). For ln(x) at x = 1.0000000005 it is left out, as rounding x changes ln x in its 8th figure.

With the estimate field empty, only L(x) is shown.

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 not, the page says the slopes of f just left and right of a differ (a corner, a jump, a vertical tangent, or a curve that bends too sharply for h). The derivative the algebra uses is compared with a numeric difference quotient at 20 points (to 1 part in a million), and f(a) and f′(a) with the checked derivative at a. The slope of L, read as (L(10⁸) − L(−10⁸))/(2 · 10⁸), or as (L(1) − L(−1))/2 when that is past the largest computer number, must agree with the average of the two quotients to 10⁻⁵ × max(1, |f′(a)|), plus 10⁻¹⁵ × |f(a)|/h for rounding. The estimate uses f(a) worked out exactly by the algebra when that agrees with f(a) in decimals to 10⁻¹² × (|f(a)| + |f′(a) a|). A slope below 2⁻¹⁰²² (about 2.2 × 10⁻³⁰⁸, the smallest normal computer number), or 0 while the line has an x term, gives no answer. If any check fails, the algebra finds no formula, or the work takes over 3 seconds, the page 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 centre a and the x to estimate are numbers or constant expressions: 9, 9.1, pi/3, 31pi/90.

How answers are written

  • L(x) is written expanded, in the syntax you type, with exact numbers; the terms can come in any order (sqrt(3)/2 − π/6 + x/2). 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 estimate and f(x) 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 (a corner, jump or vertical tangent).
  • A step that fails its check, finds no formula, or takes over 3 seconds.
  • A value to estimate that is not a number gives a message next to that field.

The chart

The chart draws y = f(x) from x = a − 3 to a + 3, with the point (a, f(a)) marked.

Worked examples by hand

√x at a = 9, estimating √9.1 (OpenStax Calculus Volume 1, section 4.2, Example 4.5). f(9) = 3 and f′(x) = 1/(2√x), so f′(9) = 1/6. L(x) = 3 + (x − 9)/6 = x/6 + 3/2. The estimate is L(9.1) = 3 + 0.1/6 = 3.016666667; √9.1 = 3.016620626.

sin(x) at a = π/3, estimating sin 62° (OpenStax Calculus Volume 1, section 4.2, Example 4.6). sin(π/3) = √3/2 and cos(π/3) = 1/2, so L(x) = √3/2 + (x − π/3)/2 = sqrt(3)/2 − π/6 + x/2. 62° is 31π/90 radians, so the estimate is L(31π/90) = √3/2 + π/180 = 0.8834786963; sin(31π/90) = 0.8829475929.

Other questions people ask

What is a linear approximation?

The linear approximation, or linearization, of f at x = a is L(x) = f(a) + f′(a)(x − a): the tangent line at a, used in place of the curve. For x close to a, f(x) ≈ L(x), and L is much easier to work out than f.

How do I estimate √9.1 with a linear approximation?

Take f(x) = √x and a = 9, where √9 = 3 is easy. f′(x) = 1/(2√x), so f′(9) = 1/6. Then L(x) = 3 + (x − 9)/6 and √9.1 ≈ L(9.1) = 3 + 0.1/6 = 3.0166667. The true value is 3.0166206, so the estimate is off by about 0.00005.

How accurate is the estimate?

It is best close to a and gets worse further away. For a function with a second derivative, the error f(x) − L(x) is about f″(a)(x − a)²/2, so halving the distance to a cuts the error to about a quarter. The page shows f(x) beside L(x) so you can see the error.

What is the difference between a linear approximation and a differential?

They are the same idea. The differential dy = f′(a) dx is the change in L when x changes by dx, while the true change is Δy = f(a + dx) − f(a). So f(a + dx) ≈ f(a) + dy = L(a + dx).

Why is the estimate not shown for some x?

The estimate L(x) is shown for any number you type, but the exact value f(x) is left out where f is not a real number, such as √x for x below 0, and where rounding x to a computer number could change its 10th figure, such as ln(x) at 1.0000000005. The line L(x) itself needs f to have a derivative at a.

How is the answer checked?

The line comes from a computer algebra system; each derivative it uses is compared with a numeric difference quotient at 20 points, and the slope with the slope of f just left and right of a. If a check fails the page says "No verified answer".