Python logspace() Function

The logspace() function is similar to linspace(). The linspace() function produces the evenly spaced points. Similarly, logspace() produces evenly spaced points on a logarithmically spaced scale.

logspace()

The logspace() function is used in the following format:

logspace(start, stop, n)

The logspace() function starts at a value which is 10 to the power of 'start' and ends at a value which is 10 to the power of 'stop'. If 'n' is not specified, then its value is taken as 50. For example, if we write: a = logspace(1, 4, 5)

This function represents values starting from 101 to 104 . These values are divided into 5 equal points and those points are stored into the array 'a'.

logspace() function examples:

A Python program to create an array using logspace().

CopiedCopy Code

from numpy import * 
a = logspace(1, 4, 5)
n = len(a)
for i in range(n): 
print(" %.1f"% a[i], end='  ')

[101 101.75 102.5 103.25 104 ]