Math Utilities

Square

Square multiplies any number by itself, returning the mathematical square via GET /v1/math/square. Perfect for AI agents calculating areas, statistical variance, or quadratic operations in Cursor and Claude Code. Handles integers, decimals, and negative numbers with full precision.

API Endpoint

GET /v1/math/square

Code Examples

curl "https://tinyfn.io/v1/math/square" \
  -H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/math/square', {
  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/square',
    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 square a number using the MCP tool in Cursor?

Call the square tool with your number as input. It works with any numeric value including decimals and negatives, returning the precise mathematical result.

What's the difference between square and power functions?

Square specifically multiplies a number by itself (n²), while power functions handle any exponent. Square is optimized for this common operation.

Does the square function handle negative numbers correctly?

Yes, it follows standard mathematical rules: negative numbers squared become positive (e.g., (-5)² = 25).

What number formats does the square endpoint accept?

Accepts integers, decimals, scientific notation, and negative numbers. Returns results with appropriate precision for the input type.

Can I use square for calculating areas in AI agent workflows?

Absolutely. It's commonly used for area calculations, statistical operations, and any scenario requiring deterministic n² computation.

Try Square Now

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

Get Free API Key