# Printing logarithmic value of vector/matrix (element wise operation) | Linear Algebra using Python

Linear Algebra using Python | numpy.log() method: Here, we are going to learn how to print logarithmic value of vector/matrix (element wise operation) in Python?
Submitted by Anuj Singh, on May 23, 2020

Prerequisite:

Numpy is the library of function that helps to construct or manipulate matrices and vectors. The function numpy.log(x) is a function used for generating a matrix/vector/variable with the log value of b x (as log(x)). This is an element wise operation where each element in numpy.log(x) corresponds to the logarithmic of that element in x.

Syntax:

```    numpy.log(x)
```

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 log(x) values (between -1 and 1) at each entry.

Applications:

1. Machine Learning
2. Neural Network
3. Geometry
4. Physics Problems

## Python code to print logarithmic value of vector/matrix elements

```# Linear Algebra Learning Sequence
# Element Wise Logarithmic Operation

import numpy as np

# Use of np.array() to define an Vector
V = np.array([323,.623,823])
print("The Vector A : ",V)

VV = np.array([[3,63,.78],[.315,32,42]])
print("\nThe Vector B : \n",VV)

# Using munpy.log() function
print("\nlog(A) : ", np.log(V))
print("\nlog(B) : \n", np.log(VV))
```

Output:

```The Vector A :  [3.23e+02 6.23e-01 8.23e+02]

The Vector B :
[[ 3.    63.     0.78 ]
[ 0.315 32.    42.   ]]

log(A) :  [ 5.77765232 -0.47320876  6.7129562 ]

log(B) :
[[ 1.09861229  4.14313473 -0.24846136]
[-1.15518264  3.4657359   3.73766962]]
```

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates