# negative#

ivy.negative(x, /, *, out=None)[source]#

Return a new array with the negative value of each element in `x`.

Note

For signed integer data types, the numerical negative of the minimum representable integer is implementation-dependent.

Note

If `x` has a complex floating-point data type, both the real and imaginary components for each `x_i` must be negated (a result which follows from the rules of complex number multiplication).

Parameters:
• x (`Union`[`float`, `Array`, `NativeArray`]) – Input array.

• out (`Optional`[`Array`], default: `None`) – optional output array, for writing the result to. It must have a shape that the inputs broadcast to.

Return type:

`Array`

Returns:

ret – A new array with the negative value of each element in `x`.

This function conforms to the Array API Standard. This docstring is an extension of the docstring in the standard.

Both the description and the type hints above assumes an array input for simplicity, but this function is nestable, and therefore also accepts `ivy.Container` instances in place of any of the arguments.

Examples

With `ivy.Array` input:

```>>> x = ivy.array([0,1,1,2])
>>> y = ivy.negative(x)
>>> print(y)
ivy.array([ 0, -1, -1, -2])
```
```>>> x = ivy.array([0,-1,-0.5,2,3])
>>> y = ivy.zeros(5)
>>> ivy.negative(x, out=y)
>>> print(y)
ivy.array([-0. ,  1. ,  0.5, -2. , -3. ])
```
```>>> x = ivy.array([[1.1, 2.2, 3.3],
...                [-4.4, -5.5, -6.6]])
>>> ivy.negative(x,out=x)
>>> print(x)
ivy.array([[-1.1, -2.2, -3.3],
[4.4, 5.5, 6.6]])
```

With `ivy.Container` input:

```>>> x = ivy.Container(a=ivy.array([0., 1., 2.]),
...                   b=ivy.array([3., 4., -5.]))
>>> y = ivy.negative(x)
>>> print(y)
{
a: ivy.array([-0., -1., -2.]),
b: ivy.array([-3., -4., 5.])
}
```
Array.negative(self, *, out=None)[source]#

ivy.Array instance method variant of ivy.negative. This method simply wraps the function, and so the docstring for ivy.negative also applies to this method with minimal changes.

Parameters:
• self (`Array`) – input array. Should have a numeric data type.

• out (`Optional`[`Array`], default: `None`) – optional output, for writing the result to. It must have a shape that the inputs broadcast to.

Return type:

`Array`

Returns:

ret – an array containing the evaluated result for each element in `self`. The returned array must have the same data type as `self`.

Examples

With `ivy.Array` input:

```>>> x = ivy.array([2, 3 ,5, 7])
>>> y = x.negative()
>>> print(y)
ivy.array([-2, -3, -5, -7])
```
```>>> x = ivy.array([0,-1,-0.5,2,3])
>>> y = ivy.zeros(5)
>>> x.negative(out=y)
>>> print(y)
ivy.array([-0. ,  1. ,  0.5, -2. , -3. ])
```
```>>> x = ivy.array([[1.1, 2.2, 3.3],
...                [-4.4, -5.5, -6.6]])
>>> x.negative(out=x)
>>> print(x)
ivy.array([[ -1.1, -2.2, -3.3],
[4.4, 5.5, 6.6]])
```
Container.negative(self, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

ivy.Container instance method variant of ivy.negative. This method simply wraps the function, and so the docstring for ivy.negative also applies to this method with minimal changes.

Parameters:
• self (`Container`) – input container. Should have a numeric data type.

• key_chains (`Optional`[`Union`[`List`[`str`], `Dict`[`str`, `str`], `Container`]], default: `None`) – The key-chains to apply or not apply the method to. Default is `None`.

• to_apply (`Union`[`bool`, `Container`], default: `True`) – If True, the method will be applied to key_chains, otherwise key_chains will be skipped. Default is `True`.

• prune_unapplied (`Union`[`bool`, `Container`], default: `False`) – Whether to prune key_chains for which the function was not applied. Default is `False`.

• map_sequences (`Union`[`bool`, `Container`], default: `False`) – Whether to also map method to sequences (lists, tuples). Default is `False`.

• out (`Optional`[`Container`], default: `None`) – optional output container, for writing the result to. It must have a shape that the inputs broadcast to.

Return type:

`Container`

Returns:

ret – a container containing the evaluated result for each element in `self`. The returned container must have the same data type as `self`.

Examples

With `ivy.Container` input:

```>>> x = ivy.Container(a=ivy.array([0., 1., 2.]),
...                   b=ivy.array([3., 4., -5.]))
>>> y = x.negative()
>>> print(y)
{
a: ivy.array([-0., -1., -2.]),
b: ivy.array([-3., -4., 5.])
}
```