# series_dot_product_fl()

Calculates the dot product of two numerical vectors.

The function `series_dot_product_fl()` is a user-defined function (UDF) that takes an expression containing two dynamic numerical arrays as input and calculates their dot product.

Note

Use the native function series_dot_product() instead of the function described in this document. The native function provides the same functionality and is better for performance and scalability. This document is provided for reference purposes only.

## Syntax

`series_dot_product_fl(`vec1`,` vec2`)`

## Parameters

Name Type Required Description
vec1 `dynamic` ✔️ An array of numeric values.
vec2 `dynamic` ✔️ An array of numeric values that is the same length as vec1.

## Function definition

You can define the function by either embedding its code as a query-defined function, or creating it as a stored function in your database, as follows:

Define the function using the following let statement. No permissions are required.

Important

A let statement can't run on its own. It must be followed by a tabular expression statement. To run a working example of `series_dot_product_fl()`, see Example.

``````let series_dot_product_fl=(vec1:dynamic, vec2:dynamic)
{
let elem_prod = series_multiply(vec1, vec2);
let cum_sum = series_iir(elem_prod, dynamic([1]), dynamic([1,-1]));
todouble(cum_sum[-1])
};
// Write your query to use the function here.
``````

## Example

To use a query-defined function, invoke it after the embedded function definition.

``````let series_dot_product_fl=(vec1:dynamic, vec2:dynamic)
{
let elem_prod = series_multiply(vec1, vec2);
let cum_sum = series_iir(elem_prod, dynamic([1]), dynamic([1,-1]));
todouble(cum_sum[-1])
};
union
(print 1 | project v1=range(1, 3, 1), v2=range(4, 6, 1)),
(print 1 | project v1=range(11, 13, 1), v2=range(14, 16, 1))
| extend v3=series_dot_product_fl(v1, v2)
``````

Output