Simpson's three-eighths rule calculator for definite integrals
This Simpson's three-eighths rule calculator approximates a definite integral from a function, two finite bounds, and a chosen number of equal subintervals.
Run — free
It applies the composite 3/8 weighting pattern across the interval and requires the subinterval count to be divisible by three. The result includes the approximation, step size, node count, and weighted sum, making it useful both for a quick answer and for checking a numerical integration exercise or implementation.
Enter the function and interval clearly
Write the integrand as an expression in x, then provide finite lower and upper bounds. Explicit multiplication is required, so enter 2*x rather than 2x. The expression parser supports ordinary arithmetic, parentheses, powers with the ^ symbol, the constants pi and e, and common one-argument functions including sin, cos, tan, exp, log, log10, sqrt, and abs. This focused syntax keeps the calculation deterministic and avoids executing arbitrary code. For example, x^3 + 2*x over the interval from zero to three is valid. Reversing the bounds is also valid and changes the sign of the approximation, just as it does for an exact definite integral. Every sampled function value must be finite. If the expression has a singularity, an invalid square root, division by zero, or another undefined value at one of the nodes, the calculator stops with a specific input error instead of returning a misleading numeric result. Check parentheses and multiplication signs carefully when adapting textbook notation.
Choose a subinterval count divisible by three
The composite Simpson three-eighths rule divides the integration interval into equal subintervals. Its basic panel spans three subintervals and four nodes, so the total number of subintervals must be a positive multiple of three: 3, 6, 9, and so on. If n is the subinterval count, the calculator uses n + 1 nodes, including both endpoints. It computes the uniform step size h = (b - a) / n and applies endpoint weights of one. Interior nodes whose indices are divisible by three receive weight two, while the remaining interior nodes receive weight three. The final weighted sum is multiplied by 3h/8. Increasing n often improves an approximation for a sufficiently smooth function, but it is not a universal guarantee when the function oscillates sharply, contains discontinuities, or behaves badly near the interval. Compare results at successively larger valid counts such as 6, 12, and 24 to assess practical stability rather than trusting extra digits automatically. The accepted maximum keeps execution bounded.
Interpret and verify the returned calculation
The primary output is approximation, the signed estimate of the definite integral. The response also reports step_size, subintervals, node_count, and weighted_sum so you can audit the setup or reproduce the final multiplication independently. Simpson's three-eighths rule is exact for polynomials through degree three when arithmetic is exact, which makes cubic examples especially useful as checks. For other smooth functions, its error depends on higher derivatives and the selected step size. A plausible-looking decimal does not prove that the function was entered correctly or that the mesh is fine enough. Confirm the interval orientation, examine whether the function remains finite and smooth throughout the interval, and repeat the calculation with a larger multiple of three. You can also compare against an antiderivative when one is available, or against a different numerical method. The API uses the same deterministic solver as the browser calculation and costs $0.002 per request, so automated checks and interactive work follow the same arithmetic contract.
What you can do with it
Check a numerical methods assignment
Compare a hand-built Simpson 3/8 table with the returned step size, node count, weighted sum, and approximation.
Estimate an integral without an elementary antiderivative
Evaluate a smooth expression numerically when symbolic integration is inconvenient or unavailable.
Test an integration routine
Use deterministic cubic and transcendental examples as regression values for scientific or engineering software.
FAQ
Why must the subinterval count be divisible by three?
Each Simpson three-eighths panel covers three equal subintervals. The composite rule therefore requires a whole number of those panels.
Is the node count also a multiple of three?
No. If there are n subintervals, there are n + 1 nodes because both endpoints are included. The subinterval count, not the node count, must be divisible by three.
Which function syntax is supported?
Use x, numeric constants, pi, e, parentheses, +, -, *, /, ^, and supported functions such as sin, cos, exp, log, sqrt, and abs. Multiplication must be explicit.
What happens if the function is undefined inside the interval?
If a sampled node produces a non-finite value, the request returns an input error naming that node. A singularity between nodes may still require your own mathematical review.
How much does an API calculation cost?
Each API request costs $0.002. The browser calculator runs the same deterministic logic.
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/simpson-three-eighths \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"expression":"x^3 + 2*x","lower_bound":0,"upper_bound":3,"subintervals":6}'const res = await fetch("https://api.kit.forhosting.com/calculus/simpson-three-eighths", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"expression": "x^3 + 2*x",
"lower_bound": 0,
"upper_bound": 3,
"subintervals": 6
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/calculus/simpson-three-eighths",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"expression": "x^3 + 2*x",
"lower_bound": 0,
"upper_bound": 3,
"subintervals": 6
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/calculus/simpson-three-eighths", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"expression":"x^3 + 2*x","lower_bound":0,"upper_bound":3,"subintervals":6}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"expression":"x^3 + 2*x","lower_bound":0,"upper_bound":3,"subintervals":6}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/calculus/simpson-three-eighths", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"expression": "x^3 + 2*x",
"lower_bound": 0,
"upper_bound": 3,
"subintervals": 6
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "calculus.simpson_three_eighths",
"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_items | 300000 |
max_chars | 500 |
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. |