ForHosting KIT · Developer Utilities

Optimal Consumption Calculator

This optimal consumption calculator checks the standard interior consumer-choice condition: the marginal rate of substitution between two goods should equal their price ratio.

● BetaFree · in your browser
Use it from WebAPIEmailTelegramApp soon

Enter each good's marginal utility and price, and the calculator reports both ratios, their relative gap, whether they match within your chosen tolerance, and which good the consumer should buy more of when they do not match. The result is a directional economic diagnosis, not a complete demand solution, because income, quantities, and the full utility function are not supplied.

What the MRS and price-ratio condition means

For two goods X and Y, the marginal rate of substitution used here is MUx divided by MUy. It describes how much marginal utility the consumer gains from X relative to Y at the current bundle. The market price ratio is Px divided by Py. It describes how many units of Y's price must be given up to pay for one unit of X. At an interior optimum, these two trade-offs align: MUx/MUy = Px/Py. The same condition can also be written as equal marginal utility per currency unit, MUx/Px = MUy/Py. When the ratios match, moving a small amount of spending from one good to the other does not improve utility at the margin. This calculator evaluates that equality with positive marginal utilities and positive prices. It does not assume that the submitted values are quantities, and it does not calculate a budget line. Instead, it focuses precisely on the local optimality test economists use after marginal utilities at a candidate bundle are known.

How to read the buy-more recommendation

If MRS is greater than Px/Py, good X provides more marginal utility relative to good Y than the market requires for X's relative cost. Equivalently, marginal utility per currency unit is higher for X. The direction of improvement is therefore to buy more X and less Y while keeping spending constrained. Under the usual assumption of diminishing marginal utility, that reallocation lowers MRS toward the price ratio. If MRS is below Px/Py, the reverse applies: Y currently offers the higher marginal return per currency unit, so the consumer should buy more Y and less X. The boolean output fields make this direction explicit, while the recommendation states it in a sentence. “Buy more” describes a marginal reallocation, not an unlimited purchase. As the bundle changes, marginal utilities generally change too, so the ratios should be recomputed. The endpoint never claims an exact new quantity because that would require the utility function, current quantities, income, and the budget constraint.

Tolerance, assumptions, and boundary solutions

Exact equality is uncommon when marginal utilities are estimated, surveyed, or rounded. The tolerance input therefore defines a relative band around the price ratio. Its default value of 0.01 treats a gap of up to one percent in either direction as a match. Set tolerance to zero when exact arithmetic equality is required, or increase it when the underlying marginal-utility estimates are noisy. The returned relative_gap is positive when MRS exceeds the price ratio and negative when it falls below; gap_percent expresses the same comparison in percentage points for easier reporting. This is an interior-optimum test and relies on differentiable preferences, positive prices, positive marginal utilities, and the ability to adjust both goods. A corner solution may be correct when one good is not consumed, preferences are not smooth, goods are indivisible, or constraints prevent marginal reallocation. The calculator also does not test whether the budget is exhausted or whether the candidate bundle is globally optimal. Use its result as a focused first-order condition check within a broader consumer-choice analysis.

Check an economics exercise

Verify whether stated marginal utilities and prices satisfy the interior optimum and identify the direction of reallocation when they do not.

Review a candidate consumption bundle

Turn marginal utility estimates at a proposed bundle into a clear comparison of private trade-offs and market trade-offs.

Automate sensitivity analysis

Call the API across alternative prices or marginal utilities and record how the recommended purchase direction changes.

What formula does the calculator use?

It computes MRS = MUx/MUy and the price ratio = Px/Py, then compares their relative difference.

Why should I buy more X when MRS is above the price ratio?

Because X then delivers more marginal utility per currency unit than Y. Reallocating spending toward X improves utility under the standard assumptions.

Does an equal ratio prove the bundle is optimal?

It confirms the interior first-order condition within tolerance. A complete proof may also require a binding budget, suitable preference curvature, and checks for corner solutions.

What does tolerance change?

It sets the maximum relative gap treated as equality. The default 0.01 accepts a difference of up to one percent.

Can marginal utility or price be zero?

No. Every marginal utility and price must be a finite number greater than zero so both ratios are economically meaningful and defined.

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/optimal-consumption-mrs-price-ratio

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/optimal-consumption-mrs-price-ratio \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"marginal_utility_good_x":12,"marginal_utility_good_y":6,"price_good_x":8,"price_good_y":4}'
{
  "marginal_utility_good_x": 12,
  "marginal_utility_good_y": 6,
  "price_good_x": 8,
  "price_good_y": 4
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "econ.optimal_consumption_mrs_price_ratio",
  "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.

Read the full KIT documentation →