UNPKG

mathjs

Version:

Math.js is an extensive math library for JavaScript and Node.js. It features a flexible expression parser and offers an integrated solution to work with numbers, big numbers, complex numbers, units, and matrices.

44 lines (26 loc) 840 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 ```js math.dot(x, y) ``` ### Parameters Parameter | Type | Description --------- | ---- | ----------- `x` | Array &#124; Matrix | First vector `y` | Array &#124; Matrix | Second vector ### Returns Type | Description ---- | ----------- Number | Returns the dot product of `x` and `y` ## Examples ```js math.dot([2, 4, 1], [2, 2, 3]); // returns Number 15 math.multiply([2, 4, 1], [2, 2, 3]); // returns Number 15 ``` ## See also [multiply](multiply.md), [cross](cross.md) <!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->