Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

python
numpy

What is the exp function in NumPy?

Hassaan Waqar

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

The exp function in NumPy is used to compute the exponent of all values present in the given array.

e refers to Euler’s constant. It has an approximate value of 2.718.

Syntax

The syntax of the exp function is as follows:

numpy.exp(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj]) = <ufunc 'exp'>

Parameters

The description of each parameter of the exp function is given below:

Parameter Description
array The array of numbers to compute exponents of.
out The location where the result is stored. By default, a new array of results is created.
where Takes an array-like object. At locations where it is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value.
dtype Data type of the resultant array.
casting Determines which kind of casting is permissible. Can be ‘no’, ‘equiv’, ‘safe’, ‘same_kind’, or ‘unsafe’.
order Determines the calculation iteration order or memory layout of the output array.
subok If set to False, the output will always be a strict array and not a subtype. It is True by default.

Return value

The exp function returns an array with the element-wise exponent.

Example

The code snippet below shows how the exp function works in NumPy:

import numpy as np
in_array = [1, 3, 5]
print ("Input array : ", in_array)
out_array = np.exp(in_array)
print ("Output array : ", out_array)

RELATED TAGS

python
numpy

CONTRIBUTOR

Hassaan Waqar
Copyright ©2022 Educative, Inc. All rights reserved

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring