Function reference · Math

abs

Returns the absolute value of an expression.

It drops the abs when the sign is known: from numbers, even powers, or assumptions. Otherwise it stays. For a complex number it is the modulus.

Notation

abs(x)

Write it in an expression: nerdamer('abs(-5)'), or in the Playground.

nerdamer.abs

nerdamer.abs(x: ExpressionInput): Expression

A method on the default import. Arguments can be strings, as in Notation.

Examples

A negative number.

abs(-5)
// → 5
Open in Playground

An even power is never negative.

abs(x^2)
// → x^2
Open in Playground

With x>=4, 7-2*x is negative.

assume(x>=4); abs(7-2*x)
// → -(7-2*x)
Open in Playground

The modulus of a complex number.

abs(3+4*i)
// → 5
Open in Playground

The sign of x is unknown.

abs(x)
// → abs(x)
Open in Playground

Also called

magnitude

← Back to Function reference