# `DOT_PRODUCT`

**Applies to:** ✅ Data 360 SQL ✅ Tableau Hyper API

Computes the conventional dot product (scalar product) of two vectors.

## Syntax

```sql
dot_product(<array1>, <array2>)
```

## Arguments

### Required

- `<array1>`: The first vector (`array(real)` or `array(double precision)`).
- `<array2>`: The second vector (`array(real)` or `array(double precision)`).

## Returns

Returns a double-precision value that represents the dot product of the two vectors.

## Considerations

- Both input arrays must be of the same element type and length.
- If any element is NULL, the result is NULL.
- For optimal performance, use array definitions with non-nullable elements such as `array(real not null)`.

## Examples

### Calculate Dot Product

Compute the dot product of two vectors.

```sql
SELECT dot_product(array[1, 2, 3], array[-1, 2, -3]) AS result;
```

Returns `-6.0`, calculated as (1 × -1) + (2 ×2 ) + (3 × -3) = -1 + 4 - 9 = -6.

## Related Documentation

- [Array Data Type](/docs/data/data-cloud-query-guide/references/dc-sql-reference/array.md)
