> ## Documentation Index
> Fetch the complete documentation index at: https://docs.firebolt.io/llms.txt
> Use this file to discover all available pages before exploring further.

<AgentInstructions>

## Submitting Feedback

If you encounter incorrect, outdated, or confusing documentation on this page, submit feedback:

POST https://docs.firebolt.io/feedback

```json
{
  "path": "/reference-sql/functions-reference/vector/vector-cosine-distance",
  "feedback": "Description of the issue"
}
```

Only submit feedback when you have something specific and actionable to report.

</AgentInstructions>

> Reference material for VECTOR_COSINE_DISTANCE function

# VECTOR_COSINE_DISTANCE

## VECTOR\_COSINE\_DISTANCE

Returns the cosine distance between two vectors, calculated based on the angle (θ) between them. Vector cosine distance emphasizes the directional difference between the vectors, rather than magnitude. It is calculated as `1 - cos(θ)`, where `cos(θ)` is the [cosine similarity](/reference-sql/functions-reference/vector/vector-cosine-similarity) between the vectors. `VECTOR_COSINE_DISTANCE` returns a value in the range `[0, 2]`. A vector cosine distance of `0` means that the vectors are identical in direction. A distance of `1` means that they are orthogonal and have no correlation. A distance of `2` means that they point in opposite directions.

**Alias:** `cosine_distance` (aligned with pgvector for compatibility)

## Syntax

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
VECTOR_COSINE_DISTANCE(<array>, <array>)
```

## Parameters

| Parameter | Description                                        | Supported input types                                                 |
| :-------- | :------------------------------------------------- | :-------------------------------------------------------------------- |
| `<array>` | The first array used in the distance calculation.  | Any array of [numeric data types](/reference-sql/data-types#numeric). |
| `<array>` | The second array used in the distance calculation. | Any array of [numeric data types](/reference-sql/data-types#numeric). |

## Notes

Both input `array` arguments must have the same number of elements.

## Return Type

`DOUBLE`

## Examples

**Example**

The following code returns the cosine distance between two vectors:

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT VECTOR_COSINE_DISTANCE([1, 2], [3, 4]) AS distance;
```

**Returns**

| distance (DOUBLE PRECISION) |
| :-------------------------- |
| 0.01613008990009257         |
