acos
Compute the arccosine of a number to get the angle in degrees, or use unit parameter for radians.
Instructions
Arccosine. Result in degrees by default, or radians with unit param.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| value | Yes | ||
| unit | No |
Implementation Reference
- cruncher.js:1441-1453 (handler)The acos tool handler: computes arccosine of a value between -1 and 1, returning result in degrees (default) or radians based on the unit parameter. Uses Math.acos() and fromRadians() helper.
/** * Calculates the inverse cosine (arccosine) of a value. * @param {Object} args - The arguments object. * @param {number} args.value - The value between -1 and 1. * @param {string} [args.unit] - The unit ("degrees" or "radians"). * @returns {number} The angle whose cosine is value. * @throws {Error} If value is not between -1 and 1. */ acos: ({ value, unit }) => { if (value < -1 || value > 1) throw new Error("acos input must be between -1 and 1."); return fromRadians(Math.acos(value), unit); }, - cruncher.js:422-441 (schema)The acos tool schema definition (inputSchema): accepts a 'value' (number, required) and an optional 'unit' (string, enum: degrees/radians).
{ name: "acos", annotations: { title: "Arccosine", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false, }, description: 'Arccosine. Result in degrees by default, or radians with unit param.', inputSchema: { type: "object", properties: { value: { type: "number" }, unit: { type: "string", enum: ["degrees", "radians"] }, }, required: ["value"], }, }, - cruncher.js:75-86 (registration)The acos tool is registered in the 'standard' tool tier within TOOL_TIERS configuration, ensuring it is exposed to the LLM.
standard: [ "evaluate_expression", "add", "subtract", "multiply", "divide", "sqrt", "power", "absolute", "modulo", "factorial", "logarithm", "natural_log", "get_constant", "sine", "cosine", "tangent", "asin", "acos", "atan", "set_angle_mode", "get_angle_mode", "sum", "avg", "min", "max", "count", "variance", "std_dev", "percentage_of", "percentage_change", "percentage_reverse", "median", "range", "convert_unit", ], - cruncher.js:1315-1318 (helper)The fromRadians helper used by the acos handler to convert the radian result of Math.acos() into degrees (default) or keep it in radians.
const fromRadians = (radians, unit) => { const resolved = unit || angleMode; return resolved === "degrees" ? radians * (180 / Math.PI) : radians; }; - cruncher.js:214-215 (helper)Pre-compiled regex RE_FUNC_ACOS used by evaluate_expression to convert 'acos(...)' to 'Math.acos(...)' in expressions.
const RE_FUNC_ACOS = /\bacos\s*\(/g; const RE_FUNC_ATAN = /\batan\s*\(/g;