
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
Compute the square root of complex inputs with scimath in Python
To compute the square root of input, use the emath.sqrt() method in Python Numpy. The method returns the square root of x. If x was a scalar, so is out, otherwise an array is returned. The parameter x is the input value. For negative input elements, a complex value is returned
Steps
At first, import the required libraries −
import numpy as np
The complex input explicity using complex() method −
a = complex(-9.0, 0.0)
Display the array −
print("Display the complex value...\n",a)
To compute the square root of input, use the emath.sqrt() method in Python Numpy −
print("\nResult...\n",np.emath.sqrt(a))
Example
import numpy as np # Explicity using complex() method a = complex(-9.0, 0.0) # Display the array print("Display the complex value...\n",a) # To compute the square root of input, use the emath.sqrt() method in Python Numpy # The method returns the square root of x. If x was a scalar, so is out, otherwise an array is returned. print("\nResult...\n",np.emath.sqrt(a))
Output
Display the complex value... (-9+0j) Result... 3j
- Related Articles
- Compute the square root of input with emath in Python
- Compute the square root of negative input with emath in Python
- Compute the natural logarithm with scimath in Python
- Compute the inverse cosine with scimath in Python
- Compute the inverse sine with scimath in Python
- Compute the logarithm base 2 with scimath in Python
- Compute the logarithm base n with scimath in Python
- Compute the logarithm base 10 with scimath in Python
- Compute the inverse hyperbolic tangent with scimath in Python
- How to find Square root of complex numbers in Python?
- Compute the roots of a polynomial with given complex roots in Python
- Compute the roots of a Laguerre series with given complex roots in Python
- Compute the roots of a Hermite series with given complex roots in Python
- Compute the roots of a Chebyshev series with given complex roots in Python
- Compute the roots of a Legendre series with given complex roots in Python

Advertisements