- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# Return the result of the power to which the negative input value is raised with scimath in Python

To return the result of the power to which the input value is raised with scimath, use the scimath.power() method in Python. Returns x to the power p, i.e. the result of x**p. If x and p are scalars, so is out, otherwise an array is returned.

If x contains negative values, the output is converted to the complex domain. The parameter x is the input value. The parameter p is the power(s) to which x is raised. If x contains multiple values, p has to either be a scalar, or contain the same number of values as x. In the latter case, the result is x[0]**p[0], x[1]**p[1], ....

## Steps

At first, import the required libraries −

import numpy as np

Create a numpy array using the array() method. The array elements also includes negative values −

arr = np.array([2, -4, -8, 16, -32])

Display the array −

print("Our Array...\n",arr)

Check the Dimensions −

print("\nDimensions of our Array...\n",arr.ndim)

Get the Datatype −

print("\nDatatype of our Array object...\n",arr.dtype)

Get the Shape −

print("\nShape of our Array object...\n",arr.shape)

To return the result of the power to which the input value is raised with scimath, use the scimath.power() method −

print("\nResult...\n",np.emath.power(arr, 2))

## Example

import numpy as np # Create a numpy array using the array() method # The array elements also includes negative values arr = np.array([2, -4, -8, 16, -32]) # Display the array print("Our Array...\n",arr) # Check the Dimensions print("\nDimensions of our Array...\n",arr.ndim) # Get the Datatype print("\nDatatype of our Array object...\n",arr.dtype) # Get the Shape print("\nShape of our Array object...\n",arr.shape) # To return the result of the power to which the input value is raised with scimath, use the scimath.power() method in Python print("\nResult...\n",np.emath.power(arr, 2))

## Output

Our Array... [ 2 -4 -8 16 -32] Dimensions of our Array... 1 Datatype of our Array object... int64 Shape of our Array object... (5,) Result... [ 4.+0.j 16.-0.j 64.-0.j 256.+0.j 1024.-0.j]

- Related Articles
- Return the result of the negative power to which the input value is raised with scimath in Python
- Return the result of the power to which the input value is raised with scimath in Python
- Return the square of the complex-value input in Python
- To return value of a number raised to the power of another number, we should use ^ operator in MySQL?
- Compute the square root of negative input with emath in Python
- Return a scalar type which is common to the input arrays 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
- Return the base 2 logarithm for complex value input in Python
- EXPONENTS AND POWER:If the question is that 10 raised by power 22 + 10 raised by power 20, divided by 10 raised by power 20, then calculate the answer.
- Find value of y mod (2 raised to power x) in C++
- 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