# numpy.cbrt () in Python

|

Parameters :

`  arr:   [array_like]  Input array or object whose elements, we need to square. `

Return:

` An array with cube root of x for all x ie array elements `

Code # 1: Work

 ` # Python program explaining ` ` # cbrt () function `   ` import ` ` numpy as np `   ` arr1 ` ` = ` ` [` ` 1 ` `, ` ` 27000 ` `, ` ` 64 ` `, ` ` - ` ` 1000 ` `] ` ` print ` ` (` `" cbrt Value of arr1: "` `, np.cbrt (arr1)) ` ` `  ` arr2 ` ` = ` ` [` ` 1024 ` `, ` ` - ` ` 128 ` `] ` ` print ` ` (` ` "cbrt Value of arr2:" ` `, np.cbrt (arr2)) `

Output:

` cbrt Value of arr1: [1.30.4. - 10.] cbrt Value of arr2: [10.0793684 -5.0396842] `

Code # 2: Working with Complex Numbers

` `

` # Python program explaining # cbrt () function     import numpy as np   a = 4 + 3j print ( "cbrt (4 + 3j):" , np.cbrt (a))   b = 16 + 13j print ( "cbrt value (16 + 13j):" , np.cbrt (b)) `

Output:

`  TypeError:  ufunc ’cbrt’ not supported for the i nput types, and the inputs could not be safely coerced to any supported types according to the casting rule ’’ safe ’’ `

Code # 3: Graphical Representation

 ` # Python program explaining ` ` # cbrt () function `   ` import ` ` numpy as np ` ` import ` ` matplotlib.pyplot as plt ` ` `  ` a ` ` = ` ` np.linspace ( start ` ` = ` ` - ` ` 5 ` `, stop ` ` = ` ` 150 ` `, ` ` num ` ` = ` ` 10 ` `, endpoint ` ` = ` ` True ` `) `   ` print ` ` (` ` "Graphical Representation:" ` `, np.cbrt (a)) `   ` plt.title (` ` "blue: with cbrt red: without cbrt" ` `) ` ` plt.plot (a, np. cbrt (a)) `   ` plt.scatter (a, a, color ` ` = ` ` ’red’ ` `) ` ` plt.show () `

< / code>

Output:

` Graphical Representation: [-1.70997595 2.30347441 3.08793243 3.60027433 3.99768384 4.3287262 4.61565763 4.87076238 5.10162421 5.31329285] `

## Shop Learn programming in R: courses

\$ Best Python online courses for 2022

\$ Best laptop for Fortnite

\$ Best laptop for Excel

\$ Best laptop for Solidworks

\$ Best laptop for Roblox

\$ Best computer for crypto mining

\$ Best laptop for Sims 4

\$

Latest questions

NUMPYNUMPY

psycopg2: insert multiple rows with one query

NUMPYNUMPY

How to convert Nonetype to int or string?

NUMPYNUMPY

How to specify multiple return types using type-hints

NUMPYNUMPY

Javascript Error: IPython is not defined in JupyterLab

## Wiki

Python OpenCV | cv2.putText () method

numpy.arctan2 () in Python

Python | os.path.realpath () method

Python OpenCV | cv2.circle () method

Python OpenCV cv2.cvtColor () method

Python - Move item to the end of the list

time.perf_counter () function in Python

Check if one list is a subset of another in Python

Python os.path.join () method