simple-squiggle

A restricted subset of Squiggle
Log | Files | Refs | README

subtract.md (1216B)


      1 <!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
      2 
      3 # Function subtract
      4 
      5 Subtract two values, `x - y`.
      6 For matrices, the function is evaluated element wise.
      7 
      8 
      9 ## Syntax
     10 
     11 ```js
     12 math.subtract(x, y)
     13 ```
     14 
     15 ### Parameters
     16 
     17 Parameter | Type | Description
     18 --------- | ---- | -----------
     19 `x` | number &#124; BigNumber &#124; Fraction &#124; Complex &#124; Unit &#124; Array &#124; Matrix |  Initial value
     20 `y` | number &#124; BigNumber &#124; Fraction &#124; Complex &#124; Unit &#124; Array &#124; Matrix |  Value to subtract from `x`
     21 
     22 ### Returns
     23 
     24 Type | Description
     25 ---- | -----------
     26 number &#124; BigNumber &#124; Fraction &#124; Complex &#124; Unit &#124; Array &#124; Matrix |  Subtraction of `x` and `y`
     27 
     28 
     29 ### Throws
     30 
     31 Type | Description
     32 ---- | -----------
     33 
     34 
     35 ## Examples
     36 
     37 ```js
     38 math.subtract(5.3, 2)        // returns number 3.3
     39 
     40 const a = math.complex(2, 3)
     41 const b = math.complex(4, 1)
     42 math.subtract(a, b)          // returns Complex -2 + 2i
     43 
     44 math.subtract([5, 7, 4], 4)  // returns Array [1, 3, 0]
     45 
     46 const c = math.unit('2.1 km')
     47 const d = math.unit('500m')
     48 math.subtract(c, d)          // returns Unit 1.6 km
     49 ```
     50 
     51 
     52 ## See also
     53 
     54 [add](add.md)