natural_log
Compute the natural logarithm (ln) for positive numeric values. Rejects non-positive inputs with an error.
Instructions
Natural logarithm (ln). Errors on non-positive input.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| value | Yes |
Implementation Reference
- cruncher.js:1455-1468 (handler)The natural_log handler function. Uses Math.log(value) to compute the natural logarithm (base e). Throws an error for non-positive input.
/** * Calculates the natural logarithm (base-e) of a value. * @param {Object} args - The arguments object. * @param {number} args.value - The positive number. * @returns {number} The natural logarithm of value. * @throws {Error} If value is not positive. */ natural_log: ({ value }) => { if (value <= 0) throw new Error( "Natural log is only defined for positive numbers.", ); return Math.log(value); }, - cruncher.js:474-490 (schema)The input schema definition for natural_log. Defines a single required 'value' parameter of type number.
{ name: "natural_log", annotations: { title: "Natural Logarithm", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false, }, description: "Natural logarithm (ln). Errors on non-positive input.", inputSchema: { type: "object", properties: { value: { type: "number" } }, required: ["value"], }, }, - cruncher.js:69-73 (registration)The natural_log tool is registered in the 'standard' tool tier set (line 73), making it available in the default tool set.
standard: [ "evaluate_expression", "add", "subtract", "multiply", "divide", "sqrt", "power", "absolute", "modulo", "factorial", "logarithm", "natural_log", "get_constant", - cruncher.js:130-149 (helper)natural_log is listed in MAIN_THREAD_TOOLS (line 142) so it executes directly on the main thread without spawning a worker.
const MAIN_THREAD_TOOLS = new Set([ // Angle management "set_angle_mode", "get_angle_mode", // Trigonometry (instant Math calls) "sine", "cosine", "tangent", "asin", "acos", "atan", // Cache management "cache_clear", "cache_info", // Simple stats (zero-cost) "count", "min", "max", "variance", "std_dev", // Percentage "percentage_of", "percentage_change", "percentage_reverse", // Math one-liners "power", "sqrt", "logarithm", "natural_log", "absolute", // Constant lookup "get_constant", // Memory recall (single variable read) "memory_recall", // Unit conversion "convert_unit", ]);