exp#
- ivy.exp(x, /, *, out=None)[source]#
Calculate an implementation-dependent approximation to the exponential function, having domain
[-infinity, +infinity]
and codomain[+0, +infinity]
, for each elementx_i
of the input arrayx
(e
raised to the power ofx_i
, wheree
is the base of the natural logarithm).Note
For complex floating-point operands,
exp(conj(x))
must equalconj(exp(x))
.Note
The exponential function is an entire function in the complex plane and has no branch cuts.
Special cases
For floating-point operands,
If
x_i
isNaN
, the result isNaN
.If
x_i
is+0
, the result is1
.If
x_i
is-0
, the result is1
.If
x_i
is+infinity
, the result is+infinity
.If
x_i
is-infinity
, the result is+0
.
For complex floating-point operands, let
a = real(x_i)
,b = imag(x_i)
, andIf
a
is either+0
or-0
andb
is+0
, the result is1 + 0j
.If
a
is a finite number andb
is+infinity
, the result isNaN + NaN j
.If
a
is a finite number andb
isNaN
, the result isNaN + NaN j
.If
a
is+infinity
andb
is+0
, the result isinfinity + 0j
.If
a
is-infinity
andb
is a finite number, the result is+0 * cis(b)
.If
a
is+infinity
andb
is a nonzero finite number, the result is+infinity * cis(b)
.If
a
is-infinity
andb
is+infinity
, the result is0 + 0j
(signs of real and imaginary components are unspecified).If
a
is+infinity
andb
is+infinity
, the result isinfinity + NaN j
(sign of real component is unspecified).If
a
is-infinity
andb
isNaN
, the result is0 + 0j
(signs of real and imaginary components are unspecified).If
a
is+infinity
andb
isNaN
, the result isinfinity + NaN j
(sign of real component is unspecified).If
a
isNaN
andb
is+0
, the result isNaN + 0j
.If
a
isNaN
andb
is not equal to0
, the result isNaN + NaN j
.If
a
isNaN
andb
isNaN
, the result isNaN + NaN j
.
where
cis(v)
iscos(v) + sin(v)*1j
.- Parameters:
- Return type:
- Returns:
ret – an array containing the evaluated exponential function result for each element in
x
. The returned array must have a floating-point data type determined by type-promotion.This method conforms to the
This docstring is an extension of the
`docstring <https (//data-apis.org/array-api/latest/)
API_specification/generated/array_api.exp.html>`_
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 :class:Number:
>>> x = 3. >>> y = ivy.exp(x) >>> print(y) ivy.array(20.08553692)
With
ivy.Array
input:>>> x = ivy.array([1., 2., 3.]) >>> y = ivy.exp(x) >>> print(y) ivy.array([ 2.71828175, 7.38905621, 20.08553696])
With nested inputs in
ivy.Array
:>>> x = ivy.array([[-5.67], [ivy.nan], [0.567]]) >>> y = ivy.exp(x) >>> print(y) ivy.array([[0.00344786], [ nan], [1.76297021]])
With
ivy.NativeArray
input:>>> x = ivy.native_array([0., 4., 2.]) >>> y = ivy.exp(x) >>> print(y) ivy.array([ 1. , 54.59814835, 7.38905621])
With
ivy.Container
input:>>> x = ivy.Container(a=3.1, b=ivy.array([3.2, 1.])) >>> y = ivy.exp(x) >>> print(y) { a: ivy.array(22.197948), b: ivy.array([24.53253174, 2.71828175]) }
- Array.exp(self, *, out=None)[source]#
ivy.Array instance method variant of ivy.exp. This method simply wraps the function, and so the docstring for ivy.exp also applies to this method with minimal changes.
- Parameters:
self (
Array
) – input array. Should have a floating-point data type.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 – an array containing the evaluated exponential function result for each element in
self
. The returned array must have a floating-point data type determined by type-promotion.
Examples
>>> x = ivy.array([1., 2., 3.]) >>> print(x.exp()) ivy.array([ 2.71828198, 7.38905573, 20.08553696])
- Container.exp(self, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#
ivy.Container instance method variant of ivy.exp. This method simply wraps the function, and so the docstring for ivy.exp also applies to this method with minimal changes.
- Parameters:
self (
Container
) – input container. Should have a floating-point 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 isNone
.to_apply (
Union
[bool
,Container
], default:True
) – If True, the method will be applied to key_chains, otherwise key_chains will be skipped. Default isTrue
.prune_unapplied (
Union
[bool
,Container
], default:False
) – Whether to prune key_chains for which the function was not applied. Default isFalse
.map_sequences (
Union
[bool
,Container
], default:False
) – Whether to also map method to sequences (lists, tuples). Default isFalse
.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 array must have a real-valued floating-point data type determined by type-promotion.
Examples
>>> x = ivy.Container(a=ivy.array([1., 2., 3.]), b=ivy.array([4., 5., 6.])) >>> y = x.exp() >>> print(y) { a: ivy.array([2.71828198, 7.38905573, 20.08553696]), b: ivy.array([54.59814835, 148.4131622, 403.428772]) }