mirror of
https://github.com/josdejong/mathjs.git
synced 2026-01-25 15:07:57 +00:00
60 lines
1.7 KiB
Markdown
60 lines
1.7 KiB
Markdown
---
|
|
layout: default
|
|
---
|
|
|
|
<!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
|
|
|
|
<h1 id="function-divide">Function divide <a href="#function-divide" title="Permalink">#</a></h1>
|
|
|
|
Divide two values, `x / y`.
|
|
To divide matrices, `x` is multiplied with the inverse of `y`: `x * inv(y)`.
|
|
|
|
|
|
<h2 id="syntax">Syntax <a href="#syntax" title="Permalink">#</a></h2>
|
|
|
|
```js
|
|
math.divide(x, y)
|
|
```
|
|
|
|
<h3 id="parameters">Parameters <a href="#parameters" title="Permalink">#</a></h3>
|
|
|
|
Parameter | Type | Description
|
|
--------- | ---- | -----------
|
|
`x` | number | BigNumber | bigint | Fraction | Complex | Unit | Array | Matrix | Numerator
|
|
`y` | number | BigNumber | bigint | Fraction | Complex | Array | Matrix | Denominator
|
|
|
|
<h3 id="returns">Returns <a href="#returns" title="Permalink">#</a></h3>
|
|
|
|
Type | Description
|
|
---- | -----------
|
|
number | BigNumber | bigint | Fraction | Complex | Unit | Array | Matrix | Quotient, `x / y`
|
|
|
|
|
|
<h3 id="throws">Throws <a href="#throws" title="Permalink">#</a></h3>
|
|
|
|
Type | Description
|
|
---- | -----------
|
|
|
|
|
|
<h2 id="examples">Examples <a href="#examples" title="Permalink">#</a></h2>
|
|
|
|
```js
|
|
math.divide(2, 3) // returns number 0.6666666666666666
|
|
|
|
const a = math.complex(5, 14)
|
|
const b = math.complex(4, 1)
|
|
math.divide(a, b) // returns Complex 2 + 3i
|
|
|
|
const c = [[7, -6], [13, -4]]
|
|
const d = [[1, 2], [4, 3]]
|
|
math.divide(c, d) // returns Array [[-9, 4], [-11, 6]]
|
|
|
|
const e = math.unit('18 km')
|
|
math.divide(e, 4.5) // returns Unit 4 km
|
|
```
|
|
|
|
|
|
<h2 id="see-also">See also <a href="#see-also" title="Permalink">#</a></h2>
|
|
|
|
[multiply](multiply.html)
|