mirror of
https://github.com/josdejong/mathjs.git
synced 2026-01-18 14:59:29 +00:00
51 lines
1.2 KiB
Markdown
51 lines
1.2 KiB
Markdown
# Function multiply
|
|
|
|
Multiply two values, `x * y`. The result is squeezed.
|
|
For matrices, the matrix product is calculated.
|
|
|
|
|
|
## Syntax
|
|
|
|
```js
|
|
math.multiply(x, y)
|
|
```
|
|
|
|
### Parameters
|
|
|
|
Parameter | Type | Description
|
|
--------- | ---- | -----------
|
|
`x` | Number | BigNumber | Boolean | Complex | Unit | Array | Matrix | null | First value to multiply
|
|
`y` | Number | BigNumber | Boolean | Complex | Unit | Array | Matrix | null | Second value to multiply
|
|
|
|
### Returns
|
|
|
|
Type | Description
|
|
---- | -----------
|
|
Number | BigNumber | Complex | Unit | Array | Matrix | Multiplication of `x` and `y`
|
|
|
|
|
|
## Examples
|
|
|
|
```js
|
|
math.multiply(4, 5.2); // returns Number 20.8
|
|
|
|
var a = math.complex(2, 3);
|
|
var b = math.complex(4, 1);
|
|
math.multiply(a, b); // returns Complex 5 + 14i
|
|
|
|
var c = [[1, 2], [4, 3]];
|
|
var d = [[1, 2, 3], [3, -4, 7]];
|
|
math.multiply(c, d); // returns Array [[7, -6, 17], [13, -4, 33]]
|
|
|
|
var e = math.unit('2.1 km');
|
|
math.multiply(3, e); // returns Unit 6.3 km
|
|
```
|
|
|
|
|
|
## See also
|
|
|
|
[divide](divide.md)
|
|
|
|
|
|
<!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
|