函数 multiply #

将两个或多个值相乘,x * y。对于矩阵,则计算矩阵乘积。

Syntax #

math.multiply(x, y)
math.multiply(x, y, z, ...)

Parameters #

Parameter Type Description
x number | BigNumber | bigint | Fraction | Complex | Unit | Array | Matrix 第一个乘数
y number | BigNumber | bigint | Fraction | Complex | Unit | Array | Matrix 第二个乘数

Returns #

Type Description
number | BigNumber | bigint | Fraction | Complex | Unit | Array | Matrix xy 的乘积

Throws #

Type | Description —- | ———–

Examples #

math.multiply(4, 5.2)        // returns number 20.8
math.multiply(2, 3, 4)       // returns number 24

const a = math.complex(2, 3)
const b = math.complex(4, 1)
math.multiply(a, b)          // returns Complex 5 + 14i

const c = [[1, 2], [4, 3]]
const d = [[1, 2, 3], [3, -4, 7]]
math.multiply(c, d)          // returns Array [[7, -6, 17], [13, -4, 33]]

const e = math.unit('2.1 km')
math.multiply(3, e)          // returns Unit 6.3 km

另请参阅 #

divide, prod, cross, dot

Fork me on GitHub