Mediant of Two Fractions Calculator
The mediant of two fractions is formed by adding their numerators to make a new numerator and adding their denominators to make a new denominator.
Run — free
This calculator performs that exact operation without reducing or otherwise changing the result. Enter four integers representing the two fractions, and it returns the mediant as separate numerator and denominator values plus a readable fraction. It also rejects either input fraction when its denominator is zero.
How to calculate the mediant
Suppose the first fraction is a/b and the second is c/d. Their mediant is (a + c)/(b + d). Enter a as the first numerator, b as the first denominator, c as the second numerator, and d as the second denominator. The calculator adds across the numerators and denominators independently, then reports both sums and a formatted fraction. For example, the mediant of 1/3 and 2/5 is 3/8 because 1 + 2 equals 3 and 3 + 5 equals 8. This operation is different from ordinary fraction addition: adding 1/3 and 2/5 requires a common denominator and produces 11/15, while their mediant is 3/8. Keep that distinction in mind when choosing the operation. The output deliberately preserves the direct sums instead of simplifying them, because those sums are the definition of the mediant and often carry useful information about how the result was constructed. Negative numerators and denominators are accepted as long as each denominator is nonzero and every value is a safe integer.
What the result means
For two positive fractions with positive denominators, the mediant lies strictly between them when the fractions have different values. This makes the construction useful for finding a rational number inside an interval. The familiar Farey sequence and Stern–Brocot tree use mediants to organize rational numbers and generate increasingly precise bounds. The returned numerator and denominator are the literal component sums, not necessarily a fraction in lowest terms. If you enter 1/2 and 3/4, the result is 4/6 even though 4/6 has the same numerical value as 2/3. Preserving 4/6 matters when you are studying the mediant operation itself, tracing a tree path, or checking a hand calculation. Signs deserve care: the between-ness property assumes the conventional positive-denominator setting, while the arithmetic definition still works with signed inputs. Also note that the two input denominators may sum to zero. In that case the tool still returns the formal mediant with a zero denominator, because the stated invalid-input rule applies to either original denominator and the component-wise sum remains well defined as a formal fraction expression.
Validation and reliable API use
Each of the four fields must be supplied as an integer that JavaScript can represent exactly. Decimal values, numeric strings, missing values, infinities, and integers outside the safe range are rejected instead of being rounded or silently coerced. The first and second denominators are checked separately, and either one being zero produces an invalid-input error. After validation, the calculation uses only two additions, so the same request always produces the same JSON result and never depends on a network service, stored state, time, or randomness. API consumers receive the fields numerator, denominator, and fraction. The separate numeric fields are convenient for later computation, while the fraction string is ready for display or logging. Before sending large integer values, remember that even two individually safe integers can have a sum outside the safe range; such an overflow is rejected to protect exactness. Automated clients can call the capability for $0.002 per request, while interactive users can perform the same deterministic calculation in the browser. For reproducible workflows, store the original four inputs alongside the returned mediant so the construction can be audited later.
What you can do with it
Explore the Stern–Brocot tree
Generate the fraction between two neighboring bounds while tracing rational numbers through the tree.
Check a number theory exercise
Verify the component-wise numerator and denominator sums without confusing the mediant with ordinary fraction addition.
Refine rational bounds
Produce a new candidate between two positive rational bounds during an exact search or approximation procedure.
FAQ
What is the mediant of a/b and c/d?
It is (a + c)/(b + d): add the numerators together and add the denominators together.
Is the mediant the same as adding two fractions?
No. Ordinary addition uses a common denominator; the mediant uses the sum of the denominators.
Does the calculator reduce the result?
No. It preserves the summed numerator and denominator because those values directly express the mediant construction.
Can either input denominator be zero?
No. A zero first or second denominator causes an invalid-input error.
Can I use negative integers?
Yes. Safe negative integers are accepted, although familiar ordering properties generally assume positive denominators.
What does an API request cost?
Each API request costs $0.002. The same deterministic calculation can also run in your browser.
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/numth/mediant-fraction \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"first_numerator":1,"first_denominator":3,"second_numerator":2,"second_denominator":5}'const res = await fetch("https://api.kit.forhosting.com/numth/mediant-fraction", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"first_numerator": 1,
"first_denominator": 3,
"second_numerator": 2,
"second_denominator": 5
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/numth/mediant-fraction",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"first_numerator": 1,
"first_denominator": 3,
"second_numerator": 2,
"second_denominator": 5
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/numth/mediant-fraction", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"first_numerator":1,"first_denominator":3,"second_numerator":2,"second_denominator":5}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"first_numerator":1,"first_denominator":3,"second_numerator":2,"second_denominator":5}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/numth/mediant-fraction", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"first_numerator": 1,
"first_denominator": 3,
"second_numerator": 2,
"second_denominator": 5
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "numth.mediant_fraction",
"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. |