# **l1_norm()**

## **Function Description**

The `l1_norm` function is used to calculate the `l1`/Manhattan/TaxiCab norm. `l1` norm is obtained by summing the absolute values of vector elements.

<div align="center">
<img src=https://community-shared-data-1308875761.cos.ap-beijing.myqcloud.com/artwork/docs/reference/vector/l1_norm.png?raw=true width=50% heigth=50%/>
</div>

You can use the `l1` norm to calculate the `l1` distance.

```text
l1_distance(a,b) = l1_norm(a-b)
```

This calculation method is also applicable to calculating the `l2` distance from `l2_Norm`.

## **Function Syntax**

```sql
SELECT l1_norm(vector) AS result FROM table_name;
```

## **Example**

```text
drop table if exists vec_table;
create table vec_table(a int, b vecf32(3), c vecf64(3));
insert into vec_table values(1, "[1,2,3]", "[4,5,6]");
mysql> select * from vec_table;
+-------+--------------------------+
| a | b | c |
+-------+--------------------------+
| 1 | [1, 2, 3] | [4, 5, 6] |
+-------+--------------------------+
1 row in set (0.00 sec)

mysql> select l1_norm(b) from vec_table;
+----------------+
| l1_norm(b) |
+----------------+
| 6 |
+----------------+
1 row in set (0.00 sec)
```
