Q:

Write a NumPy program to compute natural, base 10, and base 2 logarithms for all elements in a given array

0

Write a NumPy program to compute natural, base 10, and base 2 logarithms for all elements in a given array.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

import numpy as np
x = np.array([1, np.e, np.e**2])
print("Original array: ")
print(x)
print("\nNatural log =", np.log(x))
print("Common log =", np.log10(x))
print("Base 2 log =", np.log2(x))

Sample Output:

Original array: 
[1.         2.71828183 7.3890561 ]

Natural log = [0. 1. 2.]
Common log = [0.         0.43429448 0.86858896]
Base 2 log = [0.         1.44269504 2.88539008]

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now