ForHosting KIT · Math

Lagrange error bound calculator

Give a bound M on the derivative, the interpolation nodes and the point you care about, and get the largest error the polynomial can have there: nodes 0, 1 and 2 with M of 1, evaluated at 0.5, give at most 0.0625. Free in your browser.

  • Free
  • Runs in your browser
  • No sign-up
  • Your data stays on your device
Use it from WebAPIEmailTelegramApp soon
If you enter
Nodes
0, 1, 2
M
1
X
0.5
You get
N
3
Degree
2
Product
0.375
Factorial
6

Given a bound M on the n-th derivative of your function, the positions of the interpolation nodes, and the point where you evaluate, it returns the worst-case gap between the true function and the interpolating polynomial, computed with the classic remainder theorem. One call, one number, no numerical guessing — the bound is a closed form, so the result is exact arithmetic rather than an estimate produced by sampling.

What the error bound actually tells you

Interpolating a function through a set of nodes gives you a polynomial that matches the function exactly at those nodes, but says nothing by itself about the points in between. The Lagrange remainder theorem fills that gap: if the polynomial passes through n nodes and the absolute value of the n-th derivative of the function never exceeds M on the interval, then the true error at any point x is at most M divided by n factorial, multiplied by the product of the distances from x to each node.

You supply the derivative bound M, the node positions, and the evaluation point; you get back the maximum error the interpolation can possibly have there. That makes it a certificate, not a measurement — it holds even in the worst case, which is exactly what you need before trusting an interpolated value in a report, a control system, or a published figure.

How nodes and the evaluation point shape the bound

The product term is the part worth understanding, because it explains where interpolation is safe and where it is dangerous. Every node contributes one factor of the distance between your evaluation point and that node, so the bound collapses to zero exactly at the nodes — where the polynomial is exact by construction — and grows as you move away from the cluster.

Evaluating inside a tight, well-spread group of nodes keeps the product small; extrapolating beyond the outermost node makes every factor grow at once, and the bound explodes accordingly. The factorial in the denominator works in your favor: each additional node raises the degree by one and divides the bound by one more factor, which is why adding a well-placed node can improve accuracy dramatically.

Where it fits in a real workflow

The typical use is verification, not discovery. You already have a function, a set of sample points, and a reason to interpolate — a lookup table for a sensor, a smooth reconstruction of tabulated physical data, a cheap stand-in for an expensive computation. Before shipping the approximation, you bound its error and keep the number on record.

Engineers use it to prove a table-driven controller stays within tolerance; analysts use it to justify publishing interpolated figures; students use it to check homework against the theorem instead of hoping. The computation is deterministic closed-form arithmetic: no randomness, no sampling, no external calls, so the same input always produces the same bound.

Certify a lookup-table approximation

Prove that a sensor table interpolated with polynomials stays within the required tolerance between calibration points.

Decide how many nodes you need

Compare the bound for different node counts and placements before committing to a sampling budget for an expensive function.

Check numerical analysis homework

Verify by-hand applications of the Lagrange remainder theorem against an exact, deterministic reference implementation.

What exactly is the value M?

M is an upper bound on the absolute value of the n-th derivative of your function over the interval, where n is the number of nodes. For sin(x), for example, every derivative is bounded by 1.

Is the result the actual error?

No — it is the maximum possible error guaranteed by the remainder theorem. The true error is never larger, and is often much smaller.

Can I evaluate outside the nodes?

Yes, any finite evaluation point is accepted. Expect the bound to grow quickly when extrapolating, because every distance factor increases at once.

What happens with an empty node list?

At least one node is required to define the interpolation.

Is there a limit on the number of nodes?

Up to 170 nodes are accepted, since 171! exceeds double-precision range. In practice a handful of well-placed nodes is all the theorem needs.

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/lagrange-error-bound

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/lagrange-error-bound \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"nodes":[0,1,2],"m":1,"x":0.5}'
{
  "nodes": [
    0,
    1,
    2
  ],
  "m": 1,
  "x": 0.5
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "math.lagrange_error_bound",
  "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.

min_nodes1
max_nodes170
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.

The Lagrange error bound API answers the question every polynomial interpolation leaves open: how far off can the approximating polynomial actually be?

What the error bound actually tells you

This endpoint evaluates that expression directly.

How nodes and the evaluation point shape the bound

Use this endpoint to test that intuition quantitatively — move the point, add or remove nodes, and watch how the worst-case error responds before you commit to a node layout.

Where it fits in a real workflow

It runs on our global edge at $0.002 per request, and the identical code runs free in your browser on this page — you only pay when you automate it inside a pipeline.

What does it cost?

$0.002 per request. It is also free to run in your browser on this page — the same code runs in both places.

Read the full KIT documentation →