mirror of
https://github.com/josdejong/mathjs.git
synced 2025-12-08 19:46:04 +00:00
837 B
837 B
Function dot
Calculate the dot product of two vectors. The dot product of
A = [a1, a2, a3, ..., an] and B = [b1, b2, b3, ..., bn] is defined as:
dot(A, B) = a1 * b1 + a2 * b2 + a3 * b3 + ... + an * bn
Syntax
math.dot(x, y)
Parameters
| Parameter | Type | Description |
|---|---|---|
x |
Array | Matrix | First vector |
y |
Array | Matrix | Second vector |
Returns
| Type | Description |
|---|---|
| number | Returns the dot product of x and y |
Examples
math.dot([2, 4, 1], [2, 2, 3]) // returns number 15
math.multiply([2, 4, 1], [2, 2, 3]) // returns number 15