Math Utilities

Log

Calculate logarithms with any base or natural log by default. Available via MCP in Cursor, Windsurf, and other AI tools, or REST at `/v1/math/log`. Pass a number and optional base — `log(100, 10)` returns `2.0` for log₁₀(100). Handles edge cases like negative numbers and provides IEEE 754 compliant results.

API Endpoint

GET /v1/math/log

Code Examples

curl "https://tinyfn.io/v1/math/log" \
  -H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/math/log', {
  headers: { 'X-API-Key': 'YOUR_API_KEY' }
});
const data = await response.json();
console.log(data);
import requests

response = requests.get('https://tinyfn.io/v1/math/log',
    headers={'X-API-Key': 'YOUR_API_KEY'})
data = response.json()
print(data)

Use via MCP

Add to your AI agent

Connect your AI agent (Claude, Cursor, Windsurf, etc.) to TinyFn's math tools:

{
  "mcpServers": {
    "tinyfn-math": {
      "url": "https://tinyfn.io/mcp/math",
      "headers": {
        "X-API-Key": "YOUR_API_KEY"
      }
    }
  }
}

Learn more about MCP setup →

FAQ

How do I calculate natural logarithm vs base-10 logarithm?

Natural log: just pass the number `log(2.718)` returns ~1.0. For base-10: `log(100, 10)` returns 2.0. No base parameter defaults to natural log (base e).

What happens when I pass negative numbers or zero to the log function?

Returns `NaN` for negative numbers and zero, following IEEE 754 standards. `log(-5)` and `log(0)` both return `NaN`.

Can I use this MCP tool in my AI agent for scientific calculations?

Yes, the log tool integrates with MCP-enabled editors like Cursor and Windsurf. Your AI agent gets precise logarithmic calculations instead of approximated results.

How do I calculate logarithms with custom bases like base-2 or base-16?

Pass the base as second parameter: `log(256, 2)` returns 8.0 for log₂(256), `log(256, 16)` returns 2.0 for log₁₆(256).

What's the difference between this and JavaScript's Math.log()?

Similar functionality but accessible via MCP protocol and REST API. Supports custom bases directly unlike Math.log() which only does natural log.

Try Log Now

Get your free API key and start using Log in seconds.

Get Free API Key