

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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 Questions & Answers
- 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
- How to find Square root of complex numbers 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
- Return the element-wise square-root of a complex type array in Numpy
- Compute the roots of a polynomial with given complex roots in Python
- Return the square of the complex-value input in Python
- 8086 program to find the square root of a perfect square root number
- Guess Nearest Square Root in Python
Advertisements