Deadweight loss calculator
Find the surplus a market distortion destroys with the triangle rule, half the price change times the quantity change: a price change of 2 and a quantity change of 10 give a deadweight loss of 10. Signs are ignored. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Price change
- 2
- Quantity change
- 10
- Abs price change
- 2
- Abs quantity change
- 10
- Deadweight loss
- 10
Deadweight loss is the surplus that vanishes when a tax, subsidy, price ceiling, price floor, quota, or other wedge moves a market away from the competitive quantity. For linear demand and supply the lost surplus is a triangle whose height is the change in price and whose base is the change in quantity, so the loss equals one half times the absolute price change times the absolute quantity change. Students, policy analysts, and pricing teams look up this Harberger triangle whenever they already know how far the distortion moved price and quantity and do not need to rebuild the full schedules. This deadweight loss calculator accepts those two changes, applies the triangle identity, and returns the loss amount.
What deadweight loss is and how a price change and a quantity change form a triangle
Deadweight loss, sometimes called excess burden or Harberger loss, is the net surplus that neither consumers nor producers nor the treasury capture after a market distortion. A per-unit tax drives a wedge between the price buyers pay and the price sellers receive; a subsidy does the reverse; a binding price ceiling or floor, a quota, or a monopoly markup all share the same geometry: quantity moves away from the competitive level and the last units that would have traded in a free market no longer do.
Those missing units are the ones whose marginal benefit exceeded marginal cost, so their disappearance is a real resource loss rather than a transfer. When inverse demand and inverse supply are locally linear, the lost surplus is a right triangle whose vertical leg is the absolute change in price caused by the wedge and whose horizontal leg is the absolute change in quantity. The area of that triangle is one half times the product of those two legs.
That is the identity this calculator applies: deadweight loss equals one half times the absolute price change times the absolute quantity change. The sign of each change does not matter for the area: a two-dollar tax that cuts quantity by ten and a two-dollar subsidy that expands quantity by ten produce the same ten-dollar triangle under linear schedules. Send the magnitudes you already measured or the signed deltas from a before-and-after table; the engine takes absolute values before multiplying.
If you only know the tax rate and an elasticity, first convert those into a price change and a quantity change, then call this tool. If you have full linear intercepts and slopes, recover both deltas from the undistorted and distorted equilibria and then send those deltas here. Numeric outputs use half-up rounding so goldens compare byte-for-byte across runtimes.
Zero is a valid input: a frozen price or a frozen quantity yields a deadweight loss of zero, which is the honest result when the distortion did not move that dimension of the market.
The two changes you enter and the result
Both may be positive, negative, or zero; the engine uses absolute values because a triangle area cannot be negative. Optional decimals is an integer from zero through twelve, default six, controlling half-up rounding on the absolute legs and on the loss. Example: a price change of two and a quantity change of ten returns a deadweight loss of ten.
A price change of negative four and a quantity change of twenty-five returns a deadweight loss of fifty, the same triangle as a four-unit price rise with a twenty-five-unit quantity drop. Pair the loss with your own incidence study if you need who pays the wedge. Failed validation does not consume balance, which keeps exploratory scripts cheap when developers intentionally send a non-finite price change to confirm the error path.
Where a deadweight loss calculator earns its keep
Principles and public-finance courses use a deadweight loss calculator so students can turn any pair of price and quantity changes into the textbook Harberger triangle without mixing the loss with the tax-revenue rectangle or forgetting the one-half factor. Exam generators and LMS plugins need a deterministic oracle that rejects a non-finite input instead of inventing not-a-number that a buggy grader might treat as success. Failed validation does not consume balance.
Use this capability when you already have the change in price and the change in quantity; if you only have linear intercepts and slopes and want competitive consumer plus producer surplus with no distortion, that is a different identity and does not belong in this triangle definition.
What you can do with it
Classroom Harberger-triangle checks
Let students enter the price wedge and the quantity change from a tax or subsidy diagram and verify the triangle area against textbook worked examples.
LMS and exam auto-grading
Mark deadweight-loss items with a deterministic oracle that rejects non-finite inputs and never drops the one-half factor or treats tax revenue as the loss.
Policy and pricing notebooks
Batch-convert estimated price and quantity deltas from tax, ceiling, floor, or quota scenarios into a comparable deadweight-loss column without spreadsheet formula drift.
FAQ
How is deadweight loss calculated from a price change and a quantity change?
A price change of 2 and a quantity change of 10 yield a loss of 10.
Does the sign of the price or quantity change matter?
No. Deadweight loss is a triangle area, so the engine uses absolute values. A subsidy that expands quantity and a tax that cuts quantity by the same amounts produce the same loss under linear schedules.
What happens if an input is not a finite number?
Missing values, empty strings, infinities, and NaN are not billed and never become a hollow not-a-number success.
Is this the same as total market surplus or tariff-quota equivalence?
No. Total surplus at competitive equilibrium is consumer plus producer surplus with no wedge. Tariff-quota tools recover equivalent instruments from full linear schedules.
What if I only know the tax rate and an elasticity?
Turn those into a price change and a quantity change first, then enter both here. If you have the full straight-line demand and supply, read both changes off the equilibria before and after the distortion.
Related tools
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/fin/deadweight-loss \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"price_change":2,"quantity_change":10}'const res = await fetch("https://api.kit.forhosting.com/fin/deadweight-loss", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"price_change": 2,
"quantity_change": 10
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/fin/deadweight-loss",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"price_change": 2,
"quantity_change": 10
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/fin/deadweight-loss", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"price_change":2,"quantity_change":10}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"price_change":2,"quantity_change":10}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/fin/deadweight-loss", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"price_change": 2,
"quantity_change": 10
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "fin.deadweight_loss",
"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.
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. |
Technical notes
A non-finite price change or quantity change fails with invalid_input instead of a hollow not-a-number.
What deadweight loss is and how a price change and a quantity change form a triangle
This endpoint does not estimate demand elasticities, fit supply curves, or simulate incidence shares.
Input contract, response shape, and error behaviour
POST a JSON body with two required finite numbers. price_change (aliases delta_p, dp, delta_price, price_delta, and change_in_price) is the change in price caused by the distortion, in the same currency units as the loss you want back. quantity_change (aliases delta_q, dq, delta_quantity, quantity_delta, and change_in_quantity) is the change in quantity in the market's own units. On success the body echoes the two signed inputs, then abs_price_change and abs_quantity_change as the triangle legs, deadweight_loss as one half times their product, and a formula string restating DWL equals one half times the absolute price change times the absolute quantity change. Missing fields, empty strings, booleans, non-numeric strings, NaN, and infinities fail with invalid_input naming the field and are not billed. Prefer plain JSON numbers over strings with currency symbols or thousand separators; numeric strings are accepted only when they match a strict finite number pattern without commas or labels. This calculator does not rebuild demand and supply from intercepts, does not split the triangle into consumer and producer pieces, and does not report tax revenue or subsidy outlays; those are transfers, not deadweight loss. Pricing is a fixed $0.002 per successful call with unit item.
Where a deadweight loss calculator earns its keep
Policy notebooks and consulting workbooks often tabulate tax, subsidy, ceiling, and quota scenarios from already-estimated deltas; pinning the arithmetic in a tiny parse API keeps spreadsheet drift out of the comparison column when someone later changes only the quantity change. Keep requests small, pin the rounded deadweight_loss field in tests, and you get reproducible welfare-loss numbers for homework, LMS plugins, and edge workers without standing up a full computable-general-equilibrium stack of your own.
Technical questions
What does the deadweight loss calculator cost?
The browser tool is free. API requests use prepaid KIT balance at $0.002 per successful call; invalid input is not billed.