47 lines
		
	
	
		
			954 B
		
	
	
	
		
			Markdown
		
	
	
	
	
	
			
		
		
	
	
			47 lines
		
	
	
		
			954 B
		
	
	
	
		
			Markdown
		
	
	
	
	
	
<!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
 | 
						|
 | 
						|
# Function abs
 | 
						|
 | 
						|
Calculate the absolute value of a number. For matrices, the function is
 | 
						|
evaluated element wise.
 | 
						|
 | 
						|
 | 
						|
## Syntax
 | 
						|
 | 
						|
```js
 | 
						|
math.abs(x)
 | 
						|
```
 | 
						|
 | 
						|
### Parameters
 | 
						|
 | 
						|
Parameter | Type | Description
 | 
						|
--------- | ---- | -----------
 | 
						|
`x` | number | BigNumber | Fraction | Complex | Array | Matrix | Unit |  A number or matrix for which to get the absolute value
 | 
						|
 | 
						|
### Returns
 | 
						|
 | 
						|
Type | Description
 | 
						|
---- | -----------
 | 
						|
number | BigNumber | Fraction | Complex | Array | Matrix | Unit |  Absolute value of `x`
 | 
						|
 | 
						|
 | 
						|
### Throws
 | 
						|
 | 
						|
Type | Description
 | 
						|
---- | -----------
 | 
						|
 | 
						|
 | 
						|
## Examples
 | 
						|
 | 
						|
```js
 | 
						|
math.abs(3.5)                // returns number 3.5
 | 
						|
math.abs(-4.2)               // returns number 4.2
 | 
						|
 | 
						|
math.abs([3, -5, -1, 0, 2])  // returns Array [3, 5, 1, 0, 2]
 | 
						|
```
 | 
						|
 | 
						|
 | 
						|
## See also
 | 
						|
 | 
						|
[sign](sign.md)
 |