Rational multiply
rational-multiply · version 1.0.0 · Numbers & math · free, no key needed
Multiply two rational numbers given as numerator/denominator integer strings and return the reduced product.
Use when you need to: rational multiply · multiply two rational numbers · multiply fractions as rationals.
Supported
- rational multiply
- multiply two rational numbers
- multiply fractions as rationals
- product of two rationals
Not supported
- rational add
- decimal multiply
- float multiplication
- mixed numbers
- continued fractions
- IEEE-754 arithmetic
Behavior
- Each operand is an object with canonical integer-string numerator and denominator fields.
- The denominator must be a positive canonical integer; zero and negative denominators are rejected.
- Inputs may use -0, which is canonicalized to 0; every other integer must match 0 or -?[1-9][0-9]*.
- The product is (a.numerator * b.numerator) / (a.denominator * b.denominator).
- The result is reduced by gcd, with the sign only on the numerator; 0 is numerator 0 over denominator 1.
- Input, intermediate, and output numerators and denominators may have at most 1000 digits excluding sign.
Input
a(object, required)b(object, required)
Output
numerator(string, required)denominator(string, required)
Limits
- max digits: 1000
Example
Request input:
{
"a": {
"numerator": "2",
"denominator": "3"
},
"b": {
"numerator": "3",
"denominator": "4"
}
}
Response:
{
"result": {
"numerator": "1",
"denominator": "2"
}
}
How to call it
MCP
Connect https://computefirst.net/mcp (setup), then call execute with:
{
"id": "rational-multiply",
"version": "1.0.0",
"input": {
"a": {
"numerator": "2",
"denominator": "3"
},
"b": {
"numerator": "3",
"denominator": "4"
}
}
}
HTTP (no key)
curl -X POST https://computefirst.net/v1/tools/rational-multiply/versions/1.0.0/execute \
-H "Content-Type: application/json" \
-d '{"a":{"numerator":"2","denominator":"3"},"b":{"numerator":"3","denominator":"4"}}'
The machine-readable contract is at /v1/tools/rational-multiply/versions/1.0.0.
CLI
node cli.mjs run rational-multiply 1.0.0 --input input.json --base-url https://computefirst.net
Get the client at /clients/cli/.
Related tools
- Rational subtract: Subtract one rational number from another, given as numerator/denominator integer strings, and return the reduced difference.
- Rational add: Add two rational numbers given as numerator/denominator integer strings and return the reduced sum.
- Rational compare: Compare two rational numbers given as numerator/denominator integer strings by exact value.
- Array rational sum: Sum an array of canonical rationals and return the reduced total.
- Array rational mean: Return the reduced arithmetic mean of an array of canonical rationals.
- Array rational min max: Return the reduced numeric minimum and maximum of an array of canonical rationals.