Computes the straight-line Euclidean distance between two points in n-dimensional space. Access via MCP in Cursor or Windsurf, or REST at GET /v1/math/distance. Pass coordinates as arrays like [0,0] and [3,4] to get 5.0. Works in 2D, 3D, or higher dimensions with floating-point precision.
curl "https://tinyfn.io/v1/math/distance" \
-H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/math/distance', {
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/distance',
headers={'X-API-Key': 'YOUR_API_KEY'})
data = response.json()
print(data)
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"
}
}
}
}
Pass coordinate arrays like point1=[1,2] and point2=[4,6] to get the Euclidean distance. For (1,2) to (4,6), the result is 5.0.
Yes, it handles any dimensional space. Use [x,y,z] arrays for 3D points like [0,0,0] and [1,1,1] which gives distance √3 ≈ 1.732.
Absolutely. AI agents in Cursor or Cline can calculate distances between waypoints, find nearest neighbors, or compute movement costs in games and simulations.
The calculation uses the minimum dimension count. Missing coordinates are treated as zero, so [1,2] and [3,4,5] computes distance in 2D space.
For one-off calculations, yes. The optimized implementation handles edge cases and provides consistent floating-point precision without writing your own math.