Home »
Python »
Linear Algebra using Python
Printing the power of vector/matrix elements using pow(x,a) | Linear Algebra using Python
Linear Algebra using Python | pow(x, a) Function: Here, we are going to learn how to print the power of vector/matrix elements using pow(x,a) in Python?
Submitted by Anuj Singh, on May 25, 2020
Prerequisite:
Numpy is the library of function that helps to construct or manipulate matrices and vectors. The function pow(x, a) is a function used for generating a matrix/vector/variable with the log value of b x (as xa). This is an element-wise operation where each element in pow(x, a) corresponds to the xa of that element in x.
Syntax:
power_matrix = pow(x,a)
Input parameter(s):
- x – could be a matrix or vector or a variable.
Return value:
A Matrix or vector or a variable of the same dimensions as input x with xa values at each entry.
Applications:
- Machine Learning
- Neural Network
- General Mathematics
Python code to print the power of vector/matrix elements
# Linear Algebra Learning Sequence
# Element wise Power
import numpy as np
# Use of np.array() to define an Vector
V = np.array([3,6,8])
print("The Vector A : ",V)
# Using power function
print("\npow(A,3) : ", pow(V,3))
print("\npow(A,2) : ", pow(V,2))
Output:
The Vector A : [3 6 8]
pow(A,3) : [ 27 216 512]
pow(A,2) : [ 9 36 64]