numpy.real() function Python (original) (raw)
Last Updated : 11 Jun, 2020
**numpy.real()
**function return the real part of the complex argument.
Syntax : numpy.real(arr)
Parameters :
arr : [array_like] Input array.Return : [ndarray or scalar] The real component of the complex argument. If val is real, the type of val is used for the output. If val has complex elements, the returned type is float.
Code #1 :
import
numpy as geek
arr
=
geek.array([
1
+
3j
,
5
+
7j
,
9
+
11j
])
gfg
=
arr.real
print
(gfg)
Output :
[1. 5. 9.]
Code #2 :
import
numpy as geek
arr
=
geek.array([
2
+
3j
,
5
+
6j
,
8
+
9j
])
gfg
=
arr.real
print
(gfg)
Output :
[2. 5. 8.]
Similar Reads
- numpy.roots() function - Python numpy.roots() function return the roots of a polynomial with coefficients given in p. The values in the rank-1 array p are coefficients of a polynomial. If the length of p is n+1 then the polynomial is described by: p[0] * x**n + p[1] * x**(n-1) + ... + p[n-1]*x + p[n] Syntax : numpy.roots(p) Parame 1 min read
- numpy.real_if_close() function - Python In this numpy.real_if_close()function, if complex input returns a real array then complex parts are close to zero. Syntax : numpy.real_if_close(arr, tol = 100) Parameters : arr : [array_like] Input array. tol : [float] “Close to zero†is defined as tol. Tolerance in machine epsilons for the complex 1 min read
- numpy.i0() function | Python numpy.i0() function is the modified Bessel function of the first kind, order 0. it's usually denoted by I0. Syntax : numpy.i0(x) Parameters : x : [array_like, dtype float or complex] Argument of the Bessel function. Return : [ndarray, shape = x.shape, dtype = x.dtype] The modified Bessel function ev 1 min read
- numpy.imag() function - Python numpy.imag() function return the imaginary part of the complex argument. Syntax : numpy.imag(arr) Parameters : arr : [array_like] Input array. Return : [ndarray or scalar] The imaginary component of the complex argument. If val is real, the type of val is used for the output. If val has complex elem 1 min read
- numpy.iinfo() function – Python numpy.iinfo() function shows machine limits for integer types. Syntax : numpy.iinfo(dtype) Parameters : dtype : [integer type, dtype, or instance] The kind of integer data type to get information about. Return : Machine limits for integer types. Code #1 : # Python program explaining # numpy.iinfo() 1 min read
- numpy.reciprocal() in Python The numpy.reciprocal() is a mathematical function that is used to calculate reciprocal of all the elements in the input array. Syntax :numpy.reciprocal(x, /, out=None, *, where=True) Parameters : x[array_like]: Input array or object whose elements needed to test. out [ndarray, optional]: A location 2 min read
- round() function in Python Python round() function is a built-in function available with Python. It will return you a float number that will be rounded to the decimal places which are given as input. If the decimal places to be rounded are not specified, it is considered as 0, and it will round to the nearest integer. In this 6 min read
- Python int() Function The Python int() function converts a given object to an integer or converts a decimal (floating-point) number to its integer part by truncating the fractional part. Example: In this example, we passed a string as an argument to the int() function and printed it. [GFGTABS] Python age = "21" 4 min read
- pow() Function - Python pow() function in Python is a built-in tool that calculates one number raised to the power of another. It also has an optional third part that gives the remainder when dividing the result. Example: [GFGTABS] Python print(pow(3,2)) [/GFGTABS]Output9 Explanation: pow(3, 2) calculates 32 = 9, where the 2 min read
- Python | Numpy ndarray.real() With the help of Numpy ndarray.real() method, we can find the real values in an imaginary expressions by just using ndarray.real() method. Remember resulting data type for the real value is 'float64'. Syntax : ndarray.real() Return : Array of Real values having dtype 'float64' Example #1 : In this e 1 min read