rational.root
This function gives the `k`-th root of `a` when it is a rational, and `null` when it is not. The root of a rational in lowest terms is rational only when its numerator and its denominator are both `k`-th powers of integers. An odd index gives the negative root of a negative value. The result is exact.
CLI- Package
- @procedures/rational · README
- Path
["rational","root"]- CLI
mark rational root --a <object> --k <number>- As data
{"$proc":["rational","root"],"input":{}}
Use it
In TypeScript
import { Client, LocalTransport, PROCEDURE_REGISTRY } from "@procedures/client";
import "@procedures/rational/register"; // registers its procedures
const client = new Client(new LocalTransport({ registry: PROCEDURE_REGISTRY }));
const result = await client.exec(["rational","root"], { a: {}, k: 1 });
console.log(JSON.stringify(result));From the command line
$ mark rational root --a <object> --k <number>
As data, in a program
{ "$proc": ["rational", "root"], "input": { "a": {}, "k": 1 } }Input
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
a | object | yes | The value. | |
k | number | yes | An integer index of 1 or more. |
Output
The schema does not list fields (null | object).
JSON Schemas
{
"input": {
"type": "object",
"properties": {
"a": {
"type": "object",
"properties": {
"n": {
"type": "string",
"pattern": "^-?(0|[1-9][0-9]*)$",
"x-procedures-codec": "bigint"
},
"d": {
"type": "string",
"pattern": "^-?(0|[1-9][0-9]*)$",
"x-procedures-codec": "bigint"
}
},
"required": [
"n",
"d"
],
"additionalProperties": {},
"description": "The value."
},
"k": {
"type": "number",
"description": "An integer index of 1 or more."
}
},
"required": [
"a",
"k"
],
"additionalProperties": false
},
"output": {
"anyOf": [
{
"type": "null"
},
{
"type": "object",
"properties": {
"n": {
"type": "string",
"pattern": "^-?(0|[1-9][0-9]*)$",
"x-procedures-codec": "bigint"
},
"d": {
"type": "string",
"pattern": "^-?(0|[1-9][0-9]*)$",
"x-procedures-codec": "bigint"
}
},
"required": [
"n",
"d"
],
"additionalProperties": {}
}
]
}
}