ForHosting KIT · Finance & money

Consumer surplus linear demand calculator

If the most buyers would pay is 100 and that falls by 2 per unit, a market price of 40 means 30 units are bought and consumer surplus is 900. Enter your demand line and price to get both numbers. 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
Demand intercept
100
Demand slope
-2
Market price
40
You get
Demand equation
P=100-2Q
Quantity
30
Consumer surplus
900

Consumer surplus is the extra value buyers receive when they pay less than they would have been willing to pay. With a linear demand curve that surplus is a right triangle sitting between the inverse demand line and the horizontal market price, from quantity zero out to the units actually purchased. This consumer surplus calculator takes the intercept and slope of inverse demand P equals a plus b times Q together with the market price, solves for the quantity on that line, and returns the triangular area one half times quantity times the gap between the choke price and the market price. Students use it to check homework graphs; tutoring platforms and problem banks use it as a deterministic oracle.

Linear inverse demand and the surplus triangle

Write inverse demand as price P equals a plus b times quantity Q. The slope b must be negative so the demand curve slopes down; each extra unit is valued less than the one before it. At a posted market price P star, buyers purchase the quantity that sits on that line, Q star equals P star minus a, all divided by b.

Graphically the first units are valued near a and the last unit is valued at P star, so the net gain to consumers is the area between the demand line and the price, from Q equals zero to Q star. Because both edges are straight, that area is a right triangle whose height is a minus P star and whose base is Q star. The area formula is therefore one half times Q star times a minus P star, which is the consumer surplus.

Textbooks that write P equals alpha minus beta Q with beta positive are using the same line: set a equal to alpha and b equal to minus beta. Textbooks that start from Q equals alpha minus beta P should invert first: the choke price is alpha over beta and the inverse slope is minus one over beta.

Coursework, tutoring, and lightweight welfare notebooks

Principles of economics courses assign linear consumer-surplus problems because the triangle is easy to grade and matches the graphs drawn in class. Tutoring platforms and LMS plugins need a deterministic oracle that returns Q star and CS for arbitrary intercepts, slopes, and prices without student-side spreadsheet drift. Product and policy notebooks that sketch a simple linear market before a full simulation can pin the same analytic triangle in tests.

Use the one-hundred minus two Q example to lock a key of nine hundred, then scale intercepts for problem generators. Pin the rounded fields in automated tests, reject a non-negative slope and a non-positive quantity explicitly, and you get reproducible consumer-surplus figures for homework, exam generators, and lightweight welfare notebooks without standing up a numerical integrator. The calculator does not need a supply curve: it measures buyers' gain at a given price on a given linear demand line, which is exactly the triangle most problem sets ask for.

Homework and exam surplus checks

Students enter inverse-demand intercept and slope plus the market price and verify the triangle area against textbook solutions without graphing by hand.

Problem banks and welfare notebooks

Generate or validate linear inverse-demand schedules for coursework seeds and pin expected quantity and consumer surplus in continuous integration.

What is the formula for consumer surplus with linear demand?

Write inverse demand as P = a + b·Q with b < 0. At market price P, quantity is Q = (P − a)/b and consumer surplus is the triangle CS = ½·Q·(a − P).

What surplus does a top price of 100, dropping 2 per unit, give at a market price of 40?

Buyers purchase 30 units, and consumer surplus is 900: half of 30 times the gap of 60 between the top price of 100 and the market price of 40.

Why must the slope be negative?

Demand slopes down: each extra unit is worth a little less to buyers than the one before. A zero or positive slope would not describe a normal demand curve, so the calculator asks for a negative value.

My textbook writes quantity as a function of price. What do I do?

Invert it first. If quantity is α minus β times price, the top price is α divided by β and the slope is minus one divided by β. Enter those two numbers and the result matches the textbook.

Why must the market price be below the top price?

The top price is the most anyone would pay. At or above it nobody buys, so there is no surplus triangle; the market price must also be zero or more.

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/econ/consumer-surplus-linear-demand

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/econ/consumer-surplus-linear-demand \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"demand_intercept":100,"demand_slope":-2,"market_price":40}'
{
  "demand_intercept": 100,
  "demand_slope": -2,
  "market_price": 40
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "econ.consumer_surplus_linear_demand",
  "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.

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.

Successful API calls use prepaid KIT balance at $0.002 per item; invalid input is not billed.

Linear inverse demand and the surplus triangle

The intercept a is the choke price: the highest willingness to pay, read on the vertical axis when nobody buys. This endpoint keeps the signed inverse-demand slope explicit so you can paste coefficients from either notation after a single conversion, then read the triangle instead of sketching it by hand.

Inputs, closed form, validation, and the response

Classic check: a equals one hundred, b equals minus two, P equals forty yields Q star equals thirty and consumer surplus equals nine hundred, because one half times thirty times sixty is nine hundred. Another check: a equals fifty, b equals minus one, P equals twenty yields quantity thirty and surplus four hundred fifty. Send three finite numbers: demand_intercept a, demand_slope b, and market_price P. Fields may arrive as JSON numbers or numeric strings; missing, empty, or non-finite values fail with invalid_input naming the field. demand_slope must be strictly negative — a flat or upward inverse demand is not the downward line the triangle formula assumes, so the API rejects it instead of inventing an area. market_price must be non-negative and must lie strictly below the intercept; otherwise quantity on the line is zero or negative and there is no surplus triangle in the first quadrant. Failed validation is not billed; successful parse calls use the published $0.002 base price. Pair the numbers with your own plot if you need a sketch; this endpoint returns the area, not an image.

LMS and tutoring auto-grading

Score linear consumer-surplus items with a deterministic oracle that rejects a flat or upward demand slope and a non-positive quantity as invalid_input.

My textbook writes P = 80 − 2Q. How do I enter that?

Set demand_intercept to 80 and demand_slope to −2, then send the market price. The signed slope is already the coefficient of Q.

My textbook writes Q = 100 − 2P. How do I convert?

Invert to P = 50 − 0.5Q: demand_intercept is 100/2 = 50 and demand_slope is −1/2 = −0.5. Then send the same market price.

Why must demand_slope be negative?

Consumer surplus as a triangle above the price assumes downward-sloping inverse demand. A zero or positive slope is rejected as invalid_input rather than treated as an area.

What does the consumer surplus calculator cost?

The browser tool is free. API requests use prepaid KIT balance at $0.002 per successful call; invalid input is not billed.

Read the full KIT documentation →